summaryrefslogtreecommitdiffstats
path: root/Source/cmFindBase.cxx
diff options
context:
space:
mode:
authorChuck Atkins <chuck.atkins@kitware.com>2017-05-03 17:56:03 (GMT)
committerChuck Atkins <chuck.atkins@kitware.com>2017-05-16 19:19:40 (GMT)
commitef3d360a3de4a290c92c34827a3b68a8ce160840 (patch)
treef999d696f387ba6b0d71ebf9b013ca0723bb2989 /Source/cmFindBase.cxx
parent836cb52e9aec83f88841cb5b45abb1d32bb02214 (diff)
downloadCMake-ef3d360a3de4a290c92c34827a3b68a8ce160840.zip
CMake-ef3d360a3de4a290c92c34827a3b68a8ce160840.tar.gz
CMake-ef3d360a3de4a290c92c34827a3b68a8ce160840.tar.bz2
find_*: Add a new PackageRoot search path group
The new PackageRoot search path group allows the PackageName_ROOT cmake and environment variables to be used as search prefixes for all find_* commands called from within a find module
Diffstat (limited to 'Source/cmFindBase.cxx')
-rw-r--r--Source/cmFindBase.cxx22
1 files changed, 22 insertions, 0 deletions
diff --git a/Source/cmFindBase.cxx b/Source/cmFindBase.cxx
index 068dcfc..581c401 100644
--- a/Source/cmFindBase.cxx
+++ b/Source/cmFindBase.cxx
@@ -3,7 +3,9 @@
#include "cmFindBase.h"
#include "cmConfigure.h"
+#include <deque>
#include <iostream>
+#include <iterator>
#include <map>
#include <stddef.h>
@@ -158,6 +160,9 @@ bool cmFindBase::ParseArguments(std::vector<std::string> const& argsIn)
void cmFindBase::ExpandPaths()
{
if (!this->NoDefaultPath) {
+ if (!this->NoPackageRootPath) {
+ this->FillPackageRootPath();
+ }
if (!this->NoCMakePath) {
this->FillCMakeVariablePath();
}
@@ -196,6 +201,23 @@ void cmFindBase::FillCMakeEnvironmentPath()
paths.AddSuffixes(this->SearchPathSuffixes);
}
+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);
+ }
+}
+
void cmFindBase::FillCMakeVariablePath()
{
cmSearchPath& paths = this->LabeledPaths[PathLabel::CMake];