From 7a9b1ee1419bcc39ca74522777076e45f4ee8490 Mon Sep 17 00:00:00 2001 From: Samuel Nicholas Date: Sun, 29 Dec 2024 13:43:02 +1030 Subject: [PATCH] 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 --- cmake/godotcpp.cmake | 26 +++++++++++++++++++------- test/CMakeLists.txt | 22 ++++++++-------------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/cmake/godotcpp.cmake b/cmake/godotcpp.cmake index e898a9d3..72999b7a 100644 --- a/cmake/godotcpp.cmake +++ b/cmake/godotcpp.cmake @@ -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}'") endif () set( IS_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 foreach ( TARGET_ALIAS template_debug template_release editor ) @@ -277,6 +275,17 @@ function( godotcpp_generate ) set( DEBUG_FEATURES "$>" ) set( HOT_RELOAD "$>" ) + # Suffix + string( JOIN "" GODOT_SUFFIX + "$<1:.${SYSTEM_NAME}>" + "$<1:.${TARGET_ALIAS}>" + "$<${IS_DEV_BUILD}:.dev>" + "$<$:.double>" + "$<1:.${SYSTEM_ARCH}>" + # missing IOS_SIMULATOR + # missing THREADS + ) + # the godot-cpp.* library targets add_library( ${TARGET_NAME} STATIC EXCLUDE_FROM_ALL ) add_library( godot-cpp::${TARGET_ALIAS} ALIAS ${TARGET_NAME} ) @@ -306,14 +315,17 @@ function( godotcpp_generate ) POSITION_INDEPENDENT_CODE ON INTERFACE_POSITION_INDEPENDENT_CODE ON - PREFIX lib - OUTPUT_NAME "${PROJECT_NAME}.${SYSTEM_NAME}.${TARGET_ALIAS}${DEV_TAG}.${SYSTEM_ARCH}" + PREFIX "lib" + OUTPUT_NAME "${PROJECT_NAME}${GODOT_SUFFIX}" + ARCHIVE_OUTPUT_DIRECTORY "$<1:${CMAKE_BINARY_DIR}/bin>" # Things that are handy to know for dependent targets - GODOT_PLATFORM "${SYSTEM_NAME}" - GODOT_TARGET "${TARGET_ALIAS}" - GODOT_ARCH "${SYSTEM_ARCH}" + GODOT_PLATFORM "${SYSTEM_NAME}" + GODOT_TARGET "${TARGET_ALIAS}" + GODOT_ARCH "${SYSTEM_ARCH}" + GODOT_PRECISION "${GODOT_PRECISION}" + GODOT_SUFFIX "${GODOT_SUFFIX}" # Some IDE's respect this property to logically group targets FOLDER "godot-cpp" diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 289fef28..8b7d7251 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -21,20 +21,10 @@ foreach( TARGET_ALIAS template_debug template_release editor ) set( LINK_TARGET "godot-cpp::${TARGET_ALIAS}" ) ### Get useful properties of the library - get_target_property( GODOT_PLATFORM ${LINK_TARGET} GODOT_PLATFORM ) - get_target_property( GODOT_TARGET ${LINK_TARGET} GODOT_TARGET ) - get_target_property( GODOT_ARCH ${LINK_TARGET} GODOT_ARCH ) + get_target_property( GODOT_SUFFIX ${LINK_TARGET} GODOT_SUFFIX ) get_target_property( OSX_ARCH ${LINK_TARGET} OSX_ARCHITECTURES ) - set( DEV_TAG "$<$:.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_NAME "gdexample.${GODOT_PLATFORM}.${GODOT_TARGET}${DEV_TAG}.${GODOT_ARCH}" ) - endif() + set( OUTPUT_DIR "${CMAKE_CURRENT_SOURCE_DIR}/project/bin/" ) 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 PREFIX "lib" - OUTPUT_NAME "gdexample.${GODOT_PLATFORM}.${GODOT_TARGET}${DEV_TAG}.${GODOT_ARCH}" + OUTPUT_NAME "gdexample${GODOT_SUFFIX}" #macos options, ignored on other platforms 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 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 () endforeach()