diff options
author | Brad King <brad.king@kitware.com> | 2018-03-15 17:22:07 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-03-16 13:19:28 (GMT) |
commit | eb35d8884b4cf9f4f96482b1bf6017511fdcdda3 (patch) | |
tree | 2634d94df58551aa9b7c46586d0102e5176033a7 /Source/cmFindBase.cxx | |
parent | 018946aaafc9ada6852d55cb8034faf0f4c1afbc (diff) | |
download | CMake-eb35d8884b4cf9f4f96482b1bf6017511fdcdda3.zip CMake-eb35d8884b4cf9f4f96482b1bf6017511fdcdda3.tar.gz CMake-eb35d8884b4cf9f4f96482b1bf6017511fdcdda3.tar.bz2 |
find_package: Use PackageName_ROOT variables as search prefixes
This feature was originally added by commit v3.9.0-rc1~71^2~2 (find_*:
Add a new PackageRoot search path group, 2017-05-03) and documented by
commit v3.9.0-rc1~71^2 (find_*: Add docs for PackageRoot search path
group, 2017-05-03). However, we had to disable the feature and remove
the documentation in commit v3.9.1~2^2 (find_*: Disable the PACKAGE_ROOT
search path group for CMake 3.9, 2017-08-08) due to breaking projects
that used `PackageName_ROOT` variables themselves.
Add policy `CMP0074` to restore the `PackageName_ROOT` variable behavior
in a compatible way. Also revise the stack of root paths to store the
paths themselves rather than the package names. This way the policy can
be considered at the `find_package` call site instead of individual
`find_` calls inside a find module.
Co-Author: Chuck Atkins <chuck.atkins@kitware.com>
Issue: #17144
Diffstat (limited to 'Source/cmFindBase.cxx')
-rw-r--r-- | Source/cmFindBase.cxx | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx index 7069386..865595b 100644 --- a/Source/cmFindBase.cxx +++ b/Source/cmFindBase.cxx @@ -67,8 +67,6 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn) } this->AlreadyInCache = false; - this->SelectDefaultNoPackageRootPath(); - // Find the current root path mode. this->SelectDefaultRootPathMode(); @@ -206,16 +204,12 @@ void cmFindBase::FillPackageRootPath() { cmSearchPath& paths = this->LabeledPaths[PathLabel::PackageRoot]; - // Add package specific search prefixes - // NOTE: This should be using const_reverse_iterator but HP aCC and - // Oracle sunCC both currently have standard library issues - // with the reverse iterator APIs. - for (std::deque<std::string>::reverse_iterator pkg = - this->Makefile->FindPackageModuleStack.rbegin(); - pkg != this->Makefile->FindPackageModuleStack.rend(); ++pkg) { - std::string varName = *pkg + "_ROOT"; - paths.AddCMakePrefixPath(varName); - paths.AddEnvPrefixPath(varName); + // Add the PACKAGE_ROOT_PATH from each enclosing find_package call. + for (std::deque<std::vector<std::string>>::const_reverse_iterator pkgPaths = + this->Makefile->FindPackageRootPathStack.rbegin(); + pkgPaths != this->Makefile->FindPackageRootPathStack.rend(); + ++pkgPaths) { + paths.AddPrefixPaths(*pkgPaths); } paths.AddSuffixes(this->SearchPathSuffixes); |