diff options
author | David Aguilar <davvid@gmail.com> | 2018-12-21 00:41:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-01-16 14:59:46 (GMT) |
commit | a5e948a36f5d1c1cf6a0ea34b04bbc4b6058e7d9 (patch) | |
tree | bc00d06b51f88ef5776b106f6be786319e18bc68 /Source/cmFindPackageCommand.cxx | |
parent | c59eae7ebc5423c2b06befd762f8639b0f23b7a0 (diff) | |
download | CMake-a5e948a36f5d1c1cf6a0ea34b04bbc4b6058e7d9.zip CMake-a5e948a36f5d1c1cf6a0ea34b04bbc4b6058e7d9.tar.gz CMake-a5e948a36f5d1c1cf6a0ea34b04bbc4b6058e7d9.tar.bz2 |
find_package: optionally resolve symlinks when discovering packages
Teach find_package() to resolve symlinks when constructing
relocatable prefix paths from discovered cmake config files.
The `CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS` variable enables
this behavior when set to `TRUE`.
Fixes: #18704
Diffstat (limited to 'Source/cmFindPackageCommand.cxx')
-rw-r--r-- | Source/cmFindPackageCommand.cxx | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index 8dc7ca2..2567b7a 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -95,6 +95,7 @@ cmFindPackageCommand::cmFindPackageCommand() this->UseLib32Paths = false; this->UseLib64Paths = false; this->UseLibx32Paths = false; + this->UseRealPath = false; this->PolicyScope = true; this->VersionMajor = 0; this->VersionMinor = 0; @@ -195,6 +196,11 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args, this->NoSystemRegistry = true; } + // Check whether we should resolve symlinks when finding packages + if (this->Makefile->IsOn("CMAKE_FIND_PACKAGE_RESOLVE_SYMLINKS")) { + this->UseRealPath = true; + } + // Check if Sorting should be enabled if (const char* so = this->Makefile->GetDefinition("CMAKE_FIND_PACKAGE_SORT_ORDER")) { @@ -1502,6 +1508,10 @@ bool cmFindPackageCommand::FindConfigFile(std::string const& dir, fprintf(stderr, "Checking file [%s]\n", file.c_str()); } if (cmSystemTools::FileExists(file, true) && this->CheckVersion(file)) { + // Allow resolving symlinks when the config file is found through a link + if (this->UseRealPath) { + file = cmSystemTools::GetRealPath(file); + } return true; } } |