diff options
author | Brad King <brad.king@kitware.com> | 2019-02-13 14:23:31 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-02-13 14:52:20 (GMT) |
commit | 557b2d6e65038640d5016413e612e48691cff0d8 (patch) | |
tree | e78fffef3bf804f628eb7d2ec424e9354a59adb5 /Source/cmLocalGenerator.cxx | |
parent | 017598a4443c19185dc245f3f0fcfceff9b98463 (diff) | |
download | CMake-557b2d6e65038640d5016413e612e48691cff0d8.zip CMake-557b2d6e65038640d5016413e612e48691cff0d8.tar.gz CMake-557b2d6e65038640d5016413e612e48691cff0d8.tar.bz2 |
Fix regression in -I/usr/include exclusion logic
The change in commit 15ad830062 (Refactor exclusion of -I/usr/include to
avoid per-language values, 2019-01-21, v3.14.0-rc1~108^2~4) caused the
exclusion to apply to Fortran, but it was only meant for C, CXX, and
CUDA. The purpose of the change was to prepare for the value of
`CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES` to be computed from the
actual compiler instead of hard-coded. We need to preserve exclusion of
`-I/usr/include` if the compiler has any implicit include directory that
looks intended to replace it, e.g. `<sdk>/usr/include` on macOS.
Fixes: #18914
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 252aa4c..b1115ea 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -939,12 +939,6 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit( // 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,6 +947,22 @@ 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; cmSystemTools::ConvertToUnixSlashes(imd); |