Fix the rpath with option - plugins fail without (#5298)

* Only need loader_path
This commit is contained in:
Allen Byrne 2025-02-14 16:07:04 -06:00 committed by GitHub
parent 2f4f6902cd
commit d4200dc689
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 42 additions and 1 deletions

View File

@ -38,7 +38,9 @@
"ZLIB_USE_LOCALCONTENT": "OFF",
"LIBAEC_USE_LOCALCONTENT": "OFF",
"HDF5_USE_ZLIB_STATIC": "ON",
"HDF5_USE_LIBAEC_STATIC": "ON"
"HDF5_USE_LIBAEC_STATIC": "ON",
"HDF5_ENABLE_SZIP_SUPPORT": "ON",
"HDF5_ENABLE_ZLIB_SUPPORT": "ON"
}
},
{

View File

@ -35,6 +35,29 @@ macro (H5_SET_LIB_OPTIONS libtarget libname libtype libpackage)
endif ()
endif ()
HDF_SET_LIB_OPTIONS (${libtarget} ${LIB_OUT_NAME} ${libtype})
#-- Apple Specific install_name for libraries
if (APPLE)
option (HDF5_BUILD_WITH_INSTALL_NAME "Build with library install_name set to the installation path" OFF)
if (HDF5_BUILD_WITH_INSTALL_NAME)
set_target_properties (${libtarget} PROPERTIES
INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/lib"
BUILD_WITH_INSTALL_RPATH ${HDF5_BUILD_WITH_INSTALL_NAME}
)
endif ()
if (HDF5_BUILD_FRAMEWORKS)
if (${libtype} MATCHES "SHARED")
# adapt target to build frameworks instead of dylibs
set_target_properties(${libtarget} PROPERTIES
XCODE_ATTRIBUTE_INSTALL_PATH "@rpath"
FRAMEWORK TRUE
FRAMEWORK_VERSION ${HDF5_PACKAGE_VERSION_MAJOR}
MACOSX_FRAMEWORK_IDENTIFIER org.hdfgroup.${libtarget}
MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${HDF5_PACKAGE_VERSION_MAJOR}
MACOSX_FRAMEWORK_BUNDLE_VERSION ${HDF5_PACKAGE_VERSION_MAJOR})
endif ()
endif ()
endif ()
endmacro ()
# Initialize the list of VFDs to be used for testing and create a test folder for each VFD

View File

@ -458,6 +458,16 @@ macro (HDF_DIR_PATHS package_prefix)
endif ()
message(STATUS "Final: ${${package_prefix}_INSTALL_DOC_DIR}")
# Append the needed INSTALL_RPATH for HDF Standard binary packages
if (APPLE)
list(APPEND CMAKE_INSTALL_RPATH
"@loader_path/../${${package_prefix}_INSTALL_LIB_DIR}"
"@loader_path/"
)
else ()
list(APPEND CMAKE_INSTALL_RPATH "\$ORIGIN/../${${package_prefix}_INSTALL_LIB_DIR}:\$ORIGIN/")
endif ()
if (DEFINED ADDITIONAL_CMAKE_PREFIX_PATH AND EXISTS "${ADDITIONAL_CMAKE_PREFIX_PATH}")
set (CMAKE_PREFIX_PATH ${ADDITIONAL_CMAKE_PREFIX_PATH} ${CMAKE_PREFIX_PATH})
endif ()

View File

@ -572,6 +572,12 @@ Bug Fixes since HDF5-2.0.0 release
Configuration
-------------
- The relative rpaths ($ORIGIN / @loader_path) are appended to the CMAKE_INSTALL_RPATH
The RPATH settings were removed by a pull-request #5271, but the settings are needed
under certain conditions. These settings have been restored by appending the necessary paths
and will not override/overwrite any existing settings.
- When using a system installed zlib library, the shared library is expected to
be found in the system library path.