Commit 130b0e21 authored by Alexander Neundorf's avatar Alexander Neundorf

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
parent dfe9c951
...@@ -817,36 +817,56 @@ bool cmFindPackageCommand::HandlePackageMode() ...@@ -817,36 +817,56 @@ bool cmFindPackageCommand::HandlePackageMode()
{ {
// The variable is not set. // The variable is not set.
cmOStringStream e; cmOStringStream e;
e << "Could not find "; // If there are files in ConsideredConfigs, it means that FooConfig.cmake
if(!this->NoModule) // have been found, but they didn't have appropriate versions.
{ if (this->ConsideredConfigFiles.size() > 0)
e << "module Find" << this->Name << ".cmake or "; {
} e << "Could not find configuration file for package " << this->Name
e << "a configuration file for package " << this->Name << ".\n"; << " with " << (this->VersionExact ? "exact " : "at least ")
if(!this->NoModule) << "version " << this->Version << " .\n"
{ << "Found the following files:\n";
e << "Adjust CMAKE_MODULE_PATH to find Find" for(std::vector<std::string>::size_type i=0;
<< this->Name << ".cmake or set "; i<this->ConsideredConfigFiles.size(); i++)
} {
else e << " " << this->ConsideredConfigFiles[i]
{ << ", version: " << this->ConsideredVersions[i] << "\n";
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 else
{ {
e << "The file will have one of the following names:\n"; e << "Could not find ";
for(std::vector<std::string>::const_iterator ci = this->Configs.begin(); if(!this->NoModule)
ci != this->Configs.end(); ++ci) {
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->Makefile->IssueMessage(
this->Required? cmake::FATAL_ERROR : cmake::WARNING, e.str()); this->Required? cmake::FATAL_ERROR : cmake::WARNING, e.str());
} }
...@@ -911,20 +931,14 @@ bool cmFindPackageCommand::HandlePackageMode() ...@@ -911,20 +931,14 @@ bool cmFindPackageCommand::HandlePackageMode()
consideredVersionsVar += "_CONSIDERED_VERSIONS"; consideredVersionsVar += "_CONSIDERED_VERSIONS";
std::string consideredConfigFiles; 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; std::string consideredVersions;
for(std::vector<std::string>::const_iterator
it = this->ConsideredVersions.begin(); for(std::vector<std::string>::size_type i=0;
it != this->ConsideredVersions.end(); ++it) i<this->ConsideredConfigFiles.size(); i++)
{ {
consideredVersions += *it; consideredConfigFiles += this->ConsideredConfigFiles[i];
consideredConfigFiles += ";";
consideredVersions += this->ConsideredVersions[i];
consideredVersions += ";"; consideredVersions += ";";
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment