diff options
author | Brad King <brad.king@kitware.com> | 2013-01-29 19:52:19 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2013-01-29 19:52:19 (GMT) |
commit | 5f78d2057f1447afb6ec33e5f8a241c8bcdcd5f1 (patch) | |
tree | c473a92ace315c7cf2a48465a2643658a1425838 /Source/cmExportInstallFileGenerator.cxx | |
parent | 3e7bba3fb2d431b512181e99c6333e9dfdc8a9fd (diff) | |
parent | 34d1ade048a87953c089d730f0126eecb6685968 (diff) | |
download | CMake-5f78d2057f1447afb6ec33e5f8a241c8bcdcd5f1.zip CMake-5f78d2057f1447afb6ec33e5f8a241c8bcdcd5f1.tar.gz CMake-5f78d2057f1447afb6ec33e5f8a241c8bcdcd5f1.tar.bz2 |
Merge topic 'fix-relocatable-include-dirs'
34d1ade Add the INSTALL_PREFIX genex.
3a17197 Generate the _IMPORT_PREFIX in the non-config export file.
Diffstat (limited to 'Source/cmExportInstallFileGenerator.cxx')
-rw-r--r-- | Source/cmExportInstallFileGenerator.cxx | 72 |
1 files changed, 43 insertions, 29 deletions
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index a35f5cf..b6600f0 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<std::string> 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. @@ -127,6 +155,21 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) } //---------------------------------------------------------------------------- +void +cmExportInstallFileGenerator::ReplaceInstallPrefix(std::string &input) +{ + std::string::size_type pos = 0; + std::string::size_type lastPos = pos; + + while((pos = input.find("$<INSTALL_PREFIX>", lastPos)) != input.npos) + { + std::string::size_type endPos = pos + sizeof("$<INSTALL_PREFIX>") - 1; + input.replace(pos, endPos - pos, "${_IMPORT_PREFIX}"); + lastPos = endPos; + } +} + +//---------------------------------------------------------------------------- bool cmExportInstallFileGenerator::GenerateImportFileConfig(const char* config, std::vector<std::string> &missingTargets) @@ -187,27 +230,6 @@ cmExportInstallFileGenerator const char* config, std::string const& suffix, 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. for(std::vector<cmTargetExport*>::const_iterator tei = this->IEGen->GetExportSet()->GetTargetExports()->begin(); @@ -253,14 +275,6 @@ cmExportInstallFileGenerator importedLocations); } } - - // Cleanup the import prefix variable. - if(!this->ImportPrefix.empty()) - { - os << "# Cleanup temporary variables.\n" - << "set(_IMPORT_PREFIX)\n" - << "\n"; - } } //---------------------------------------------------------------------------- |