diff --git a/CMakeLists.txt b/CMakeLists.txt index d114245cf..541288b93 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -406,6 +406,18 @@ if(BUILD_SHARED_LIBS) PRIVATE $<$:GEOS_DLL_EXPORT>) set_target_properties(geos_c PROPERTIES VERSION ${CAPI_VERSION}) + + # See https://github.com/libgeos/geos/issues/1435 + if(NOT DEFINED CMAKE_INSTALL_RPATH) + # Use relative rpath + if(APPLE) + set_target_properties(geos_c PROPERTIES + INSTALL_RPATH "@loader_path") + else() + set_target_properties(geos_c PROPERTIES INSTALL_RPATH "\$ORIGIN") + endif() + endif() + if(NOT WIN32 OR MINGW) set_target_properties(geos_c PROPERTIES SOVERSION ${CAPI_VERSION_MAJOR}) endif()