summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2021-07-08 11:54:47 (GMT)
committerKitware Robot <kwrobot@kitware.com>2021-07-08 11:54:53 (GMT)
commitc3a5dec0e83e15666734e7eb3f72ecba70f50913 (patch)
tree055564979e99f087ad2dbcdd15e080372e5c8e75
parent8b4e586f0d166e3f415536f3a41602335e9f74fa (diff)
parentc00f928ce1aba90c0b3fe8d6112eacd0f5494ec3 (diff)
downloadCMake-c3a5dec0e83e15666734e7eb3f72ecba70f50913.zip
CMake-c3a5dec0e83e15666734e7eb3f72ecba70f50913.tar.gz
CMake-c3a5dec0e83e15666734e7eb3f72ecba70f50913.tar.bz2
Merge topic 'CPATH_symlinks'
c00f928ce1 Do not exclude include directory symlinks to entries of CPATH 5c02964aff cmLocalGenerator: Simplify CPATH lookup loop 86595b3002 cmLocalGenerator: Clarify check for membership in multiple sets 10969fd003 cmLocalGenerator: Remove unnecessary parentheses in a condition 3fd56472c6 cmLocalGenerator: Store realpath lookup result in a variable 429fb28f25 cmLocalGenerator: Factor out repeated condition into local variable Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !6313
-rw-r--r--Source/cmLocalGenerator.cxx33
-rw-r--r--Source/cmLocalGenerator.h2
2 files changed, 23 insertions, 12 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index a14f085..3d36acd 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -107,10 +107,9 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile)
{
std::vector<std::string> cpath;
cmSystemTools::GetPath(cpath, "CPATH");
- for (std::string& cp : cpath) {
+ for (std::string const& cp : cpath) {
if (cmSystemTools::FileIsFullPath(cp)) {
- cp = cmSystemTools::CollapseFullPath(cp);
- this->EnvCPATH.emplace(std::move(cp));
+ this->EnvCPATH.emplace_back(cmSystemTools::CollapseFullPath(cp));
}
}
}
@@ -1247,19 +1246,31 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
}
}
+ bool const isCorCxx = (lang == "C" || lang == "CXX");
+
+ // Resolve symlinks in CPATH for comparison with resolved include paths.
+ // We do this here instead of when EnvCPATH is populated in case symlinks
+ // on disk have changed in the meantime.
+ std::set<std::string> resolvedEnvCPATH;
+ if (isCorCxx) {
+ for (std::string const& i : this->EnvCPATH) {
+ resolvedEnvCPATH.emplace(this->GlobalGenerator->GetRealPath(i));
+ }
+ }
+
// Checks if this is not an excluded (implicit) include directory.
- auto notExcluded = [this, &implicitSet, &implicitExclude,
- &lang](std::string const& dir) {
- return (
- // Do not exclude directories that are not in an excluded set.
- ((!cm::contains(implicitSet, this->GlobalGenerator->GetRealPath(dir))) &&
- (!cm::contains(implicitExclude, dir)))
+ auto notExcluded = [this, &implicitSet, &implicitExclude, &resolvedEnvCPATH,
+ isCorCxx](std::string const& dir) -> bool {
+ std::string const& real_dir = this->GlobalGenerator->GetRealPath(dir);
+ return
+ // Do not exclude directories that are not in any excluded set.
+ !(cm::contains(implicitSet, real_dir) ||
+ cm::contains(implicitExclude, dir))
// 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") && cm::contains(this->EnvCPATH, dir)));
+ || (isCorCxx && cm::contains(resolvedEnvCPATH, real_dir));
};
// Get the target-specific include directories.
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 993280a..cafb34d 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -587,7 +587,7 @@ protected:
std::string::size_type ObjectPathMax;
std::set<std::string> ObjectMaxPathViolations;
- std::set<std::string> EnvCPATH;
+ std::vector<std::string> EnvCPATH;
using GeneratorTargetMap =
std::unordered_map<std::string, cmGeneratorTarget*>;