-
-
Notifications
You must be signed in to change notification settings - Fork 281
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix the rpath with option - plugins fail without #5298
Changes from 4 commits
618fe55
28e052e
998eed6
4614bbb
3262728
65363db
df9f6ba
7472daa
0f0dde7
36aeb68
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Definition: BUILD_WITH_INSTALL_RPATH is a boolean specifying whether to link the target in the build tree with the INSTALL_RPATH. This takes precedence over SKIP_BUILD_RPATH and avoids the need for relinking before installation. This property is initialized by the value of the CMAKE_BUILD_WITH_INSTALL_RPATH variable if it is set when a target is created. If policy CMP0068 is not NEW, this property also controls use of INSTALL_NAME_DIR in the build tree on macOS. Either way, the BUILD_WITH_INSTALL_NAME_DIR target property takes precedence. Eliminating this option then just forces the change onto the user? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess the idea of adding these lines was to use If you don't set anything related to build rpaths, and you need to run a just-built executable as part of the build (before install), cmake ensures that these executables can find their libraries. If you meddle with it, then maybe not. I think the only case where you may benefit from setting build rpaths yourself is when you run just-built executables during the build that dlopen(...) just-built libraries that cmake is not aware of as part of target_link_libraries. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Like the plugins. I'm not aware of it's use by us in our CI. However, I also don't develop with macs either. |
||
) | ||
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 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -458,6 +458,18 @@ 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 | ||
"@executable_path/../${${package_prefix}_INSTALL_LIB_DIR}" | ||
"@executable_path/" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I ran across this statement, which seems to just make things more confusing! Even though we only test on the latest two versions of MAC, forcing a single setting could cause someone problems. However, 10.5 is pretty old and maaybe it should just be @rpath? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, I don't think the statement is entirely correct, in the sense that the one does not replace the other 🤔. If you have libhdf5.dylib, the cmake "trick" is to set its install name to Then an executable or library that links against That way, after substitution: The main difference between linux and macOS is that for rpaths to "work" you need to opt-in by marking the needed library as There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So the suggestion then is to only use "@loader_path" ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that + requiring cmake 3.0 should give equivalent behavior as on linux. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Okay - will do. |
||
"@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 () | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not immediately related to the issue, is it? The default install name as of CMake 3.0 is
@rpath/lib<name>.dylib
(before it waslib<name>.dylib
). When users link against the library, it copies the install name@rpath/lib<name>.dylib
as a load command, so rpaths set by the user in the dependent executable/library are respected when searching for libhdf5.dylib at runtime. Then the situation is exactly the same as on Linux, where users also have to set an rpath. If you set it to an absolute path, then rpaths no longer work, and the library is always opened directly by absolute path (not relocatable). So, bit unclear why this is added now, and why the apple situation should be different from linux.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was added as it was previously removed - can be removed if some apple developer knows this is not needed.