diff options
author | Brad King <brad.king@kitware.com> | 2003-07-16 18:52:51 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2003-07-16 18:52:51 (GMT) |
commit | 8ca5266645c5fa3d65728508a8eb3c6ebe30c1f6 (patch) | |
tree | 99ee3ea522cfb14be909638c0ae657b294cceaec /Source/cmFindPackageCommand.cxx | |
parent | c2b98959c5e0f18e289ab18ecb70484342fd4548 (diff) | |
download | CMake-8ca5266645c5fa3d65728508a8eb3c6ebe30c1f6.zip CMake-8ca5266645c5fa3d65728508a8eb3c6ebe30c1f6.tar.gz CMake-8ca5266645c5fa3d65728508a8eb3c6ebe30c1f6.tar.bz2 |
ENH: Added QUIET optional argument to block error message when _DIR variable is not set. Also removed upper-casing of package name.
Diffstat (limited to 'Source/cmFindPackageCommand.cxx')
-rw-r--r-- | Source/cmFindPackageCommand.cxx | 33 |
1 files changed, 29 insertions, 4 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; |