Merge pull request #683 from nicoraf/test_cmake_windows

pull/712/head
Rémi Verschelde 2022-02-21 00:16:16 +01:00 committed by GitHub
commit 1f03394643
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 165 additions and 33 deletions

View File

@ -120,7 +120,7 @@ jobs:
- name: Build test GDNative library - name: Build test GDNative library
run: | run: |
cd test && cmake -DCMAKE_BUILD_TYPE=Release . cd test && cmake -DCMAKE_BUILD_TYPE=Release -DGODOT_HEADERS_PATH="../godot-headers" -DCPP_BINDINGS_PATH=".." .
make -j $(nproc) make -j $(nproc)
linux-cmake-ninja: linux-cmake-ninja:
@ -144,9 +144,128 @@ jobs:
- name: Build test GDNative library - name: Build test GDNative library
run: | run: |
cd test && cmake -DCMAKE_BUILD_TYPE=Release -GNinja . cd test && cmake -DCMAKE_BUILD_TYPE=Release -DGODOT_HEADERS_PATH="../godot-headers" -DCPP_BINDINGS_PATH=".." -GNinja .
cmake --build . -j $(nproc) cmake --build . -j $(nproc)
windows-msvc:
name: Build (Windows, MSVC)
runs-on: windows-2019
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up Python (for SCons)
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install scons
- name: Build godot-cpp
run: |
scons target=release generate_bindings=yes -j $env:NUMBER_OF_PROCESSORS
- name: Build test project
run: |
cd test
scons target=release -j $env:NUMBER_OF_PROCESSORS
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: godot-cpp-windows-msvc2019-x86_64-release
path: bin/libgodot-cpp.windows.release.64.lib
if-no-files-found: error
windows-msvc-cmake:
name: Build (Windows, MSVC, CMake)
runs-on: windows-2019
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
- name: Build godot-cpp
run: |
cmake -DCMAKE_BUILD_TYPE=Release -G"Visual Studio 16 2019" .
cmake --build .
- name: Build test GDNative library
run: |
cd test && cmake -DCMAKE_BUILD_TYPE=Release -DGODOT_HEADERS_PATH="../godot-headers" -DCPP_BINDINGS_PATH=".." -G"Visual Studio 16 2019" .
cmake --build .
windows-mingw:
name: Build (Windows, MinGW)
runs-on: windows-2019
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up Python (for SCons)
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install scons
- name: Build godot-cpp
# Install GCC from Scoop as the default supplied GCC doesn't work ("Error 1").
run: |
Invoke-Expression (New-Object System.Net.WebClient).DownloadString('https://get.scoop.sh')
scoop install gcc
g++ --version
gcc --version
scons target=release generate_bindings=yes use_mingw=yes -j $env:NUMBER_OF_PROCESSORS
#- name: Build test project (TODO currently not supported, leaving uncommented as a reminder to fix this)
# run: |
# cd test
# scons target=release use_mingw=yes -j $env:NUMBER_OF_PROCESSORS
- name: Upload artifact
uses: actions/upload-artifact@v2
with:
name: godot-cpp-linux-mingw-x86_64-release
path: bin/libgodot-cpp.windows.release.64.a
if-no-files-found: error
macos:
name: Build (macOS, Clang, universal / x86_64 + arm64)
runs-on: macos-11
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
- name: Set up Python (for SCons)
uses: actions/setup-python@v2
with:
python-version: '3.x'
- name: Install dependencies
run: |
python -m pip install scons
- name: Build godot-cpp
run: |
scons target=release generate_bindings=yes -j $(sysctl -n hw.logicalcpu)
- name: Build test project
run: |
cd test
scons target=release -j $(sysctl -n hw.logicalcpu)
static-checks: static-checks:
name: Static Checks (clang-format) name: Static Checks (clang-format)
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04

View File

@ -39,6 +39,17 @@ cmake_minimum_required(VERSION 3.6)
option(GENERATE_TEMPLATE_GET_NODE "Generate a template version of the Node class's get_node." ON) option(GENERATE_TEMPLATE_GET_NODE "Generate a template version of the Node class's get_node." ON)
set(BUILD_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${BUILD_PATH}")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${BUILD_PATH}")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${BUILD_PATH}")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG "${BUILD_PATH}")
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE "${BUILD_PATH}")
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_DEBUG "${BUILD_PATH}")
SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY_RELEASE "${BUILD_PATH}")
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG "${BUILD_PATH}")
SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE "${BUILD_PATH}")
# Default build type is Debug in the SConstruct # Default build type is Debug in the SConstruct
if(CMAKE_BUILD_TYPE STREQUAL "") if(CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE Debug) set(CMAKE_BUILD_TYPE Debug)
@ -68,8 +79,8 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
endif(CMAKE_BUILD_TYPE MATCHES Debug) endif(CMAKE_BUILD_TYPE MATCHES Debug)
# Disable conversion warning, trunkation, unreferenced var, signed missmatch # Disable conversion warning, truncation, unreferenced var, signed missmatch, different type
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /wd4244 /wd4305 /wd4101 /wd4018 /wd4267") set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /wd4244 /wd4305 /wd4101 /wd4018 /wd4267 /wd4099")
# Todo: Check if needed. # Todo: Check if needed.
add_definitions(-DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_WARNINGS) add_definitions(-DWIN32_LEAN_AND_MEAN -D_CRT_SECURE_NO_WARNINGS)
@ -171,7 +182,6 @@ target_include_directories(${PROJECT_NAME}
set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY COMPILE_FLAGS ${GODOT_COMPILE_FLAGS}) set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY COMPILE_FLAGS ${GODOT_COMPILE_FLAGS})
set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS ${GODOT_LINKER_FLAGS}) set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS ${GODOT_LINKER_FLAGS})
set_property(TARGET ${PROJECT_NAME} PROPERTY ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/bin")
# Create the correct name (godot.os.build_type.system_bits) # Create the correct name (godot.os.build_type.system_bits)

4
test/.gitignore vendored
View File

@ -1,3 +1,7 @@
# Generated directories with binaries
build
bin
# Godot 4+ specific ignores # Godot 4+ specific ignores
.godot/ .godot/

View File

@ -1,18 +1,17 @@
project(godot-cpp-test) project(godot-cpp-test)
cmake_minimum_required(VERSION 3.6) cmake_minimum_required(VERSION 3.6)
# Local dependency paths, adapt them to your setup set(GODOT_HEADERS_PATH ../godot-headers/ CACHE STRING "Path to Godot headers")
set(GODOT_HEADERS_PATH ../godot-headers/) set(CPP_BINDINGS_PATH ../ CACHE STRING "Path to C++ bindings")
set(CPP_BINDINGS_PATH ../)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux") if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(TARGET_PATH x11) set(TARGET_PATH x11)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
set(TARGET_PATH win64) set(TARGET_PATH win64)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
set(TARGET_PATH osx) set(TARGET_PATH osx)
else() else()
message(FATAL_ERROR "Not implemented support for ${CMAKE_SYSTEM_NAME}") message(FATAL_ERROR "Not implemented support for ${CMAKE_SYSTEM_NAME}")
endif() endif()
# Change the output directory to the bin directory # Change the output directory to the bin directory
@ -37,7 +36,8 @@ set(GODOT_LINKER_FLAGS )
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
# using Visual Studio C++ # using Visual Studio C++
set(GODOT_COMPILE_FLAGS "/EHsc /WX") # /GF /MP set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /EHsc /WX") # /GF /MP
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /DTYPED_METHOD_BIND")
if(CMAKE_BUILD_TYPE MATCHES Debug) if(CMAKE_BUILD_TYPE MATCHES Debug)
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /MDd") # /Od /RTC1 /Zi set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /MDd") # /Od /RTC1 /Zi
@ -101,10 +101,10 @@ file(GLOB_RECURSE HEADERS include/*.h**)
add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS}) add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS})
target_include_directories(${PROJECT_NAME} SYSTEM target_include_directories(${PROJECT_NAME} SYSTEM
PRIVATE PRIVATE
${CPP_BINDINGS_PATH}/include ${CPP_BINDINGS_PATH}/include
${CPP_BINDINGS_PATH}/gen/include ${CPP_BINDINGS_PATH}/gen/include
${GODOT_HEADERS_PATH} ${GODOT_HEADERS_PATH}
) )
# Create the correct name (godot.os.build_type.system_bits) # Create the correct name (godot.os.build_type.system_bits)
@ -112,35 +112,36 @@ target_include_directories(${PROJECT_NAME} SYSTEM
set(BITS 32) set(BITS 32)
if(CMAKE_SIZEOF_VOID_P EQUAL 8) if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(BITS 64) set(BITS 64)
endif(CMAKE_SIZEOF_VOID_P EQUAL 8) endif(CMAKE_SIZEOF_VOID_P EQUAL 8)
if(CMAKE_BUILD_TYPE MATCHES Debug) if(CMAKE_BUILD_TYPE MATCHES Debug)
set(GODOT_CPP_BUILD_TYPE Debug) set(GODOT_CPP_BUILD_TYPE Debug)
else() else()
set(GODOT_CPP_BUILD_TYPE Release) set(GODOT_CPP_BUILD_TYPE Release)
endif() endif()
string(TOLOWER ${CMAKE_SYSTEM_NAME} SYSTEM_NAME) string(TOLOWER ${CMAKE_SYSTEM_NAME} SYSTEM_NAME)
string(TOLOWER ${GODOT_CPP_BUILD_TYPE} BUILD_TYPE) string(TOLOWER ${GODOT_CPP_BUILD_TYPE} BUILD_TYPE)
if(ANDROID) if(ANDROID)
# Added the android abi after system name # Added the android abi after system name
set(SYSTEM_NAME ${SYSTEM_NAME}.${ANDROID_ABI}) set(SYSTEM_NAME ${SYSTEM_NAME}.${ANDROID_ABI})
endif() endif()
if(CMAKE_VERSION VERSION_GREATER "3.13") if(CMAKE_VERSION VERSION_GREATER "3.13")
target_link_directories(${PROJECT_NAME} target_link_directories(${PROJECT_NAME}
PRIVATE PRIVATE
${CPP_BINDINGS_PATH}/bin/ ${CPP_BINDINGS_PATH}/bin/
) )
target_link_libraries(${PROJECT_NAME}
godot-cpp.${SYSTEM_NAME}.${BUILD_TYPE}$<$<NOT:$<PLATFORM_ID:Android>>:.${BITS}> target_link_libraries(${PROJECT_NAME}
) godot-cpp.${SYSTEM_NAME}.${BUILD_TYPE}$<$<NOT:$<PLATFORM_ID:Android>>:.${BITS}>
)
else() else()
target_link_libraries(${PROJECT_NAME} target_link_libraries(${PROJECT_NAME}
${CPP_BINDINGS_PATH}/bin/libgodot-cpp.${SYSTEM_NAME}.${BUILD_TYPE}$<$<NOT:$<PLATFORM_ID:Android>>:.${BITS}>.a ${CPP_BINDINGS_PATH}/bin/libgodot-cpp.${SYSTEM_NAME}.${BUILD_TYPE}$<$<NOT:$<PLATFORM_ID:Android>>:.${BITS}>.a
) )
endif() endif()
# Add the compile flags # Add the compile flags
@ -148,5 +149,3 @@ set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY COMPILE_FLAGS ${GODOT
set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS ${GODOT_LINKER_FLAGS}) set_property(TARGET ${PROJECT_NAME} APPEND_STRING PROPERTY LINK_FLAGS ${GODOT_LINKER_FLAGS})
set_property(TARGET ${PROJECT_NAME} PROPERTY OUTPUT_NAME "gdexample") set_property(TARGET ${PROJECT_NAME} PROPERTY OUTPUT_NAME "gdexample")