summaryrefslogtreecommitdiffstats
path: root/Source/cmFindPackageCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2012-02-28 13:56:50 (GMT)
committerBrad King <brad.king@kitware.com>2012-02-28 14:58:31 (GMT)
commit31ead5f695182dbb96196f9795b6437e013c6567 (patch)
tree13b6f49ac874ec555796ff483a661cd24f2bf160 /Source/cmFindPackageCommand.cxx
parent6d8308314adbc3ff504b836b3989db9939de1e0b (diff)
downloadCMake-31ead5f695182dbb96196f9795b6437e013c6567.zip
CMake-31ead5f695182dbb96196f9795b6437e013c6567.tar.gz
CMake-31ead5f695182dbb96196f9795b6437e013c6567.tar.bz2
find_package: Reject mixed use of MODULE- and CONFIG-only options
Many options imply exclusive Config mode. The new MODULE option implies exclusive Module mode. Do not allow mixed combinations.
Diffstat (limited to 'Source/cmFindPackageCommand.cxx')
-rw-r--r--Source/cmFindPackageCommand.cxx80
1 files changed, 37 insertions, 43 deletions
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 86eb2c8..437f47a 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -415,7 +415,8 @@ bool cmFindPackageCommand
Doing doing = DoingNone;
cmsys::RegularExpression version("^[0-9.]+$");
bool haveVersion = false;
- std::string haveModeString = "";
+ std::set<unsigned int> configArgs;
+ std::set<unsigned int> moduleArgs;
for(unsigned int i=1; i < args.size(); ++i)
{
if(args[i] == "QUIET")
@@ -431,48 +432,18 @@ bool cmFindPackageCommand
}
else if(args[i] == "MODULE")
{
- if(!haveModeString.empty())
- {
- cmOStringStream e;
- e << "given " << args[i] << ", but mode is already set to "
- << haveModeString << ".";
- this->SetError(e.str().c_str());
- return false;
- }
-
- this->UseConfigFiles = false;
+ moduleArgs.insert(i);
doing = DoingNone;
- haveModeString = args[i];
}
else if(args[i] == "CONFIG")
{
- if(!haveModeString.empty())
- {
- cmOStringStream e;
- e << "given " << args[i] << ", but mode is already set to "
- << haveModeString << ".";
- this->SetError(e.str().c_str());
- return false;
- }
-
- this->UseFindModules = false;
+ configArgs.insert(i);
doing = DoingNone;
- haveModeString = args[i];
}
else if(args[i] == "NO_MODULE")
{
- if(!haveModeString.empty())
- {
- cmOStringStream e;
- e << "given " << args[i] << ", but mode is already set to "
- << haveModeString << ".";
- this->SetError(e.str().c_str());
- return false;
- }
-
- this->UseFindModules = false;
+ configArgs.insert(i);
doing = DoingNone;
- haveModeString = args[i];
}
else if(args[i] == "REQUIRED")
{
@@ -486,31 +457,31 @@ bool cmFindPackageCommand
}
else if(args[i] == "NAMES")
{
- this->UseFindModules = false;
+ configArgs.insert(i);
this->Compatibility_1_6 = false;
doing = DoingNames;
}
else if(args[i] == "PATHS")
{
- this->UseFindModules = false;
+ configArgs.insert(i);
this->Compatibility_1_6 = false;
doing = DoingPaths;
}
else if(args[i] == "HINTS")
{
- this->UseFindModules = false;
+ configArgs.insert(i);
this->Compatibility_1_6 = false;
doing = DoingHints;
}
else if(args[i] == "PATH_SUFFIXES")
{
- this->UseFindModules = false;
+ configArgs.insert(i);
this->Compatibility_1_6 = false;
doing = DoingPathSuffixes;
}
else if(args[i] == "CONFIGS")
{
- this->UseFindModules = false;
+ configArgs.insert(i);
this->Compatibility_1_6 = false;
doing = DoingConfigs;
}
@@ -523,27 +494,27 @@ bool cmFindPackageCommand
else if(args[i] == "NO_CMAKE_PACKAGE_REGISTRY")
{
this->NoUserRegistry = true;
- this->UseFindModules = false;
+ configArgs.insert(i);
this->Compatibility_1_6 = false;
doing = DoingNone;
}
else if(args[i] == "NO_CMAKE_SYSTEM_PACKAGE_REGISTRY")
{
this->NoSystemRegistry = true;
- this->UseFindModules = false;
+ configArgs.insert(i);
this->Compatibility_1_6 = false;
doing = DoingNone;
}
else if(args[i] == "NO_CMAKE_BUILDS_PATH")
{
this->NoBuilds = true;
- this->UseFindModules = false;
+ configArgs.insert(i);
this->Compatibility_1_6 = false;
doing = DoingNone;
}
else if(this->CheckCommonArgument(args[i]))
{
- this->UseFindModules = false;
+ configArgs.insert(i);
this->Compatibility_1_6 = false;
doing = DoingNone;
}
@@ -603,6 +574,29 @@ bool cmFindPackageCommand
}
}
+ // Maybe choose one mode exclusively.
+ this->UseFindModules = configArgs.empty();
+ this->UseConfigFiles = moduleArgs.empty();
+ if(!this->UseFindModules && !this->UseConfigFiles)
+ {
+ cmOStringStream e;
+ e << "given options exclusive to Module mode:\n";
+ for(std::set<unsigned int>::const_iterator si = moduleArgs.begin();
+ si != moduleArgs.end(); ++si)
+ {
+ e << " " << args[*si] << "\n";
+ }
+ e << "and options exclusive to Config mode:\n";
+ for(std::set<unsigned int>::const_iterator si = configArgs.begin();
+ si != configArgs.end(); ++si)
+ {
+ e << " " << args[*si] << "\n";
+ }
+ e << "The options are incompatible.";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+
// Ignore EXACT with no version.
if(this->Version.empty() && this->VersionExact)
{