summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Neundorf <neundorf@kde.org>2012-09-23 16:40:40 (GMT)
committerBrad King <brad.king@kitware.com>2012-09-30 14:26:54 (GMT)
commit6f50a04cc1c4584472f850e06daad7ae20af45c4 (patch)
tree4ef4a21ed8131c8b84df082cd40ce09b1ab0364e
parent0cfd055acda3543d66690b5e92d8ee7c20e0654f (diff)
downloadCMake-6f50a04cc1c4584472f850e06daad7ae20af45c4.zip
CMake-6f50a04cc1c4584472f850e06daad7ae20af45c4.tar.gz
CMake-6f50a04cc1c4584472f850e06daad7ae20af45c4.tar.bz2
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
-rw-r--r--Source/cmExportFileGenerator.cxx9
-rw-r--r--Source/cmFindPackageCommand.cxx2
2 files changed, 10 insertions, 1 deletions
diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx
index 5d95668..8dffae4 100644
--- a/Source/cmExportFileGenerator.cxx
+++ b/Source/cmExportFileGenerator.cxx
@@ -389,8 +389,15 @@ void cmExportFileGenerator::GenerateMissingTargetsCheckCode(std::ostream& os,
for(unsigned int i=0; i<missingTargets.size(); ++i)
{
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"
+ << " ENDIF()\n"
<< "ENDIF()\n";
}
os << "\n";
diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx
index c20941a..470ceca 100644
--- a/Source/cmFindPackageCommand.cxx
+++ b/Source/cmFindPackageCommand.cxx
@@ -840,6 +840,8 @@ bool cmFindPackageCommand
//----------------------------------------------------------------------------
void cmFindPackageCommand::SetModuleVariables(const std::string& components)
{
+ this->AddFindDefinition("CMAKE_FIND_PACKAGE_NAME", this->Name.c_str());
+
// Store the list of components.
std::string components_var = this->Name + "_FIND_COMPONENTS";
this->AddFindDefinition(components_var.c_str(), components.c_str());