diff --git a/CMakeLists.txt b/CMakeLists.txt index eb878dfe..32dce3ec 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,11 +40,17 @@ For example; the tools/godotcpp.py is matched by the cmake/godotcpp.cmake file The CMake equivalent is below. ]=======================================================================] - include(cmake/godotcpp.cmake) godotcpp_options() +#[[ People are compiling godot by itself and expecting template_debug +Replace this with PROJECT_IS_TOP_LEVEL, _IS_TOP_LEVEL when minimum reaches 3.21 +]] +if(NOT PROJECT_NAME) + set(GODOTCPP_IS_TOP_LEVEL ON) +endif() + # Define our project. project( godot-cpp diff --git a/cmake/godotcpp.cmake b/cmake/godotcpp.cmake index d7397fbc..cc512089 100644 --- a/cmake/godotcpp.cmake +++ b/cmake/godotcpp.cmake @@ -325,8 +325,17 @@ function(godotcpp_generate) "$<$:.nothreads>" ) + # People are compiling godot by itself. + set(EXCLUDE EXCLUDE_FROM_ALL) + if(GODOTCPP_IS_TOP_LEVEL) + if(TARGET_ALIAS STREQUAL template_debug) + set(EXCLUDE "") + endif() + endif() + # the godot-cpp.* library targets - add_library(${TARGET_NAME} STATIC EXCLUDE_FROM_ALL) + add_library(${TARGET_NAME} STATIC ${EXCLUDE}) + add_library(godot-cpp::${TARGET_ALIAS} ALIAS ${TARGET_NAME}) file(GLOB_RECURSE GODOTCPP_SOURCES LIST_DIRECTORIES NO CONFIGURE_DEPENDS src/*.cpp)