Skip to content

Commit

Permalink
For XCode 15, the dyld linker behaviour changed and
Browse files Browse the repository at this point in the history
no longer automatically falls back to checking
the contents of /usr/local/lib when trying to
evaluate an @rpath dependency. As a result,
runtime linking is failing on up-to-date MacOS
systems. The INSTALL_NAME_DIR directive is used
for APPLE builds, to ensure that the installed
library advertises its install path, so libraries
that link to it can find it again when dynamic
linking time arrives.

https://stackoverflow.com/questions/77137284/dynamic-linker-fails-to-find-symbol-at-runtime-after-updating-to-xcode-15
  • Loading branch information
pramsey committed Nov 9, 2023
1 parent cb0550a commit 8cf761b
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 13 deletions.
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,12 @@ add_library(GEOS::geos ALIAS geos)
target_link_libraries(geos PUBLIC geos_cxx_flags PRIVATE $<BUILD_INTERFACE:ryu>)
# ryu is an object library, nothing is actually being linked here. The BUILD_INTERFACE
# switch was necessary to build on AppVeyor (CMake 3.16.2) but not locally (CMake 3.16.3)

if(APPLE AND BUILD_SHARED_LIBS)
set_target_properties(geos PROPERTIES
INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}")
endif()

add_subdirectory(include)
add_subdirectory(src)

Expand All @@ -326,6 +332,11 @@ add_library(geos_c "")
add_library(GEOS::geos_c ALIAS geos_c)
target_link_libraries(geos_c PRIVATE geos)

if(APPLE AND BUILD_SHARED_LIBS)
set_target_properties(geos_c PROPERTIES
INSTALL_NAME_DIR "${CMAKE_INSTALL_FULL_LIBDIR}")
endif()

if(BUILD_SHARED_LIBS)
target_compile_definitions(geos_c
PRIVATE $<$<BOOL:${WIN32}>:GEOS_DLL_EXPORT>)
Expand Down
Binary file added examples/capi_indexed_predicate
Binary file not shown.
13 changes: 0 additions & 13 deletions util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,8 @@
################################################################################

option(BUILD_GEOSOP "Build geosop command-line interface" ON)

message(STATUS "GEOS: Build geosop ${BUILD_GEOSOP}")

if(BUILD_GEOSOP)
if(BUILD_SHARED_LIBS)
if(NOT DEFINED CMAKE_INSTALL_RPATH)
# Use relative rpath
if(APPLE)
set(CMAKE_INSTALL_RPATH "@loader_path/../${CMAKE_INSTALL_LIBDIR}")
else()
set(CMAKE_INSTALL_RPATH "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
endif()
endif()
message(STATUS "GEOS: install runtime path for util: ${CMAKE_INSTALL_RPATH}")
endif()

add_subdirectory(geosop)
endif()
15 changes: 15 additions & 0 deletions util/geosop/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,18 @@ target_link_libraries(geosop PRIVATE geos geos_c)
install(TARGETS geosop
DESTINATION ${CMAKE_INSTALL_BINDIR}
)

if(BUILD_SHARED_LIBS)
if(NOT DEFINED CMAKE_INSTALL_RPATH)
# Use relative rpath
if(APPLE)
set_target_properties(geosop PROPERTIES
INSTALL_RPATH "@loader_path/../${CMAKE_INSTALL_LIBDIR}")
else()
set_target_properties(geosop PROPERTIES
INSTALL_RPATH "\$ORIGIN/../${CMAKE_INSTALL_LIBDIR}")
endif()
endif()
endif()


0 comments on commit 8cf761b

Please sign in to comment.