-
-
Notifications
You must be signed in to change notification settings - Fork 615
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CMake test project rewrite, test script exports before running test
- Loading branch information
Vano
committed
Jan 8, 2024
1 parent
450994a
commit 3d4d41e
Showing
3 changed files
with
86 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,143 +1,59 @@ | ||
project(godot-cpp-test) | ||
cmake_minimum_required(VERSION 3.6) | ||
cmake_minimum_required(VERSION 3.24) | ||
project(gdexample) | ||
|
||
set(GODOT_GDEXTENSION_DIR ../gdextension/ CACHE STRING "Path to GDExtension interface header directory") | ||
set(CPP_BINDINGS_PATH ../ CACHE STRING "Path to C++ bindings") | ||
|
||
if(CMAKE_SYSTEM_NAME STREQUAL "Linux") | ||
set(TARGET_PATH x11) | ||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows") | ||
set(TARGET_PATH win64) | ||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin") | ||
set(TARGET_PATH macos) | ||
else() | ||
message(FATAL_ERROR "Not implemented support for ${CMAKE_SYSTEM_NAME}") | ||
endif() | ||
|
||
# Change the output directory to the bin directory | ||
set(BUILD_PATH ${CMAKE_SOURCE_DIR}/bin/${TARGET_PATH}) | ||
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}") | ||
|
||
# Set the c++ standard to c++17 | ||
set(CMAKE_CXX_STANDARD 17) | ||
set(CMAKE_CXX_STANDARD_REQUIRED ON) | ||
set(CMAKE_CXX_EXTENSIONS OFF) | ||
|
||
set(GODOT_COMPILE_FLAGS ) | ||
set(GODOT_LINKER_FLAGS ) | ||
|
||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") | ||
# using Visual Studio C++ | ||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /WX") # /GF /MP | ||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /DTYPED_METHOD_BIND") | ||
|
||
if(CMAKE_BUILD_TYPE MATCHES Debug) | ||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /MDd") # /Od /RTC1 /Zi | ||
else() | ||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /MD /O2") # /Oy /GL /Gy | ||
STRING(REGEX REPLACE "/RTC(su|[1su])" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") | ||
string(REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG}) | ||
endif(CMAKE_BUILD_TYPE MATCHES Debug) | ||
|
||
# Disable conversion warning, truncation, unreferenced var, signed mismatch | ||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /wd4244 /wd4305 /wd4101 /wd4018 /wd4267") | ||
|
||
add_definitions(-DNOMINMAX) | ||
|
||
# Unkomment for warning level 4 | ||
#if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") | ||
# string(REGEX REPLACE "/W[0-4]" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") | ||
#endif() | ||
|
||
else() | ||
|
||
set(GODOT_LINKER_FLAGS "-static-libgcc -static-libstdc++ -Wl,-R,'$$ORIGIN'") | ||
|
||
set(GODOT_COMPILE_FLAGS "-fPIC -g -Wwrite-strings") | ||
|
||
if(CMAKE_BUILD_TYPE MATCHES Debug) | ||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -fno-omit-frame-pointer -O0") | ||
else() | ||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -O3") | ||
endif(CMAKE_BUILD_TYPE MATCHES Debug) | ||
endif() | ||
|
||
# Disable exception handling. Godot doesn't use exceptions anywhere, and this | ||
# saves around 20% of binary size and very significant build time (GH-80513). | ||
option(GODOT_DISABLE_EXCEPTIONS ON "Force disabling exception handling code") | ||
if (GODOT_DISABLE_EXCEPTIONS) | ||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") | ||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -D_HAS_EXCEPTIONS=0") | ||
else() | ||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -fno-exceptions") | ||
endif() | ||
else() | ||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") | ||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} /EHsc") | ||
endif() | ||
endif() | ||
add_subdirectory( | ||
../ # path to godot-cpp | ||
${CMAKE_CURRENT_BINARY_DIR}/godot-cpp # needed because godot-cpp is top directory | ||
) | ||
|
||
# Get Sources | ||
file(GLOB_RECURSE SOURCES src/*.c**) | ||
file(GLOB_RECURSE HEADERS include/*.h**) | ||
|
||
# Define our godot-cpp library | ||
add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS}) | ||
|
||
target_include_directories(${PROJECT_NAME} SYSTEM | ||
PRIVATE | ||
${CPP_BINDINGS_PATH}/include | ||
${CPP_BINDINGS_PATH}/gen/include | ||
${GODOT_GDEXTENSION_DIR} | ||
) | ||
|
||
# Create the correct name (godot.os.build_type.system_bits) | ||
# Synchronized with godot-cpp's CMakeLists.txt | ||
|
||
set(BITS 32) | ||
if(CMAKE_SIZEOF_VOID_P EQUAL 8) | ||
set(BITS 64) | ||
endif(CMAKE_SIZEOF_VOID_P EQUAL 8) | ||
|
||
if(CMAKE_BUILD_TYPE MATCHES Debug) | ||
set(GODOT_CPP_BUILD_TYPE Debug) | ||
if(${PLATFORM} STREQUAL "WEB") | ||
# wasm libraries loaded with dlopen() are created like this in cmake | ||
add_executable(${PROJECT_NAME} ${SOURCES} ${HEADERS}) | ||
set_target_properties(${PROJECT_NAME} | ||
PROPERTIES | ||
PREFIX "lib" | ||
SUFFIX ".wasm" | ||
) | ||
elseif(${PLATFORM} STREQUAL "MACOS") | ||
# TODO: create framework with cmake FRAMEWORK property | ||
# or with template file | ||
message(WARNING "Mac/IOS framework configuration is not tested and may not work.") | ||
|
||
add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS}) | ||
set_target_properties(${PROJECT_NAME} PROPERTIES | ||
FRAMEWORK TRUE | ||
MACOSX_FRAMEWORK_IDENTIFIER com.godotengine.${PROJECT_NAME} | ||
MACOSX_FRAMEWORK_INFO_PLIST Info.plist | ||
) | ||
else() | ||
set(GODOT_CPP_BUILD_TYPE Release) | ||
add_library(${PROJECT_NAME} SHARED ${SOURCES} ${HEADERS}) | ||
endif() | ||
|
||
string(TOLOWER ${CMAKE_SYSTEM_NAME} SYSTEM_NAME) | ||
string(TOLOWER ${GODOT_CPP_BUILD_TYPE} BUILD_TYPE) | ||
target_link_libraries(${PROJECT_NAME} PUBLIC godot-cpp) | ||
|
||
if(ANDROID) | ||
# Added the android abi after system name | ||
set(SYSTEM_NAME ${SYSTEM_NAME}.${ANDROID_ABI}) | ||
endif() | ||
get_directory_property(GODOT_CC_FLAGS DIRECTORY ../ DEFINITION GODOT_CC_FLAGS) | ||
get_directory_property(GODOT_CXX_FLAGS DIRECTORY ../ DEFINITION GODOT_CXX_FLAGS) | ||
target_compile_options(${PROJECT_NAME} PRIVATE | ||
${GODOT_CC_FLAGS} | ||
${GODOT_CXX_FLAGS} | ||
) | ||
|
||
if(CMAKE_VERSION VERSION_GREATER "3.13") | ||
target_link_directories(${PROJECT_NAME} | ||
PRIVATE | ||
${CPP_BINDINGS_PATH}/bin/ | ||
) | ||
get_directory_property(GODOT_LINK_FLAGS DIRECTORY ../ DEFINITION GODOT_LINK_FLAGS) | ||
target_link_options(${PROJECT_NAME} PRIVATE ${GODOT_LINK_FLAGS}) | ||
|
||
target_link_libraries(${PROJECT_NAME} | ||
godot-cpp.${SYSTEM_NAME}.${BUILD_TYPE}$<$<NOT:$<PLATFORM_ID:Android>>:.${BITS}> | ||
) | ||
else() | ||
target_link_libraries(${PROJECT_NAME} | ||
${CPP_BINDINGS_PATH}/bin/libgodot-cpp.${SYSTEM_NAME}.${BUILD_TYPE}$<$<NOT:$<PLATFORM_ID:Android>>:.${BITS}>.a | ||
) | ||
endif() | ||
|
||
# Add the 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}) | ||
get_directory_property(LIBRARY_SUFFIX DIRECTORY ../ DEFINITION LIBRARY_SUFFIX) | ||
set_target_properties(${PROJECT_NAME} | ||
PROPERTIES | ||
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/project/bin" | ||
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/project/bin" | ||
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/project/bin" | ||
|
||
OUTPUT_NAME "${PROJECT_NAME}${LIBRARY_SUFFIX}" | ||
) | ||
|
||
set_property(TARGET ${PROJECT_NAME} PROPERTY OUTPUT_NAME "gdexample") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
[preset.0] | ||
|
||
name="<null>" | ||
platform="Linux/X11" | ||
runnable=false | ||
dedicated_server=false | ||
custom_features="" | ||
export_filter="all_resources" | ||
include_filter="" | ||
exclude_filter="" | ||
export_path="" | ||
encryption_include_filters="" | ||
encryption_exclude_filters="" | ||
encrypt_pck=false | ||
encrypt_directory=false | ||
|
||
[preset.0.options] | ||
|
||
custom_template/debug="" | ||
custom_template/release="" | ||
debug/export_console_wrapper=1 | ||
binary_format/embed_pck=false | ||
texture_format/bptc=true | ||
texture_format/s3tc=true | ||
texture_format/etc=false | ||
texture_format/etc2=false | ||
binary_format/architecture="x86_64" | ||
ssh_remote_deploy/enabled=false | ||
ssh_remote_deploy/host="user@host_ip" | ||
ssh_remote_deploy/port="22" | ||
ssh_remote_deploy/extra_args_ssh="" | ||
ssh_remote_deploy/extra_args_scp="" | ||
ssh_remote_deploy/run_script="#!/usr/bin/env bash | ||
export DISPLAY=:0 | ||
unzip -o -q \"{temp_dir}/{archive_name}\" -d \"{temp_dir}\" | ||
\"{temp_dir}/{exe_name}\" {cmd_args}" | ||
ssh_remote_deploy/cleanup_script="#!/usr/bin/env bash | ||
kill $(pgrep -x -f \"{temp_dir}/{exe_name} {cmd_args}\") | ||
rm -rf \"{temp_dir}\"" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters