summaryrefslogtreecommitdiff
path: root/Source/cmExportInstallFileGenerator.cxx
diff options
context:
space:
mode:
authorBen Keller <irods.ben.keller@gmail.com>2016-05-10 11:44:40 -0400
committerBrad King <brad.king@kitware.com>2016-09-06 16:47:02 -0400
commit290e4ce8a89819d6617fa404513d8a1629cafea7 (patch)
tree2e361d6a33cffc3e729daba51268e00e85509d48 /Source/cmExportInstallFileGenerator.cxx
parent8317ea01aa3cf9319ef907e127fa6dbf9666cc53 (diff)
downloadcmake-290e4ce8a89819d6617fa404513d8a1629cafea7.tar.gz
install: Fix computed import prefix in export files when it is "/"
When exporting from a project (with install(EXPORT ...)), the `<PROJECT>Targets.cmake` file contains logic for computing the `_IMPORT_PREFIX` from its own location. This `_IMPORT_PREFIX` is then used in the `<PROJECT>Targets-<config>.cmake` file to generate the `IMPORTED_LOCATION_<CONFIG>`. The generation unconditionally appends a "/" to `_IMPORT_PREFIX` before appending the rest of the path. If `_IMPORT_PREFIX` is "/", then the `IMPORTED_LOCATION_<CONFIG>` properties all start with exactly two leading slashes ("//"). Exactly two leading slashes is a special case in POSIX file paths, such that its interpretation is left up to the implementation. This means that changing the path prefix from "/" to "//" should not be allowed. Since references to `_IMPORT_PREFIX` are always followed by a "/", simply check the value to replace "/" with "".
Diffstat (limited to 'Source/cmExportInstallFileGenerator.cxx')
-rw-r--r--Source/cmExportInstallFileGenerator.cxx5
1 files changed, 4 insertions, 1 deletions
diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx
index ceba69ac8b..bcadaa0236 100644
--- a/Source/cmExportInstallFileGenerator.cxx
+++ b/Source/cmExportInstallFileGenerator.cxx
@@ -122,7 +122,10 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
"PATH)\n";
dest = cmSystemTools::GetFilenamePath(dest);
}
- os << "\n";
+ os << "if(_IMPORT_PREFIX STREQUAL \"/\")\n"
+ << " set(_IMPORT_PREFIX \"\")\n"
+ << "endif()\n"
+ << "\n";
}
std::vector<std::string> missingTargets;