replace ad-hock name construction with new GODOT_SUFFIX

- This replicates how SCons does it.
- Modify test project to use GODOT_SUFFIX
- Add GODOT_SUFFIX to libgodot-cpp properties
pull/1683/head
Samuel Nicholas 2024-12-29 13:43:02 +10:30
parent 2baa0fdfc3
commit 7a9b1ee141
2 changed files with 27 additions and 21 deletions

View File

@ -266,8 +266,6 @@ function( godotcpp_generate )
message( WARNING "=> GODOT_DEV_BUILD implies a Debug-like build but CMAKE_BUILD_TYPE is '${CMAKE_BUILD_TYPE}'") message( WARNING "=> GODOT_DEV_BUILD implies a Debug-like build but CMAKE_BUILD_TYPE is '${CMAKE_BUILD_TYPE}'")
endif () endif ()
set( IS_DEV_BUILD "$<BOOL:${GODOT_DEV_BUILD}>") set( IS_DEV_BUILD "$<BOOL:${GODOT_DEV_BUILD}>")
# The .dev portion of the name if GODOT_DEV_BUILD is true.
set( DEV_TAG "$<${IS_DEV_BUILD}:.dev>" )
### Define our godot-cpp library targets ### Define our godot-cpp library targets
foreach ( TARGET_ALIAS template_debug template_release editor ) foreach ( TARGET_ALIAS template_debug template_release editor )
@ -277,6 +275,17 @@ function( godotcpp_generate )
set( DEBUG_FEATURES "$<NOT:$<STREQUAL:${TARGET_NAME},template_release>>" ) set( DEBUG_FEATURES "$<NOT:$<STREQUAL:${TARGET_NAME},template_release>>" )
set( HOT_RELOAD "$<IF:${HOT_RELOAD-UNSET},${DEBUG_FEATURES},$<BOOL:${GODOT_USE_HOT_RELOAD}>>" ) set( HOT_RELOAD "$<IF:${HOT_RELOAD-UNSET},${DEBUG_FEATURES},$<BOOL:${GODOT_USE_HOT_RELOAD}>>" )
# Suffix
string( JOIN "" GODOT_SUFFIX
"$<1:.${SYSTEM_NAME}>"
"$<1:.${TARGET_ALIAS}>"
"$<${IS_DEV_BUILD}:.dev>"
"$<$<STREQUAL:${GODOT_PRECISION},double>:.double>"
"$<1:.${SYSTEM_ARCH}>"
# missing IOS_SIMULATOR
# missing THREADS
)
# the godot-cpp.* library targets # the godot-cpp.* library targets
add_library( ${TARGET_NAME} STATIC EXCLUDE_FROM_ALL ) add_library( ${TARGET_NAME} STATIC EXCLUDE_FROM_ALL )
add_library( godot-cpp::${TARGET_ALIAS} ALIAS ${TARGET_NAME} ) add_library( godot-cpp::${TARGET_ALIAS} ALIAS ${TARGET_NAME} )
@ -306,14 +315,17 @@ function( godotcpp_generate )
POSITION_INDEPENDENT_CODE ON POSITION_INDEPENDENT_CODE ON
INTERFACE_POSITION_INDEPENDENT_CODE ON INTERFACE_POSITION_INDEPENDENT_CODE ON
PREFIX lib PREFIX "lib"
OUTPUT_NAME "${PROJECT_NAME}.${SYSTEM_NAME}.${TARGET_ALIAS}${DEV_TAG}.${SYSTEM_ARCH}" OUTPUT_NAME "${PROJECT_NAME}${GODOT_SUFFIX}"
ARCHIVE_OUTPUT_DIRECTORY "$<1:${CMAKE_BINARY_DIR}/bin>" ARCHIVE_OUTPUT_DIRECTORY "$<1:${CMAKE_BINARY_DIR}/bin>"
# Things that are handy to know for dependent targets # Things that are handy to know for dependent targets
GODOT_PLATFORM "${SYSTEM_NAME}" GODOT_PLATFORM "${SYSTEM_NAME}"
GODOT_TARGET "${TARGET_ALIAS}" GODOT_TARGET "${TARGET_ALIAS}"
GODOT_ARCH "${SYSTEM_ARCH}" GODOT_ARCH "${SYSTEM_ARCH}"
GODOT_PRECISION "${GODOT_PRECISION}"
GODOT_SUFFIX "${GODOT_SUFFIX}"
# Some IDE's respect this property to logically group targets # Some IDE's respect this property to logically group targets
FOLDER "godot-cpp" FOLDER "godot-cpp"

View File

@ -21,20 +21,10 @@ foreach( TARGET_ALIAS template_debug template_release editor )
set( LINK_TARGET "godot-cpp::${TARGET_ALIAS}" ) set( LINK_TARGET "godot-cpp::${TARGET_ALIAS}" )
### Get useful properties of the library ### Get useful properties of the library
get_target_property( GODOT_PLATFORM ${LINK_TARGET} GODOT_PLATFORM ) get_target_property( GODOT_SUFFIX ${LINK_TARGET} GODOT_SUFFIX )
get_target_property( GODOT_TARGET ${LINK_TARGET} GODOT_TARGET )
get_target_property( GODOT_ARCH ${LINK_TARGET} GODOT_ARCH )
get_target_property( OSX_ARCH ${LINK_TARGET} OSX_ARCHITECTURES ) get_target_property( OSX_ARCH ${LINK_TARGET} OSX_ARCHITECTURES )
set( DEV_TAG "$<$<BOOL:${GODOT_DEV_BUILD}>:.dev>" )
if( CMAKE_SYSTEM_NAME STREQUAL Darwin )
set( OUTPUT_DIR "${OUTPUT_DIR}/libgdexample.macos.${TEST_TARGET}.framework")
set( OUTPUT_NAME "gdexample.macos.${TEST_TARGET}${DEV_TAG}" )
else()
set( OUTPUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/project/bin/" ) set( OUTPUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/project/bin/" )
set( OUTPUT_NAME "gdexample.${GODOT_PLATFORM}.${GODOT_TARGET}${DEV_TAG}.${GODOT_ARCH}" )
endif()
add_library( ${TARGET_NAME} SHARED EXCLUDE_FROM_ALL ) add_library( ${TARGET_NAME} SHARED EXCLUDE_FROM_ALL )
@ -74,7 +64,7 @@ foreach( TARGET_ALIAS template_debug template_release editor )
PDB_OUTPUT_DIRECTORY "$<1:${OUTPUT_DIR}>" #MSVC Only, ignored on other platforms PDB_OUTPUT_DIRECTORY "$<1:${OUTPUT_DIR}>" #MSVC Only, ignored on other platforms
PREFIX "lib" PREFIX "lib"
OUTPUT_NAME "gdexample.${GODOT_PLATFORM}.${GODOT_TARGET}${DEV_TAG}.${GODOT_ARCH}" OUTPUT_NAME "gdexample${GODOT_SUFFIX}"
#macos options, ignored on other platforms #macos options, ignored on other platforms
OSX_ARCHITECTURES "${OSX_ARCH}" OSX_ARCHITECTURES "${OSX_ARCH}"
@ -89,7 +79,11 @@ foreach( TARGET_ALIAS template_debug template_release editor )
# Only blank the suffix on osx to match SCons # Only blank the suffix on osx to match SCons
if( CMAKE_SYSTEM_NAME STREQUAL Darwin ) if( CMAKE_SYSTEM_NAME STREQUAL Darwin )
set_target_properties( ${TARGET_NAME} PROPERTIES SUFFIX "" ) set_target_properties( ${TARGET_NAME}
PROPERTIES
SUFFIX ""
OUTPUT_DIR "${OUTPUT_DIR}/libgdexample.macos.${TARGET_ALIAS}.framework"
)
endif () endif ()
endforeach() endforeach()