diff options
-rw-r--r-- | Modules/Platform/UnixPaths.cmake | 5 | ||||
-rw-r--r-- | Source/cmLocalGenerator.cxx | 22 |
2 files changed, 16 insertions, 11 deletions
diff --git a/Modules/Platform/UnixPaths.cmake b/Modules/Platform/UnixPaths.cmake index 4ae4514..46c24bb 100644 --- a/Modules/Platform/UnixPaths.cmake +++ b/Modules/Platform/UnixPaths.cmake @@ -63,11 +63,6 @@ list(APPEND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES /lib /lib32 /lib64 /usr/lib /usr/lib32 /usr/lib64 ) -# Platform-wide directories to avoid adding via -I<dir>. -list(APPEND CMAKE_PLATFORM_IMPLICIT_INCLUDE_DIRECTORIES - /usr/include - ) - # Default per-language values. These may be later replaced after # parsing the implicit directory information from compiler output. set(_CMAKE_C_IMPLICIT_INCLUDE_DIRECTORIES_INIT 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); |