CMake: set BUILD_WITH_INSTALL_NAME_DIR for macOS#14660
Open
markmentovai wants to merge 1 commit into
Open
Conversation
CMake can either build shared libraries with a temporary install_name at build time, resetting it to the final name at install time (BUILD_WITH_INSTALL_NAME_DIR=NO, the default), or it can build them with the final name at build time (BUILD_WITH_INSTALL_NAME_DIR=YES). GDAL plugins link against libgdal as part of the build process, and if BUILD_WITH_INSTALL_NAME_DIR=NO, these plugins may be linked using an incorrect path to libgdal, taken from libgdal’s install_name. Those paths are not rewritten at install time, which can make it difficult to properly use GDAL plugins built in this way. For example, with GDAL built with a CMAKE_INSTALL_NAME_DIR set (as a downstream build may do), and PDF built as a plugin, `gdal info` on a PDF may fail with an error such as: ``` ERROR 1: dlopen(…/lib/gdalplugins/gdal_PDF.dylib, 0x0001): Library not loaded: @rpath/libgdal.39.dylib Referenced from: <…> …/lib/gdalplugins/gdal_PDF.dylib Reason: no LC_RPATH's found ``` Setting BUILD_WITH_INSTALL_NAME_DIR=YES overcomes this problem. This change should be noncontroversial, as the default GDAL build, without a CMAKE_INSTALL_NAME_DIR set, will use @rpath as the install_name_dir in both the build and installed trees, regardless of the setting of BUILD_WITH_INSTALL_NAME_DIR.
Member
|
What is the effect of this change for GDAL developers building with plugins, but not installing GDAL, and wanting to use the non-installed build ? |
Author
If they are not currently setting In addition, if these developers are setting |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
CMake can either build shared libraries with a temporary install_name at build time, resetting it to the final name at install time (
BUILD_WITH_INSTALL_NAME_DIR=NO, the default), or it can build them with the final name at build time (BUILD_WITH_INSTALL_NAME_DIR=YES).GDAL plugins link against libgdal as part of the build process, and if
BUILD_WITH_INSTALL_NAME_DIR=NO, these plugins may be linked using an incorrect path to libgdal, taken from libgdal’s install_name. Those paths are not rewritten at install time, which can make it difficult to properly use GDAL plugins built in this way. For example, with GDAL built with aCMAKE_INSTALL_NAME_DIRset (as a downstream build may do), and PDF built as a plugin,gdal infoon a PDF may fail with an error such as:Setting
BUILD_WITH_INSTALL_NAME_DIR=YESovercomes this problem. This change should be noncontroversial, as the default GDAL build, without aCMAKE_INSTALL_NAME_DIRset, will use @rpath as the install_name_dir in both the build and installed trees, regardless of the setting ofBUILD_WITH_INSTALL_NAME_DIR.What does this PR do?
What are related issues/pull requests?
AI tool usage
Tasklist
Environment
Provide environment details, if relevant: