Commit 6fc33829 authored by Brad King's avatar Brad King

Update logic for sysroot in detected implicit include directories

Since commit 5990ecb7 (Compute implicit include directories from
compiler output, 2018-12-07, v3.14.0-rc1~108^2) the values of the
`CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES` variables are computed from
a real compiler invocation.  In this case the paths under the sysroot
should already have the sysroot prefix so we should no longer have to
add the sysroot prefix.  However, it is also possible for project code
to add its own paths to `CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES`
without the sysroot prefix and expect the historical addition of the
sysroot prefix to be preserved.

Try to account for both cases by conditionally adding the sysroot prefix
on implicit include directories that do not already have it.
parent 2ad14ef4
Pipeline #129941 passed with stage
......@@ -935,6 +935,7 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
} else {
rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT");
}
cmSystemTools::ConvertToUnixSlashes(rootPath);
// Raw list of implicit include directories
std::vector<std::string> impDirVec;
......@@ -964,8 +965,11 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
}
for (std::string const& i : impDirVec) {
std::string imd = rootPath + i;
std::string imd = i;
cmSystemTools::ConvertToUnixSlashes(imd);
if (!rootPath.empty() && !cmHasPrefix(imd, rootPath)) {
imd = rootPath + imd;
}
if (implicitSet.insert(imd).second) {
implicitDirs.emplace_back(std::move(imd));
}
......
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