exports: define a CMAKE_FIND_PACKAGE_NAME var set by find_package()
This way the name of the searched package can be accessed in find-modules, config-files and more importantly in generated target export files. This is now used when a target export file detects that a required target does not exist. Alex
This commit is contained in:
parent
0cfd055acd
commit
6f50a04cc1
|
@ -389,8 +389,15 @@ void cmExportFileGenerator::GenerateMissingTargetsCheckCode(std::ostream& os,
|
||||||
for(unsigned int i=0; i<missingTargets.size(); ++i)
|
for(unsigned int i=0; i<missingTargets.size(); ++i)
|
||||||
{
|
{
|
||||||
os << "IF(NOT TARGET \"" << missingTargets[i] << "\" )\n"
|
os << "IF(NOT TARGET \"" << missingTargets[i] << "\" )\n"
|
||||||
<< " MESSAGE(FATAL_ERROR \"Required imported target \\\""
|
<< " IF(CMAKE_FIND_PACKAGE_NAME)\n"
|
||||||
|
<< " SET( ${CMAKE_FIND_PACKAGE_NAME}_FOUND FALSE)\n"
|
||||||
|
<< " SET( ${CMAKE_FIND_PACKAGE_NAME}_NOT_FOUND_MESSAGE "
|
||||||
|
<< "\"Required imported target \\\"" << missingTargets[i]
|
||||||
|
<< "\\\" not found ! \")\n"
|
||||||
|
<< " ELSE()\n"
|
||||||
|
<< " MESSAGE(FATAL_ERROR \"Required imported target \\\""
|
||||||
<< missingTargets[i] << "\\\" not found ! \")\n"
|
<< missingTargets[i] << "\\\" not found ! \")\n"
|
||||||
|
<< " ENDIF()\n"
|
||||||
<< "ENDIF()\n";
|
<< "ENDIF()\n";
|
||||||
}
|
}
|
||||||
os << "\n";
|
os << "\n";
|
||||||
|
|
|
@ -840,6 +840,8 @@ bool cmFindPackageCommand
|
||||||
//----------------------------------------------------------------------------
|
//----------------------------------------------------------------------------
|
||||||
void cmFindPackageCommand::SetModuleVariables(const std::string& components)
|
void cmFindPackageCommand::SetModuleVariables(const std::string& components)
|
||||||
{
|
{
|
||||||
|
this->AddFindDefinition("CMAKE_FIND_PACKAGE_NAME", this->Name.c_str());
|
||||||
|
|
||||||
// Store the list of components.
|
// Store the list of components.
|
||||||
std::string components_var = this->Name + "_FIND_COMPONENTS";
|
std::string components_var = this->Name + "_FIND_COMPONENTS";
|
||||||
this->AddFindDefinition(components_var.c_str(), components.c_str());
|
this->AddFindDefinition(components_var.c_str(), components.c_str());
|
||||||
|
|
Loading…
Reference in New Issue