summaryrefslogtreecommitdiffstats
path: root/Source/cmFindPackageCommand.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2006-10-26 15:39:56 (GMT)
committerBrad King <brad.king@kitware.com>2006-10-26 15:39:56 (GMT)
commitd9f1d4d71a66cff7a198ccddf85d90f928f59d52 (patch)
treeee586e645b75839cb761b70b4772ce26be34a5ce /Source/cmFindPackageCommand.cxx
parent5418998e46948d290dfb007c7ee65e54ae5635c7 (diff)
downloadCMake-d9f1d4d71a66cff7a198ccddf85d90f928f59d52.zip
CMake-d9f1d4d71a66cff7a198ccddf85d90f928f59d52.tar.gz
CMake-d9f1d4d71a66cff7a198ccddf85d90f928f59d52.tar.bz2
ENH: Added NO_MODULE and COMPONENTS options to improve flexibility of the command. Re-implemented argument parsing to be simpler and more robust.
Diffstat (limited to 'Source/cmFindPackageCommand.cxx')
-rw-r--r--Source/cmFindPackageCommand.cxx128
1 files changed, 64 insertions, 64 deletions
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 62aaeb2..b4118d9 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -54,80 +54,80 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
return false;
}
+ // Record options.
this->Name = args[0];
-
- // Build a list of required components.
- std::string components;
- const char* components_sep = "";
bool quiet = false;
bool required = false;
- if(args.size() > 1)
+ bool no_module = false;
+ std::string components;
+ const char* components_sep = "";
+
+ // Parse the arguments.
+ bool doing_components = false;
+ cmsys::RegularExpression version("^[0-9.]+$");
+ bool haveVersion = false;
+ for(unsigned int i=1; i < args.size(); ++i)
{
- cmsys::RegularExpression version("^[0-9.]+$");
- bool haveVersion = false;
- for(unsigned int i=1; i < args.size(); ++i)
+ if(args[i] == "QUIET")
{
- if(!haveVersion && version.find(args[i].c_str()))
- {
- haveVersion = true;
- }
- else if(args[i] == "QUIET")
- {
- quiet = true;
- }
- else if(args[i] == "REQUIRED")
- {
- // The package is required.
- required = true;
-
- // Look for a list of required components.
- while(++i < args.size())
- {
- // Stop looking when a known keyword argument is
- // encountered.
- if((args[i] == "QUIET") ||
- (args[i] == "REQUIRED"))
- {
- --i;
- break;
- }
- else
- {
- // Set a variable telling the find script this component
- // is required.
- std::string req_var = Name + "_FIND_REQUIRED_" + args[i];
- this->Makefile->AddDefinition(req_var.c_str(), "1");
-
- // Append to the list of required components.
- components += components_sep;
- components += args[i];
- components_sep = ";";
- }
- }
- }
- else
- {
- cmOStringStream e;
- e << "called with invalid argument \"" << args[i].c_str() << "\"";
- this->SetError(e.str().c_str());
- return false;
- }
+ quiet = true;
+ doing_components = false;
+ }
+ else if(args[i] == "NO_MODULE")
+ {
+ no_module = true;
+ doing_components = false;
+ }
+ else if(args[i] == "REQUIRED")
+ {
+ required = true;
+ doing_components = true;
+ }
+ else if(args[i] == "COMPONENTS")
+ {
+ doing_components = true;
+ }
+ else if(doing_components)
+ {
+ // Set a variable telling the find script this component
+ // is required.
+ std::string req_var = Name + "_FIND_REQUIRED_" + args[i];
+ this->Makefile->AddDefinition(req_var.c_str(), "1");
+
+ // Append to the list of required components.
+ components += components_sep;
+ components += args[i];
+ components_sep = ";";
+ }
+ else if(!haveVersion && version.find(args[i].c_str()))
+ {
+ haveVersion = true;
+ }
+ else
+ {
+ cmOStringStream e;
+ e << "called with invalid argument \"" << args[i].c_str() << "\"";
+ this->SetError(e.str().c_str());
+ return false;
}
-
- // Store the list of components.
- std::string components_var = Name + "_FIND_COMPONENTS";
- this->Makefile->AddDefinition(components_var.c_str(), components.c_str());
}
+ // Store the list of components.
+ std::string components_var = Name + "_FIND_COMPONENTS";
+ this->Makefile->AddDefinition(components_var.c_str(), components.c_str());
+
// See if there is a Find<name>.cmake module.
- bool foundModule = false;
- if(!this->FindModule(foundModule, quiet, required))
+ if(!no_module)
{
- return false;
- }
- if(foundModule)
- {
- return true;
+ bool foundModule = false;
+ if(!this->FindModule(foundModule, quiet, required))
+ {
+ return false;
+ }
+ if(foundModule)
+ {
+ return true;
+ }
}
// No find module. Assume the project has a CMake config file. Use