Skip to content

Commit

Permalink
CMake add select transitive target properties, and macos rpath handling
Browse files Browse the repository at this point in the history
prepending target properties with INTERFACE_ makes the property transitive to consumers.
add INTERFACE_ to BUILD_RPATH_USE_ORIGIN
add INTERFACE_ to POSITION_INDEPENDENT_CODE
add INTERFACE_ to OSX_ARCHITECTURES
enable INTERFACE_MACOSX_RPATH for origin rpath on macos
  • Loading branch information
enetheru committed Nov 28, 2024
1 parent a42b363 commit 762fbe1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
6 changes: 5 additions & 1 deletion cmake/godotcpp.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -264,8 +264,12 @@ function( godotcpp_generate )
CXX_VISIBILITY_PRESET ${GODOT_SYMBOL_VISIBILITY}

COMPILE_WARNING_AS_ERROR ${GODOT_WARNING_AS_ERROR}

POSITION_INDEPENDENT_CODE ON
BUILD_RPATH_USE_ORIGIN ON
INTERFACE_POSITION_INDEPENDENT_CODE ON

# Tell the linker to add the $ORIGIN relative location at build time
INTERFACE_BUILD_RPATH_USE_ORIGIN ON

PREFIX lib
OUTPUT_NAME "${PROJECT_NAME}.${SYSTEM_NAME}.${TARGET_NAME}.${SYSTEM_ARCH}"
Expand Down
5 changes: 5 additions & 0 deletions cmake/macos.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,13 @@ function( macos_generate TARGET_NAME )

set_target_properties( ${TARGET_NAME}
PROPERTIES
# enable RPATH on MACOS, with the BUILD_RPATH_USE_ORIGIN
# this should allow loading libraries from relative paths on macos.
INTERFACE_MACOSX_RPATH ON

# Specify multiple architectures for universal builds
OSX_ARCHITECTURES "${OSX_ARCH}"
INTERFACE_OSX_ARCHITECTURES "${OSX_ARCH}"
)

target_compile_definitions(${TARGET_NAME}
Expand Down
7 changes: 0 additions & 7 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ set_target_properties( godot-cpp-test
CXX_EXTENSIONS OFF
CXX_VISIBILITY_PRESET ${GODOT_SYMBOL_VISIBILITY}

POSITION_INDEPENDENT_CODE ON
BUILD_RPATH_USE_ORIGIN ON
LINK_SEARCH_START_STATIC ON
LINK_SEARCH_END_STATIC ON

Expand All @@ -49,8 +47,6 @@ set_target_properties( godot-cpp-test
)

if( CMAKE_SYSTEM_NAME STREQUAL Darwin )
get_target_property( OSX_ARCH godot-cpp::${TEST_TARGET} OSX_ARCHITECTURES )

set( OUTPUT_DIR "${OUTPUT_DIR}/libgdexample.macos.${TEST_TARGET}.framework")

set_target_properties( godot-cpp-test
Expand All @@ -60,8 +56,5 @@ if( CMAKE_SYSTEM_NAME STREQUAL Darwin )

OUTPUT_NAME "gdexample.macos.${TEST_TARGET}"
SUFFIX ""

#macos options
OSX_ARCHITECTURES "${OSX_ARCH}"
)
endif ()

0 comments on commit 762fbe1

Please sign in to comment.