summaryrefslogtreecommitdiffstats
path: root/Source/cmFindPackageCommand.cxx
diff options
context:
space:
mode:
authorAlex Neundorf <neundorf@kde.org>2010-08-29 15:43:45 (GMT)
committerAlex Neundorf <neundorf@kde.org>2010-08-29 15:43:45 (GMT)
commit130b0e21958535a4f4f408cf7392fa9b3ee336fe (patch)
treeb042726b80128a36596b9d1c0246e3f77abc0a36 /Source/cmFindPackageCommand.cxx
parentdfe9c95129b9ca05ea8ca98e69d973c9c40e5a4e (diff)
downloadCMake-130b0e21958535a4f4f408cf7392fa9b3ee336fe.zip
CMake-130b0e21958535a4f4f408cf7392fa9b3ee336fe.tar.gz
CMake-130b0e21958535a4f4f408cf7392fa9b3ee336fe.tar.bz2
Improve error message in Config-mode when no appropriate version was found
If in config-mode config files have been found by find_package(), but their version didn't match the requested version, now all considered files and their versions are printed (instead of saying "didn't find config file) Alex
Diffstat (limited to 'Source/cmFindPackageCommand.cxx')
-rw-r--r--Source/cmFindPackageCommand.cxx86
1 files changed, 50 insertions, 36 deletions
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index b8dcb3d..90fcf69 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -817,36 +817,56 @@ bool cmFindPackageCommand::HandlePackageMode()
{
// The variable is not set.
cmOStringStream e;
- e << "Could not find ";
- if(!this->NoModule)
- {
- e << "module Find" << this->Name << ".cmake or ";
- }
- e << "a configuration file for package " << this->Name << ".\n";
- if(!this->NoModule)
- {
- e << "Adjust CMAKE_MODULE_PATH to find Find"
- << this->Name << ".cmake or set ";
- }
- else
- {
- e << "Set ";
- }
- e << this->Variable << " to the directory containing a CMake "
- << "configuration file for " << this->Name << ". ";
- if(this->Configs.size() == 1)
- {
- e << "The file will be called " << this->Configs[0];
+ // If there are files in ConsideredConfigs, it means that FooConfig.cmake
+ // have been found, but they didn't have appropriate versions.
+ if (this->ConsideredConfigFiles.size() > 0)
+ {
+ e << "Could not find configuration file for package " << this->Name
+ << " with " << (this->VersionExact ? "exact " : "at least ")
+ << "version " << this->Version << " .\n"
+ << "Found the following files:\n";
+ for(std::vector<std::string>::size_type i=0;
+ i<this->ConsideredConfigFiles.size(); i++)
+ {
+ e << " " << this->ConsideredConfigFiles[i]
+ << ", version: " << this->ConsideredVersions[i] << "\n";
+ }
}
else
{
- e << "The file will have one of the following names:\n";
- for(std::vector<std::string>::const_iterator ci = this->Configs.begin();
- ci != this->Configs.end(); ++ci)
+ e << "Could not find ";
+ if(!this->NoModule)
+ {
+ e << "module Find" << this->Name << ".cmake or ";
+ }
+ e << "a configuration file for package " << this->Name << ".\n";
+ if(!this->NoModule)
+ {
+ e << "Adjust CMAKE_MODULE_PATH to find Find"
+ << this->Name << ".cmake or set ";
+ }
+ else
+ {
+ e << "Set ";
+ }
+ e << this->Variable << " to the directory containing a CMake "
+ << "configuration file for " << this->Name << ". ";
+ if(this->Configs.size() == 1)
+ {
+ e << "The file will be called " << this->Configs[0];
+ }
+ else
{
- e << " " << *ci << "\n";
+ e << "The file will have one of the following names:\n";
+ for(std::vector<std::string>::const_iterator ci=this->Configs.begin();
+ ci != this->Configs.end(); ++ci)
+ {
+ e << " " << *ci << "\n";
+ }
}
}
+
+
this->Makefile->IssueMessage(
this->Required? cmake::FATAL_ERROR : cmake::WARNING, e.str());
}
@@ -911,20 +931,14 @@ bool cmFindPackageCommand::HandlePackageMode()
consideredVersionsVar += "_CONSIDERED_VERSIONS";
std::string consideredConfigFiles;
- for(std::vector<std::string>::const_iterator
- it = this->ConsideredConfigFiles.begin();
- it != this->ConsideredConfigFiles.end(); ++it)
- {
- consideredConfigFiles += *it;
- consideredConfigFiles += ";";
- }
-
std::string consideredVersions;
- for(std::vector<std::string>::const_iterator
- it = this->ConsideredVersions.begin();
- it != this->ConsideredVersions.end(); ++it)
+
+ for(std::vector<std::string>::size_type i=0;
+ i<this->ConsideredConfigFiles.size(); i++)
{
- consideredVersions += *it;
+ consideredConfigFiles += this->ConsideredConfigFiles[i];
+ consideredConfigFiles += ";";
+ consideredVersions += this->ConsideredVersions[i];
consideredVersions += ";";
}