summaryrefslogtreecommitdiffstats
path: root/Source/cmFindPackageCommand.cxx
diff options
context:
space:
mode:
authorAlexander Neundorf <neundorf@kde.org>2008-09-06 23:10:02 (GMT)
committerAlexander Neundorf <neundorf@kde.org>2008-09-06 23:10:02 (GMT)
commit8903f88b3610b21d09f0bdc66b31ce00a3c6aebf (patch)
treedaaf824fa6b6cdef6d8202f725bdd999141900bc /Source/cmFindPackageCommand.cxx
parent6f8bdd276c12211b0992fe45051d966f21e3b853 (diff)
downloadCMake-8903f88b3610b21d09f0bdc66b31ce00a3c6aebf.zip
CMake-8903f88b3610b21d09f0bdc66b31ce00a3c6aebf.tar.gz
CMake-8903f88b3610b21d09f0bdc66b31ce00a3c6aebf.tar.bz2
ENH: provide the xxx_FIND_QUIETLY, xxx_FIND_REQUIRED and xxx_FIND_VERSION_ variables
also in Config mode, so the xxxConfig.cmake files can e.g. test the QUIETLY parameter and print something or not Alex
Diffstat (limited to 'Source/cmFindPackageCommand.cxx')
-rw-r--r--Source/cmFindPackageCommand.cxx122
1 files changed, 65 insertions, 57 deletions
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index f130ba2..7a0b462 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -411,7 +411,7 @@ bool cmFindPackageCommand
{
// Set a variable telling the find script this component
// is required.
- std::string req_var = Name + "_FIND_REQUIRED_" + args[i];
+ std::string req_var = this->Name + "_FIND_REQUIRED_" + args[i];
this->Makefile->AddDefinition(req_var.c_str(), "1");
// Append to the list of required components.
@@ -480,9 +480,7 @@ bool cmFindPackageCommand
}
}
- // Store the list of components.
- std::string components_var = Name + "_FIND_COMPONENTS";
- this->Makefile->AddDefinition(components_var.c_str(), components.c_str());
+ this->SetModuleVariables(components);
// See if there is a Find<package>.cmake module.
if(!this->NoModule)
@@ -533,68 +531,78 @@ bool cmFindPackageCommand
return result;
}
+
//----------------------------------------------------------------------------
-bool cmFindPackageCommand::FindModule(bool& found)
+bool cmFindPackageCommand::SetModuleVariables(const std::string& components)
{
- std::string module = "Find";
- module += this->Name;
- module += ".cmake";
- std::string mfile = this->Makefile->GetModulesFile(module.c_str());
- if ( mfile.size() )
+ // Store the list of components.
+ std::string components_var = this->Name + "_FIND_COMPONENTS";
+ this->Makefile->AddDefinition(components_var.c_str(), components.c_str());
+
+ if(this->Quiet)
{
- if(this->Quiet)
- {
- // Tell the module that is about to be read that it should find
- // quietly.
- std::string quietly = this->Name;
- quietly += "_FIND_QUIETLY";
- this->Makefile->AddDefinition(quietly.c_str(), "1");
- }
+ // Tell the module that is about to be read that it should find
+ // quietly.
+ std::string quietly = this->Name;
+ quietly += "_FIND_QUIETLY";
+ this->Makefile->AddDefinition(quietly.c_str(), "1");
+ }
- if(this->Required)
- {
- // Tell the module that is about to be read that it should report
- // a fatal error if the package is not found.
- std::string req = this->Name;
- req += "_FIND_REQUIRED";
- this->Makefile->AddDefinition(req.c_str(), "1");
- }
+ if(this->Required)
+ {
+ // Tell the module that is about to be read that it should report
+ // a fatal error if the package is not found.
+ std::string req = this->Name;
+ req += "_FIND_REQUIRED";
+ this->Makefile->AddDefinition(req.c_str(), "1");
+ }
- if(!this->Version.empty())
+ if(!this->Version.empty())
+ {
+ // Tell the module that is about to be read what version of the
+ // package has been requested.
+ std::string ver = this->Name;
+ ver += "_FIND_VERSION";
+ this->Makefile->AddDefinition(ver.c_str(), this->Version.c_str());
+ char buf[64];
+ switch(this->VersionCount)
{
- // Tell the module that is about to be read what version of the
- // package has been requested.
- std::string ver = this->Name;
- ver += "_FIND_VERSION";
- this->Makefile->AddDefinition(ver.c_str(), this->Version.c_str());
- char buf[64];
- switch(this->VersionCount)
+ case 3:
{
- case 3:
- {
- sprintf(buf, "%u", this->VersionPatch);
- this->Makefile->AddDefinition((ver+"_PATCH").c_str(), buf);
- } // no break
- case 2:
- {
- sprintf(buf, "%u", this->VersionMinor);
- this->Makefile->AddDefinition((ver+"_MINOR").c_str(), buf);
- } // no break
- case 1:
- {
- sprintf(buf, "%u", this->VersionMajor);
- this->Makefile->AddDefinition((ver+"_MAJOR").c_str(), buf);
- } // no break
- default: break;
- }
-
- // Tell the module whether an exact version has been requested.
- std::string exact = this->Name;
- exact += "_FIND_VERSION_EXACT";
- this->Makefile->AddDefinition(exact.c_str(),
- this->VersionExact? "1":"0");
+ sprintf(buf, "%u", this->VersionPatch);
+ this->Makefile->AddDefinition((ver+"_PATCH").c_str(), buf);
+ } // no break
+ case 2:
+ {
+ sprintf(buf, "%u", this->VersionMinor);
+ this->Makefile->AddDefinition((ver+"_MINOR").c_str(), buf);
+ } // no break
+ case 1:
+ {
+ sprintf(buf, "%u", this->VersionMajor);
+ this->Makefile->AddDefinition((ver+"_MAJOR").c_str(), buf);
+ } // no break
+ default: break;
}
+ // Tell the module whether an exact version has been requested.
+ std::string exact = this->Name;
+ exact += "_FIND_VERSION_EXACT";
+ this->Makefile->AddDefinition(exact.c_str(),
+ this->VersionExact? "1":"0");
+ }
+}
+
+
+//----------------------------------------------------------------------------
+bool cmFindPackageCommand::FindModule(bool& found)
+{
+ std::string module = "Find";
+ module += this->Name;
+ module += ".cmake";
+ std::string mfile = this->Makefile->GetModulesFile(module.c_str());
+ if ( mfile.size() )
+ {
// Load the module we found.
found = true;
return this->ReadListFile(mfile.c_str());