summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Source/cmFindPackageCommand.cxx33
-rw-r--r--Source/cmFindPackageCommand.h10
2 files changed, 36 insertions, 7 deletions
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index 5dd2eb3..8881929 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -15,6 +15,7 @@
=========================================================================*/
#include "cmFindPackageCommand.h"
+#include <cmsys/RegularExpression.hxx>
//----------------------------------------------------------------------------
bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
@@ -26,7 +27,31 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
}
this->Name = args[0];
- this->UpperName = cmSystemTools::UpperCase(this->Name);
+
+ bool quiet = false;
+ if(args.size() > 1)
+ {
+ cmsys::RegularExpression version("^[0-9.]+$");
+ bool haveVersion = false;
+ for(unsigned int i=1; i < args.size(); ++i)
+ {
+ if(!haveVersion && version.find(args[i].c_str()))
+ {
+ haveVersion = true;
+ }
+ else if(args[i] == "QUIET")
+ {
+ quiet = true;
+ }
+ else
+ {
+ cmOStringStream e;
+ e << "called with invalid argument \"" << args[i].c_str() << "\"";
+ this->SetError(e.str().c_str());
+ return false;
+ }
+ }
+ }
// See if there is a Find<name>.cmake module.
bool foundModule = false;
@@ -40,7 +65,7 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
}
// No find module. Assume the project has a CMake config file. Use
// a <NAME>_DIR cache variable to locate it.
- this->Variable = this->UpperName;
+ this->Variable = this->Name;
this->Variable += "_DIR";
this->Config = this->Name;
this->Config += "Config.cmake";
@@ -82,7 +107,7 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
result = true;
}
}
- else
+ else if(!quiet)
{
cmOStringStream e;
e << this->Variable << " is not set. It must be set to the directory "
@@ -92,7 +117,7 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
result = true;
}
- std::string foundVar = this->UpperName;
+ std::string foundVar = this->Name;
foundVar += "_FOUND";
m_Makefile->AddDefinition(foundVar.c_str(), found? "1":"0");
return result;
diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h
index 73cb4a3..f559ee9 100644
--- a/Source/cmFindPackageCommand.h
+++ b/Source/cmFindPackageCommand.h
@@ -64,7 +64,7 @@ public:
virtual const char* GetFullDocumentation()
{
return
- " FIND_PACKAGE(<name> [major.minor])\n"
+ " FIND_PACKAGE(<name> [major.minor] [QUIET])\n"
"Finds and loads settings from an external project. <name>_FOUND will "
"be set to indicate whether the package was found. Settings that "
"can be used when <name>_FOUND is true are package-specific. The "
@@ -76,7 +76,12 @@ public:
"project built by CMake that has a \"<name>Config.cmake\" file. "
"A cache entry called <name>_DIR is created and is expected to be set "
"to the directory containing this file. If the file is found, it is "
- "read and processed by CMake to load the settings of the package.";
+ "read and processed by CMake to load the settings of the package. If "
+ "<name>_DIR has not been set during a configure step, the command "
+ "will generate an error describing the problem unless the QUIET "
+ "argument is specified. If <name>_DIR has been set to a directory "
+ "not containing a \"<name>Config.cmake\" file, an error is always "
+ "generated.";
}
cmTypeMacro(cmFindPackageCommand, cmCommand);
@@ -87,7 +92,6 @@ private:
bool ReadListFile(const char* f);
cmStdString Name;
- cmStdString UpperName;
cmStdString Variable;
cmStdString Config;
std::vector<cmStdString> Builds;