From 618fe555b64efd7401e2927dedf7433a7b7ca64b Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 6 Feb 2025 16:10:33 -0600 Subject: [PATCH] Fix the rpath with option - plugins fail without --- CMakePresets.json | 5 ++++- config/cmake/HDF5Macros.cmake | 23 +++++++++++++++++++++++ config/cmake/HDFMacros.cmake | 15 +++++++++++++++ config/cmake/cacheinit.cmake | 2 ++ release_docs/INSTALL_CMake.txt | 2 ++ release_docs/RELEASE.txt | 14 ++++++++++++++ 6 files changed, 60 insertions(+), 1 deletion(-) diff --git a/CMakePresets.json b/CMakePresets.json index 1819747b8cd..24680f16ba2 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" } }, { @@ -120,6 +122,7 @@ "HDF5_BUILD_GENERATORS": "ON", "HDF5_ENABLE_ALL_WARNINGS": "ON", "HDF5_MINGW_STATIC_GCC_LIBS": "ON", + "HDF5_SET_DEFAULT_RPATH": "ON", "HDF_TEST_EXPRESS": "2" } }, 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..5e56947725e 100644 --- a/config/cmake/HDFMacros.cmake +++ b/config/cmake/HDFMacros.cmake @@ -458,6 +458,21 @@ macro (HDF_DIR_PATHS package_prefix) endif () message(STATUS "Final: ${${package_prefix}_INSTALL_DOC_DIR}") + # Define the needed INSTALL_RPATH for HDF Standard binary packages + option (HDF5_SET_DEFAULT_RPATH "Set the default RPATH for the common installation" OFF) + if (HDF5_SET_DEFAULT_RPATH) + if (APPLE) + set (CMAKE_INSTALL_RPATH + "@executable_path/../${${package_prefix}_INSTALL_LIB_DIR}" + "@executable_path/" + "@loader_path/../${${package_prefix}_INSTALL_LIB_DIR}" + "@loader_path/" + ) + else () + set (CMAKE_INSTALL_RPATH "\$ORIGIN/../${${package_prefix}_INSTALL_LIB_DIR}:\$ORIGIN/") + endif () + 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/config/cmake/cacheinit.cmake b/config/cmake/cacheinit.cmake index 157521e9e55..ec4319a7c3f 100644 --- a/config/cmake/cacheinit.cmake +++ b/config/cmake/cacheinit.cmake @@ -43,6 +43,8 @@ set (HDF5_MINGW_STATIC_GCC_LIBS ON CACHE BOOL "Statically link libgcc/libstdc++" set (HDF5_ALLOW_EXTERNAL_SUPPORT "TGZ" CACHE STRING "Allow External Library Building (NO GIT TGZ)" FORCE) set_property (CACHE HDF5_ALLOW_EXTERNAL_SUPPORT PROPERTY STRINGS NO GIT TGZ) +set (HDF5_SET_DEFAULT_RPATH ON "Set the default RPATH for the common installation" FORCE) + ######################## # compression options ######################## diff --git a/release_docs/INSTALL_CMake.txt b/release_docs/INSTALL_CMake.txt index e902eb416a1..1afae1aa76a 100644 --- a/release_docs/INSTALL_CMake.txt +++ b/release_docs/INSTALL_CMake.txt @@ -538,6 +538,7 @@ These five steps are described in detail below. set (HDF5_BUILD_JAVA ON CACHE BOOL "Build JAVA support" FORCE) set (HDF5_ENABLE_ALL_WARNINGS ON CACHE BOOL "Enable all warnings" FORCE) set (HDF5_ALLOW_EXTERNAL_SUPPORT "TGZ" CACHE STRING "Allow External Library Building (NO GIT TGZ)" FORCE) + set (HDF5_SET_DEFAULT_RPATH ON "Set the default RPATH for the common installation" FORCE) ######################## # compression options ######################## @@ -755,6 +756,7 @@ BUILD_STATIC_EXECS "Build Static Executables" OFF BUILD_TESTING "Build HDF5 Unit Testing" ON if (WINDOWS) HDF5_DISABLE_PDB_FILES "Do not install PDB files" OFF +HDF5_SET_DEFAULT_RPATH "Set the default RPATH for the common installation" OFF ---------------- HDF5 Build Options ---------------------------------------- HDF5_BUILD_CPP_LIB "Build HDF5 C++ Library" OFF diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index a7d67f698c5..be3d01d8509 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -565,6 +565,20 @@ Bug Fixes since HDF5-2.0.0 release Configuration ------------- + - The RPATH settings were restored under an HDF5 option + + The RPATH settings were removed by a pull-request #5271, but the settings are needed + under certain conditions. The settings have been restored under the HDF5_ENABLE_RPATH option. + The option is OFF by default. Typical builds using either the cacheinit.cmake file or presets + will enable the RPATH settings. + + - When using a system installed zlib library, the shared library is expected to + be found in the system library path. + + Setting the HDF5_MODULE_MODE_ZLIB option to OFF, the system installed zlib, + or an alternate installed zlib library, is expected to have a correct + zlib-config.cmake file. + - Use pre-installed libaec compression library The CMake logic for finding the libaec compression library has been