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
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
......@@ -935,6 +935,7 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
} else {
rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT");
// 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;
if (!rootPath.empty() && !cmHasPrefix(imd, rootPath)) {
imd = rootPath + imd;
if (implicitSet.insert(imd).second) {
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