Updates will be applied April 15th at 12pm EDT (UTC-0400). GitLab could be a little slow between 12 - 12:45pm EDT.

Commit 290e4ce8 authored by Ben Keller's avatar Ben Keller Committed by Brad King

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
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 "".
parent 8317ea01
......@@ -122,7 +122,10 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os)
dest = cmSystemTools::GetFilenamePath(dest);
os << "\n";
os << "if(_IMPORT_PREFIX STREQUAL \"/\")\n"
<< " set(_IMPORT_PREFIX \"\")\n"
<< "endif()\n"
<< "\n";
std::vector<std::string> missingTargets;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment