diff --git a/CMakeLists.txt b/CMakeLists.txt index 68e7ca0e..e069342e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,10 +1,12 @@ +# Configuration for building godot-cpp only +# See `tests/CMakeLists.txt` for example configuration +# # Main cmake arguments # # CMAKE_BUILD_TYPE Compilation target (Debug, Release, RelWithDebInfo, MinSizeRel) # # CMAKE_CONFIGURATION_TYPES Set to "Debug;Release;RelWithDebInfo;MinSizeRel" -# if not all needed configurations are created in multi-config generator -# (Setting it in script causes crash on Ninja Multi-Config) +# in top project config or via cmdline (see `test/CMakeLists.txt`) # # TARGET Godot build target (EDITOR, TEMPLATE_DEBUG, TEMPLATE_RELEASE) # @@ -31,9 +33,11 @@ # cmake -DTARGET=TEMPLATE_RELEASE -Bbuild # cmake --build build # -# Creates multi-config setup and builds Release version (example for Linux) +# Creates multi-config setup and builds Release version # -# cmake -G "Ninja Multi-Config" -Bbuild +# cmake -G "Ninja Multi-Config" -Bbuild # For Linux/non-MSVC +# OR +# cmake -G "Visual Studio 16 2019" -A x64 -Bbuild # For Windows/MSVC # cmake --build build --config Release # # Builds web version, using Emscripten toolchain diff --git a/cmake/godotcpp.cmake b/cmake/godotcpp.cmake index d9c20a95..c123c202 100644 --- a/cmake/godotcpp.cmake +++ b/cmake/godotcpp.cmake @@ -94,7 +94,6 @@ set(DEFAULT_OPTIMIZATION "$") set(DEBUG_SYMBOLS_ENABLED "$,$>") # Clean default options -set(CMAKE_CXX_FLAGS "") set(CMAKE_CXX_FLAGS_DEBUG "") set(CMAKE_CXX_FLAGS_RELEASE "") set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "") diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 5a184b47..97e9bcd8 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,14 +1,18 @@ +# Configuration can be used as a template for custom project, read comments cmake_minimum_required(VERSION 3.6) -project(gdexample) +project(gdexample LANGUAGES CXX) + +set(CMAKE_CONFIGURATION_TYPES "Debug;Release;RelWithDebInfo;MinSizeRel") +set(GODOT_CPP_PATH ../) # path to godot-cpp repository add_subdirectory( - ../ # path to godot-cpp + ${GODOT_CPP_PATH} ${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**) +file(GLOB_RECURSE HEADERS src/*.h**) # Define our godot-cpp library if(${PLATFORM} STREQUAL "WEB") @@ -18,6 +22,7 @@ if(${PLATFORM} STREQUAL "WEB") PROPERTIES PREFIX "lib" SUFFIX ".wasm" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/project/bin" RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/project/bin" RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/project/bin" RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/project/bin" @@ -41,20 +46,21 @@ endif() target_link_libraries(${PROJECT_NAME} PUBLIC godot-cpp) -get_directory_property(GODOT_CC_FLAGS DIRECTORY ../ DEFINITION GODOT_CC_FLAGS) -get_directory_property(GODOT_CXX_FLAGS DIRECTORY ../ DEFINITION GODOT_CXX_FLAGS) +get_directory_property(GODOT_CC_FLAGS DIRECTORY ${GODOT_CPP_PATH} DEFINITION GODOT_CC_FLAGS) +get_directory_property(GODOT_CXX_FLAGS DIRECTORY ${GODOT_CPP_PATH} DEFINITION GODOT_CXX_FLAGS) target_compile_options(${PROJECT_NAME} PRIVATE ${GODOT_CC_FLAGS} ${GODOT_CXX_FLAGS} ) -get_directory_property(GODOT_LINK_FLAGS DIRECTORY ../ DEFINITION GODOT_LINK_FLAGS) +get_directory_property(GODOT_LINK_FLAGS DIRECTORY ${GODOT_CPP_PATH} DEFINITION GODOT_LINK_FLAGS) target_link_options(${PROJECT_NAME} PRIVATE ${GODOT_LINK_FLAGS}) -get_directory_property(LIBRARY_SUFFIX DIRECTORY ../ DEFINITION LIBRARY_SUFFIX) +get_directory_property(LIBRARY_SUFFIX DIRECTORY ${GODOT_CPP_PATH} DEFINITION LIBRARY_SUFFIX) set_target_properties(${PROJECT_NAME} PROPERTIES + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/project/bin" LIBRARY_OUTPUT_DIRECTORY_DEBUG "${CMAKE_CURRENT_SOURCE_DIR}/project/bin" LIBRARY_OUTPUT_DIRECTORY_RELEASE "${CMAKE_CURRENT_SOURCE_DIR}/project/bin" LIBRARY_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_CURRENT_SOURCE_DIR}/project/bin"