summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-05-31 13:03:16 (GMT)
committerKitware Robot <kwrobot@kitware.com>2019-05-31 13:03:28 (GMT)
commit0d025f75c14c0f5a7b7199a0712c958f5703c24e (patch)
tree02d7512e17c6b1bf8d40a38c4252bf5d1caa5e69 /Source
parentebee9ff160569481aed4e0db5cbb3f3ac925c044 (diff)
parent2d0b0e2b9d50aa14ccf345c727b2da73dfba9bd6 (diff)
downloadCMake-0d025f75c14c0f5a7b7199a0712c958f5703c24e.zip
CMake-0d025f75c14c0f5a7b7199a0712c958f5703c24e.tar.gz
CMake-0d025f75c14c0f5a7b7199a0712c958f5703c24e.tar.bz2
Merge topic 'implicit-includes-CPATH'
2d0b0e2b9d Do not exclude include directories made implicit by CPATH Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !3395
Diffstat (limited to 'Source')
-rw-r--r--Source/cmLocalGenerator.cxx28
-rw-r--r--Source/cmLocalGenerator.h2
2 files changed, 27 insertions, 3 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 787e98e..87d2232 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -88,6 +88,19 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile)
this->ComputeObjectMaxPath();
+ // Canonicalize entries of the CPATH environment variable the same
+ // way detection of CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES does.
+ {
+ std::vector<std::string> cpath;
+ cmSystemTools::GetPath(cpath, "CPATH");
+ for (std::string& cp : cpath) {
+ if (cmSystemTools::FileIsFullPath(cp)) {
+ cp = cmSystemTools::CollapseFullPath(cp);
+ this->EnvCPATH.emplace(std::move(cp));
+ }
+ }
+ }
+
std::vector<std::string> enabledLanguages =
this->GetState()->GetEnabledLanguages();
@@ -1011,9 +1024,18 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
}
// Checks if this is not an excluded (implicit) include directory.
- auto notExcluded = [&implicitSet, &implicitExclude](std::string const& dir) {
- return ((implicitSet.find(dir) == implicitSet.end()) &&
- (implicitExclude.find(dir) == implicitExclude.end()));
+ auto notExcluded = [this, &implicitSet, &implicitExclude,
+ &lang](std::string const& dir) {
+ return (
+ // Do not exclude directories that are not in an excluded set.
+ ((implicitSet.find(dir) == implicitSet.end()) &&
+ (implicitExclude.find(dir) == implicitExclude.end()))
+ // Do not exclude entries of the CPATH environment variable even though
+ // they are implicitly searched by the compiler. They are meant to be
+ // user-specified directories that can be re-ordered or converted to
+ // -isystem without breaking real compiler builtin headers.
+ || ((lang == "C" || lang == "CXX") &&
+ (this->EnvCPATH.find(dir) != this->EnvCPATH.end())));
};
// Get the target-specific include directories.
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 67e3c58..f0c6806 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -429,6 +429,8 @@ protected:
std::string::size_type ObjectPathMax;
std::set<std::string> ObjectMaxPathViolations;
+ std::set<std::string> EnvCPATH;
+
typedef std::unordered_map<std::string, cmGeneratorTarget*>
GeneratorTargetMap;
GeneratorTargetMap GeneratorTargetSearchIndex;