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