Skip to content
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

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
26 changes: 23 additions & 3 deletions cmake/godotcpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ set( PLATFORM_LIST linux macos windows android ios web )

# List of known architectures
set( ARCH_LIST universal x86_32 x86_64 arm32 arm64 rv64 ppc32 ppc64 wasm32 )

# Function to map processors to known architectures
function( godot_arch_map ALIAS PROC )
string( TOLOWER "${PROC}" PROC )
Expand Down Expand Up @@ -147,6 +146,25 @@ function( godotcpp_options )

# Enable Testing
option( GODOT_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(GODOT_ADD_TARGET_TEMPLATE_RELEASE "Add template_release target to build" ON)
option(GODOT_ADD_TARGET_TEMPLATE_DEBUG "Add template_debug target to build" ON)
option(GODOT_ADD_TARGET_EDITOR "Add editor target to build" ON)
if(GODOT_ADD_TARGET_TEMPLATE_DEBUG)
list(APPEND GODOT_TARGETS "template_debug")
endif()
if(GODOT_ADD_TARGET_TEMPLATE_RELEASE)
list(APPEND GODOT_TARGETS "template_release")
endif()
if(GODOT_ADD_TARGET_EDITOR)
list(APPEND GODOT_TARGETS "editor")
endif()
if(NOT GODOT_TARGETS)
message(FATAL_ERROR "No targets were chosen to be built. See GODOT_ADD_TARGET_* variables: at least one of the should be ON")
endif()
# parent scoping GODOT_TARGETS
set(GODOT_TARGETS ${GODOT_TARGETS} PARENT_SCOPE)

#[[ Target Platform Options ]]
android_options()
Expand Down Expand Up @@ -276,7 +294,7 @@ function( godotcpp_generate )
set( DEV_TAG "$<${IS_DEV_BUILD}:.dev>" )

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

# Generator Expressions that rely on the target
Expand Down Expand Up @@ -342,6 +360,8 @@ function( godotcpp_generate )

# Added for backwards compatibility with prior cmake solution so that builds dont immediately break
# from a missing target.
add_library( godot::cpp ALIAS godot-cpp.template_debug )
# since targets can be turned off, we need to know which one is left (the order is 'template_debug' 'template_release' 'editor')
list(GET GODOT_TARGETS 0 GODOT_DEFAULT_TARGET)
add_library( godot::cpp ALIAS godot-cpp.${GODOT_DEFAULT_TARGET} )

endfunction()
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ file( GLOB_RECURSE DOC_XML
set( DOC_DATA_SOURCE "${CMAKE_CURRENT_BINARY_DIR}/src/gen/doc_data.gen.cpp" )
generate_doc_source( "${DOC_DATA_SOURCE}" "${DOC_XML}" )

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

Expand Down
Loading