diff options
author | Brad King <brad.king@kitware.com> | 2019-02-14 15:14:11 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-02-14 15:14:47 (GMT) |
commit | 50ba2f019baa3e5487a975cb72059f1fc178f9d0 (patch) | |
tree | e75148951737edb1cc76eb532f1ee8583632b253 /Source/cmLocalGenerator.cxx | |
parent | fd74eba1402d66a4d6a1af3442cf219d02f7cbc8 (diff) | |
parent | 6fc33829443ea3ef2dc8cc71c0a98b635bec6179 (diff) | |
download | CMake-50ba2f019baa3e5487a975cb72059f1fc178f9d0.zip CMake-50ba2f019baa3e5487a975cb72059f1fc178f9d0.tar.gz CMake-50ba2f019baa3e5487a975cb72059f1fc178f9d0.tar.bz2 |
Merge topic 'fix-legacy-implicit-includes'
6fc3382944 Update logic for sysroot in detected implicit include directories
2ad14ef4ea cmAlgorithms: Add cmHasPrefix to match existing cmHasSuffix
557b2d6e65 Fix regression in -I/usr/include exclusion logic
017598a444 macOS: Fix addition of <sdk>/usr/include to default implicit include dirs
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2957
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index ba3c574..a2d0efe 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -935,16 +935,11 @@ 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; - // Get platform-wide implicit directories. - if (const char* implicitIncludes = (this->Makefile->GetDefinition( - "CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES"))) { - cmSystemTools::ExpandListArgument(implicitIncludes, impDirVec); - } - // Load implicit include directories for this language. std::string key = "CMAKE_"; key += lang; @@ -953,9 +948,28 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit( cmSystemTools::ExpandListArgument(value, impDirVec); } + // The Platform/UnixPaths module used to hard-code /usr/include for C, CXX, + // and CUDA in CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES, but those + // variables are now computed. On macOS the /usr/include directory is + // inside the platform SDK so the computed value does not contain it + // directly. In this case adding -I/usr/include can hide SDK headers so we + // must still exclude it. + if ((lang == "C" || lang == "CXX" || lang == "CUDA") && + std::find(impDirVec.begin(), impDirVec.end(), "/usr/include") == + impDirVec.end() && + std::find_if(impDirVec.begin(), impDirVec.end(), + [](std::string const& d) { + return cmHasLiteralSuffix(d, "/usr/include"); + }) != impDirVec.end()) { + impDirVec.emplace_back("/usr/include"); + } + 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)); } |