@@ -106,6 +106,13 @@ function(godotcpp_options)
106106 #NOTE: arch is managed by using toolchain files.
107107 # To create a universal build for macos, set CMAKE_OSX_ARCHITECTURES
108108
109+ set (GODOTCPP_TARGET
110+ "template_debug"
111+ CACHE STRING
112+ "Which target to generate. valid values are: template_debug, template_release, and editor"
113+ )
114+ set_property (CACHE GODOTCPP_TARGET PROPERTY STRINGS "template_debug;template_release;editor" )
115+
109116 # Input from user for GDExtension interface header and the API JSON file
110117 set (GODOTCPP_GDEXTENSION_DIR
111118 "gdextension"
@@ -305,94 +312,79 @@ function(godotcpp_generate)
305312 set (IS_DEV_BUILD "$<BOOL:${GODOTCPP_DEV_BUILD} >" )
306313
307314 ### Define our godot-cpp library targets
308- foreach (TARGET_ALIAS template_debug template_release editor)
309- set (TARGET_NAME "godot-cpp.${TARGET_ALIAS} " )
310-
311- # Generator Expressions that rely on the target
312- set (DEBUG_FEATURES "$<NOT:$<STREQUAL:${TARGET_ALIAS} ,template_release>>" )
313- set (HOT_RELOAD "$<IF:${HOT_RELOAD-UNSET},${DEBUG_FEATURES} ,$<BOOL:${GODOTCPP_USE_HOT_RELOAD} >>" )
314-
315- # Suffix
316- string (
317- CONCAT
318- GODOTCPP_SUFFIX
319- "$<1:.${SYSTEM_NAME} >"
320- "$<1:.${TARGET_ALIAS} >"
321- "$<${IS_DEV_BUILD} :.dev>"
322- "$<$<STREQUAL:${GODOTCPP_PRECISION} ,double>:.double>"
323- "$<1:.${ARCH_NAME} >"
324- # TODO IOS_SIMULATOR
325- "$<$<NOT:${THREADS_ENABLED} >:.nothreads>"
326- )
327-
328- # People are compiling godot by itself.
329- set (EXCLUDE EXCLUDE_FROM_ALL )
330- if (GODOTCPP_IS_TOP_LEVEL)
331- if (TARGET_ALIAS STREQUAL template_debug)
332- set (EXCLUDE "" )
333- endif ()
334- endif ()
315+ # Generator Expressions that rely on the target
316+ set (DEBUG_FEATURES "$<NOT:$<STREQUAL:${GODOTCPP_TARGET} ,template_release>>" )
317+ set (HOT_RELOAD "$<IF:${HOT_RELOAD-UNSET},${DEBUG_FEATURES} ,$<BOOL:${GODOTCPP_USE_HOT_RELOAD} >>" )
335318
336- # the godot-cpp.* library targets
337- add_library (${TARGET_NAME} STATIC ${EXCLUDE} )
319+ # Suffix
320+ string (
321+ CONCAT
322+ GODOTCPP_SUFFIX
323+ "$<1:.${SYSTEM_NAME} >"
324+ "$<1:.${GODOTCPP_TARGET} >"
325+ "$<${IS_DEV_BUILD} :.dev>"
326+ "$<$<STREQUAL:${GODOTCPP_PRECISION} ,double>:.double>"
327+ "$<1:.${ARCH_NAME} >"
328+ # TODO IOS_SIMULATOR
329+ "$<$<NOT:${THREADS_ENABLED} >:.nothreads>"
330+ )
338331
339- add_library (godot-cpp::${TARGET_ALIAS} ALIAS ${TARGET_NAME} )
332+ # the godot-cpp.* library targets
333+ add_library (godot-cpp STATIC )
340334
341- file (GLOB_RECURSE GODOTCPP_SOURCES LIST_DIRECTORIES NO CONFIGURE_DEPENDS src/*.cpp)
335+ # Added for backwards compatibility with prior cmake solution so that builds dont immediately break
336+ # from a missing target.
337+ add_library (godot::cpp ALIAS godot-cpp)
342338
343- target_sources ( ${TARGET_NAME} PRIVATE ${GODOTCPP_SOURCES} ${GENERATED_FILES_LIST} )
339+ file (GLOB_RECURSE GODOTCPP_SOURCES LIST_DIRECTORIES NO CONFIGURE_DEPENDS src/*.cpp )
344340
345- target_include_directories (
346- ${TARGET_NAME}
347- ${GODOTCPP_SYSTEM_HEADERS_ATTRIBUTE}
348- PUBLIC include ${CMAKE_CURRENT_BINARY_DIR} /gen/include ${GODOTCPP_GDEXTENSION_DIR}
349- )
341+ target_sources (godot-cpp PRIVATE ${GODOTCPP_SOURCES} ${GENERATED_FILES_LIST} )
350342
351- # gersemi: off
352- set_target_properties (
353- ${TARGET_NAME}
354- PROPERTIES
355- CXX_STANDARD 17
356- CXX_EXTENSIONS OFF
357- CXX_VISIBILITY_PRESET ${GODOTCPP_SYMBOL_VISIBILITY}
343+ target_include_directories (
344+ godot-cpp
345+ ${GODOTCPP_SYSTEM_HEADERS_ATTRIBUTE}
346+ PUBLIC include ${CMAKE_CURRENT_BINARY_DIR} /gen/include ${GODOTCPP_GDEXTENSION_DIR}
347+ )
358348
359- COMPILE_WARNING_AS_ERROR ${GODOTCPP_WARNING_AS_ERROR}
360- POSITION_INDEPENDENT_CODE ON
361- BUILD_RPATH_USE_ORIGIN ON
349+ # gersemi: off
350+ set_target_properties (
351+ godot-cpp
352+ PROPERTIES
353+ CXX_STANDARD 17
354+ CXX_EXTENSIONS OFF
355+ CXX_VISIBILITY_PRESET ${GODOTCPP_SYMBOL_VISIBILITY}
362356
363- PREFIX "lib"
364- OUTPUT_NAME "${PROJECT_NAME}${GODOTCPP_SUFFIX} "
357+ COMPILE_WARNING_AS_ERROR ${GODOTCPP_WARNING_AS_ERROR}
358+ POSITION_INDEPENDENT_CODE ON
359+ BUILD_RPATH_USE_ORIGIN ON
365360
366- ARCHIVE_OUTPUT_DIRECTORY "$<1:${CMAKE_BINARY_DIR} /bin>"
361+ PREFIX "lib"
362+ OUTPUT_NAME "${PROJECT_NAME}${GODOTCPP_SUFFIX} "
367363
368- # Things that are handy to know for dependent targets
369- GODOTCPP_PLATFORM "${SYSTEM_NAME} "
370- GODOTCPP_TARGET "${TARGET_ALIAS} "
371- GODOTCPP_ARCH "${ARCH_NAME} "
372- GODOTCPP_PRECISION "${GODOTCPP_PRECISION} "
373- GODOTCPP_SUFFIX "${GODOTCPP_SUFFIX} "
364+ ARCHIVE_OUTPUT_DIRECTORY "$<1:${CMAKE_BINARY_DIR} /bin>"
374365
375- # Some IDE's respect this property to logically group targets
376- FOLDER "godot-cpp"
377- )
378- # gersemi: on
379-
380- if (CMAKE_SYSTEM_NAME STREQUAL Android)
381- android_generate()
382- elseif (CMAKE_SYSTEM_NAME STREQUAL iOS)
383- ios_generate()
384- elseif (CMAKE_SYSTEM_NAME STREQUAL Linux)
385- linux_generate()
386- elseif (CMAKE_SYSTEM_NAME STREQUAL Darwin)
387- macos_generate()
388- elseif (CMAKE_SYSTEM_NAME STREQUAL Emscripten)
389- web_generate()
390- elseif (CMAKE_SYSTEM_NAME STREQUAL Windows)
391- windows_generate()
392- endif ()
393- endforeach ()
366+ # Things that are handy to know for dependent targets
367+ GODOTCPP_PLATFORM "${SYSTEM_NAME} "
368+ GODOTCPP_TARGET "${GODOTCPP_TARGET} "
369+ GODOTCPP_ARCH "${ARCH_NAME} "
370+ GODOTCPP_PRECISION "${GODOTCPP_PRECISION} "
371+ GODOTCPP_SUFFIX "${GODOTCPP_SUFFIX} "
394372
395- # Added for backwards compatibility with prior cmake solution so that builds dont immediately break
396- # from a missing target.
397- add_library (godot::cpp ALIAS godot-cpp.template_debug)
373+ # Some IDE's respect this property to logically group targets
374+ FOLDER "godot-cpp"
375+ )
376+ # gersemi: on
377+ if (CMAKE_SYSTEM_NAME STREQUAL Android)
378+ android_generate()
379+ elseif (CMAKE_SYSTEM_NAME STREQUAL iOS)
380+ ios_generate()
381+ elseif (CMAKE_SYSTEM_NAME STREQUAL Linux)
382+ linux_generate()
383+ elseif (CMAKE_SYSTEM_NAME STREQUAL Darwin)
384+ macos_generate()
385+ elseif (CMAKE_SYSTEM_NAME STREQUAL Emscripten)
386+ web_generate()
387+ elseif (CMAKE_SYSTEM_NAME STREQUAL Windows)
388+ windows_generate()
389+ endif ()
398390endfunction ()
0 commit comments