summaryrefslogtreecommitdiffstats
path: root/Source
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
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')
-rw-r--r--Source/cmFindBase.cxx22
-rw-r--r--Source/cmFindBase.h1
-rw-r--r--Source/cmFindCommon.cxx12
-rw-r--r--Source/cmFindCommon.h2
-rw-r--r--Source/cmFindPackageCommand.cxx7
-rw-r--r--Source/cmMakefile.h5
6 files changed, 47 insertions, 2 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];
diff --git a/Source/cmFindBase.h b/Source/cmFindBase.h
index 81494f1..88b5b6c 100644
--- a/Source/cmFindBase.h
+++ b/Source/cmFindBase.h
@@ -50,6 +50,7 @@ protected:
private:
// Add pieces of the search.
+ void FillPackageRootPath();
void FillCMakeVariablePath();
void FillCMakeEnvironmentPath();
void FillUserHintsPath();
diff --git a/Source/cmFindCommon.cxx b/Source/cmFindCommon.cxx
index df57a1b..e8ae20f 100644
--- a/Source/cmFindCommon.cxx
+++ b/Source/cmFindCommon.cxx
@@ -10,6 +10,8 @@
#include "cmSystemTools.h"
cmFindCommon::PathGroup cmFindCommon::PathGroup::All("ALL");
+cmFindCommon::PathLabel cmFindCommon::PathLabel::PackageRoot(
+ "PacakgeName_ROOT");
cmFindCommon::PathLabel cmFindCommon::PathLabel::CMake("CMAKE");
cmFindCommon::PathLabel cmFindCommon::PathLabel::CMakeEnvironment(
"CMAKE_ENVIRONMENT");
@@ -23,6 +25,7 @@ cmFindCommon::cmFindCommon()
{
this->FindRootPathMode = RootPathModeBoth;
this->NoDefaultPath = false;
+ this->NoPackageRootPath = false;
this->NoCMakePath = false;
this->NoCMakeEnvironmentPath = false;
this->NoSystemEnvironmentPath = false;
@@ -57,6 +60,7 @@ void cmFindCommon::InitializeSearchPathGroups()
// All search paths
labels = &this->PathGroupLabelMap[PathGroup::All];
+ labels->push_back(PathLabel::PackageRoot);
labels->push_back(PathLabel::CMake);
labels->push_back(PathLabel::CMakeEnvironment);
labels->push_back(PathLabel::Hints);
@@ -69,6 +73,8 @@ void cmFindCommon::InitializeSearchPathGroups()
// Create the idividual labeld search paths
this->LabeledPaths.insert(
+ std::make_pair(PathLabel::PackageRoot, cmSearchPath(this)));
+ this->LabeledPaths.insert(
std::make_pair(PathLabel::CMake, cmSearchPath(this)));
this->LabeledPaths.insert(
std::make_pair(PathLabel::CMakeEnvironment, cmSearchPath(this)));
@@ -271,10 +277,12 @@ bool cmFindCommon::CheckCommonArgument(std::string const& arg)
{
if (arg == "NO_DEFAULT_PATH") {
this->NoDefaultPath = true;
- } else if (arg == "NO_CMAKE_ENVIRONMENT_PATH") {
- this->NoCMakeEnvironmentPath = true;
+ } else if (arg == "NO_PACKAGE_ROOT_PATH") {
+ this->NoPackageRootPath = true;
} else if (arg == "NO_CMAKE_PATH") {
this->NoCMakePath = true;
+ } else if (arg == "NO_CMAKE_ENVIRONMENT_PATH") {
+ this->NoCMakeEnvironmentPath = true;
} else if (arg == "NO_SYSTEM_ENVIRONMENT_PATH") {
this->NoSystemEnvironmentPath = true;
} else if (arg == "NO_CMAKE_SYSTEM_PATH") {
diff --git a/Source/cmFindCommon.h b/Source/cmFindCommon.h
index bbb7a38..2eed47b 100644
--- a/Source/cmFindCommon.h
+++ b/Source/cmFindCommon.h
@@ -55,6 +55,7 @@ protected:
: cmPathLabel(label)
{
}
+ static PathLabel PackageRoot;
static PathLabel CMake;
static PathLabel CMakeEnvironment;
static PathLabel Hints;
@@ -105,6 +106,7 @@ protected:
void AddPathSuffix(std::string const& arg);
bool NoDefaultPath;
+ bool NoPackageRootPath;
bool NoCMakePath;
bool NoCMakeEnvironmentPath;
bool NoSystemEnvironmentPath;
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 17fa92c..6f6a3f6 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -10,6 +10,7 @@
#include "cmsys/String.h"
#include <algorithm>
#include <assert.h>
+#include <deque>
#include <functional>
#include <iterator>
#include <sstream>
@@ -585,6 +586,9 @@ void cmFindPackageCommand::SetModuleVariables(const std::string& components)
exact += "_FIND_VERSION_EXACT";
this->AddFindDefinition(exact, this->VersionExact ? "1" : "0");
}
+
+ // Push on to the pacakge stack
+ this->Makefile->FindPackageModuleStack.push_back(this->Name);
}
void cmFindPackageCommand::AddFindDefinition(const std::string& var,
@@ -1059,6 +1063,9 @@ void cmFindPackageCommand::AppendSuccessInformation()
// Restore original state of "_FIND_" variables we set.
this->RestoreFindDefinitions();
+
+ // Pop the package stack
+ this->Makefile->FindPackageModuleStack.pop_back();
}
void cmFindPackageCommand::ComputePrefixes()
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 52a6498..6dc30ce 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -6,6 +6,7 @@
#include "cmConfigure.h"
#include "cmsys/RegularExpression.hxx"
+#include <deque>
#include <map>
#include <set>
#include <stack>
@@ -786,6 +787,10 @@ public:
void RemoveExportBuildFileGeneratorCMP0024(cmExportBuildFileGenerator* gen);
void AddExportBuildFileGenerator(cmExportBuildFileGenerator* gen);
+ // Maintain a stack of pacakge names to determine the depth of find modules
+ // we are currently being called with
+ std::deque<std::string> FindPackageModuleStack;
+
protected:
// add link libraries and directories to the target
void AddGlobalLinkInformation(cmTarget& target);