Generate the _IMPORT_PREFIX in the non-config export file.

This commit is contained in:
Stephen Kelly 2013-01-27 09:42:54 +01:00
parent f7db6d115d
commit 3a1719793f
1 changed files with 28 additions and 29 deletions

View File

@ -69,6 +69,27 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
this->GenerateExpectedTargetsCode(os, expectedTargets); 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<std::string> missingTargets; std::vector<std::string> missingTargets;
// Create all the imported targets. // Create all the imported targets.
@ -107,6 +128,13 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
<< "endforeach()\n" << "endforeach()\n"
<< "\n"; << "\n";
// Cleanup the import prefix variable.
if(!this->ImportPrefix.empty())
{
os << "# Cleanup temporary variables.\n"
<< "set(_IMPORT_PREFIX)\n"
<< "\n";
}
this->GenerateImportedFileCheckLoop(os); this->GenerateImportedFileCheckLoop(os);
// Generate an import file for each configuration. // Generate an import file for each configuration.
@ -187,27 +215,6 @@ cmExportInstallFileGenerator
const char* config, std::string const& suffix, const char* config, std::string const& suffix,
std::vector<std::string> &missingTargets) std::vector<std::string> &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. // Add each target in the set to the export.
for(std::vector<cmTargetExport*>::const_iterator for(std::vector<cmTargetExport*>::const_iterator
tei = this->IEGen->GetExportSet()->GetTargetExports()->begin(); tei = this->IEGen->GetExportSet()->GetTargetExports()->begin();
@ -253,14 +260,6 @@ cmExportInstallFileGenerator
importedLocations); importedLocations);
} }
} }
// Cleanup the import prefix variable.
if(!this->ImportPrefix.empty())
{
os << "# Cleanup temporary variables.\n"
<< "set(_IMPORT_PREFIX)\n"
<< "\n";
}
} }
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------