From d4200dc689dbd7320fae0998d94eada8168735f2 Mon Sep 17 00:00:00 2001 From: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Date: Fri, 14 Feb 2025 16:07:04 -0600 Subject: [PATCH] Fix the rpath with option - plugins fail without (#5298) * Only need loader_path --- CMakePresets.json | 4 +++- config/cmake/HDF5Macros.cmake | 23 +++++++++++++++++++++++ config/cmake/HDFMacros.cmake | 10 ++++++++++ release_docs/RELEASE.txt | 6 ++++++ 4 files changed, 42 insertions(+), 1 deletion(-) diff --git a/CMakePresets.json b/CMakePresets.json index 93b9cc2bde1..d4210b5c83b 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -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" } }, { diff --git a/config/cmake/HDF5Macros.cmake b/config/cmake/HDF5Macros.cmake index 52603149d9b..e1bb13315f5 100644 --- a/config/cmake/HDF5Macros.cmake +++ b/config/cmake/HDF5Macros.cmake @@ -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 diff --git a/config/cmake/HDFMacros.cmake b/config/cmake/HDFMacros.cmake index f7023e70da9..54d6230f5f8 100644 --- a/config/cmake/HDFMacros.cmake +++ b/config/cmake/HDFMacros.cmake @@ -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 () diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index d05e6a8ceb9..3b929e494d6 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -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.