Skip to content

Added options to enable/disable targets to be added to a cmake build. #1650

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion cmake/godotcpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,28 @@ function(godotcpp_options)

# Enable Testing
option(GODOTCPP_ENABLE_TESTING "Enable the godot-cpp.test.<target> integration testing targets" OFF)
# Define which targets create for build. By default all targets are included
# Not presented in SCons
option(GODOTCPP_ADD_TARGET_TEMPLATE_RELEASE "Add template_release target to build" ON)
option(GODOTCPP_ADD_TARGET_TEMPLATE_DEBUG "Add template_debug target to build" ON)
option(GODOTCPP_ADD_TARGET_EDITOR "Add editor target to build" ON)
if(GODOTCPP_ADD_TARGET_TEMPLATE_DEBUG)
list(APPEND GODOTCPP_TARGETS "template_debug")
endif()
if(GODOTCPP_ADD_TARGET_TEMPLATE_RELEASE)
list(APPEND GODOTCPP_TARGETS "template_release")
endif()
if(GODOTCPP_ADD_TARGET_EDITOR)
list(APPEND GODOTCPP_TARGETS "editor")
endif()
if(NOT GODOTCPP_TARGETS)
message(
FATAL_ERROR
"No targets were chosen to be build.See GODOTCPP_ADD_TARGET_* variables: at least one of the should be ON"
)
endif()
# parent scoping GODOTCPP_TARGETS
set(GODOTCPP_TARGETS ${GODOTCPP_TARGETS} PARENT_SCOPE)

#[[ Target Platform Options ]]
android_options()
Expand Down Expand Up @@ -310,7 +332,7 @@ function(godotcpp_generate)
set(IS_DEV_BUILD "$<BOOL:${GODOTCPP_DEV_BUILD}>")

### Define our godot-cpp library targets
foreach(TARGET_ALIAS template_debug template_release editor)
foreach(TARGET_ALIAS ${GODOTCPP_TARGETS})
set(TARGET_NAME "godot-cpp.${TARGET_ALIAS}")

# Generator Expressions that rely on the target
Expand Down
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ message(STATUS "Testing Integration targets are enabled.")
# Generate Doc Data
file(GLOB_RECURSE DOC_XML LIST_DIRECTORIES NO CONFIGURE_DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/doc_classes/*.xml")

foreach(TARGET_ALIAS template_debug template_release editor)
foreach(TARGET_ALIAS ${GODOTCPP_TARGETS})
set(TARGET_NAME "godot-cpp.test.${TARGET_ALIAS}")

add_library(${TARGET_NAME} SHARED EXCLUDE_FROM_ALL)
Expand Down