From 6fc33829443ea3ef2dc8cc71c0a98b635bec6179 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 13 Feb 2019 09:27:24 -0500 Subject: Update logic for sysroot in detected implicit include directories Since commit 5990ecb741 (Compute implicit include directories from compiler output, 2018-12-07, v3.14.0-rc1~108^2) the values of the `CMAKE__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__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. --- Source/cmLocalGenerator.cxx | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index b1115ea..8090e00 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -935,6 +935,7 @@ std::vector> cmLocalGenerator::GetIncludeDirectoriesImplicit( } else { rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT"); } + cmSystemTools::ConvertToUnixSlashes(rootPath); // Raw list of implicit include directories std::vector impDirVec; @@ -964,8 +965,11 @@ std::vector> 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)); } -- cgit v0.12