From 3a1719793fa4eb4024e2e36e17196832551d469c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 27 Jan 2013 09:42:54 +0100 Subject: [PATCH] Generate the _IMPORT_PREFIX in the non-config export file. --- Source/cmExportInstallFileGenerator.cxx | 57 ++++++++++++------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index a35f5cf6e..c7e3581d7 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -69,6 +69,27 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) this->GenerateExpectedTargetsCode(os, expectedTargets); } + // Add code to compute the installation prefix relative to the + // import file location. + const char* installDest = this->IEGen->GetDestination(); + if(!cmSystemTools::FileIsFullPath(installDest)) + { + std::string dest = installDest; + os << "# Compute the installation prefix relative to this file.\n" + << "get_filename_component(_IMPORT_PREFIX " + << "\"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n"; + while(!dest.empty()) + { + os << + "get_filename_component(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" PATH)\n"; + dest = cmSystemTools::GetFilenamePath(dest); + } + os << "\n"; + + // Import location properties may reference this variable. + this->ImportPrefix = "${_IMPORT_PREFIX}/"; + } + std::vector missingTargets; // Create all the imported targets. @@ -107,6 +128,13 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) << "endforeach()\n" << "\n"; + // Cleanup the import prefix variable. + if(!this->ImportPrefix.empty()) + { + os << "# Cleanup temporary variables.\n" + << "set(_IMPORT_PREFIX)\n" + << "\n"; + } this->GenerateImportedFileCheckLoop(os); // Generate an import file for each configuration. @@ -187,27 +215,6 @@ cmExportInstallFileGenerator const char* config, std::string const& suffix, std::vector &missingTargets) { - // Add code to compute the installation prefix relative to the - // import file location. - const char* installDest = this->IEGen->GetDestination(); - if(!cmSystemTools::FileIsFullPath(installDest)) - { - std::string dest = installDest; - os << "# Compute the installation prefix relative to this file.\n" - << "get_filename_component(_IMPORT_PREFIX " - << "\"${CMAKE_CURRENT_LIST_FILE}\" PATH)\n"; - while(!dest.empty()) - { - os << - "get_filename_component(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" PATH)\n"; - dest = cmSystemTools::GetFilenamePath(dest); - } - os << "\n"; - - // Import location properties may reference this variable. - this->ImportPrefix = "${_IMPORT_PREFIX}/"; - } - // Add each target in the set to the export. for(std::vector::const_iterator tei = this->IEGen->GetExportSet()->GetTargetExports()->begin(); @@ -253,14 +260,6 @@ cmExportInstallFileGenerator importedLocations); } } - - // Cleanup the import prefix variable. - if(!this->ImportPrefix.empty()) - { - os << "# Cleanup temporary variables.\n" - << "set(_IMPORT_PREFIX)\n" - << "\n"; - } } //----------------------------------------------------------------------------