[cmake] Make pkg-config files relocatable - #6471
Open
tandede wants to merge 1 commit into
Open
Conversation
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.
Problem
PCL's pkg-config templates expand
CMAKE_INSTALL_PREFIXwhile the project is being configured. The resulting.pcfiles therefore retain the path used on the build machine.This is especially visible in the Windows All-In-One installer: users may select a different installation directory, but the installed pkg-config files continue to reference the packager's original prefix. Moving an installed PCL tree has the same problem.
Approach
For a relative
PKGCFG_INSTALL_DIR, derive the package prefix from${pcfiledir}and the number of path components between the pkg-config directory and the installation root. This keeps the generated file independent of the build-time installation prefix.Absolute pkg-config destinations retain the previous behavior because they are not necessarily located inside the installation tree.
The computed prefix is shared by both the regular and header-only pkg-config templates.
Changes
PKGCONFIG_PREFIXinPCL_MAKE_PKGCONFIG..pctemplates.pcl_*.pcfile against the expected prefix for the configured installation layout.Results
With the default
lib/pkgconfiglayout, generated files now contain:A deeper relative layout such as
lib/custom/pkgconfigproduces:Absolute pkg-config installation directories continue to use the configured
CMAKE_INSTALL_PREFIX.After installing into one directory and moving the complete installation tree,
pkg-config --variable=prefix pcl_commonand the reported include flags both resolve against the new location.Validation
pcl_commontarget successfully.git diff --check.The complete
global_testsconfiguration was not available locally because the environment does not contain the GoogleTest source package required byFindGTestSource. The new regression is a standalone CMake script and was executed directly for all three layouts.Fixes #4240.