summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Grund <Flamefire@users.noreply.github.com>2021-07-06 14:11:42 (GMT)
committerBrad King <brad.king@kitware.com>2021-07-07 12:04:59 (GMT)
commitc00f928ce1aba90c0b3fe8d6112eacd0f5494ec3 (patch)
treebfa15043b2da6779de36d2d9ce73c51b850fc6a4
parent5c02964aff0e126980fe327ad1601665d9fcabfe (diff)
downloadCMake-c00f928ce1aba90c0b3fe8d6112eacd0f5494ec3.zip
CMake-c00f928ce1aba90c0b3fe8d6112eacd0f5494ec3.tar.gz
CMake-c00f928ce1aba90c0b3fe8d6112eacd0f5494ec3.tar.bz2
Do not exclude include directory symlinks to entries of CPATH
Extend the fix from commit 2d0b0e2b9d (Do not exclude include directories made implicit by CPATH, 2019-05-29, v3.14.5~2^2) to cover include directories that are symlinks to paths listed in `CPATH`. Compare resolved paths against resolved entries of `CPATH`. Resolve the entries as late as possible in case symlinks change. Fixes: #22383
-rw-r--r--Source/cmLocalGenerator.cxx16
-rw-r--r--Source/cmLocalGenerator.h2
2 files changed, 14 insertions, 4 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 30df4c4..3d36acd 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -109,7 +109,7 @@ cmLocalGenerator::cmLocalGenerator(cmGlobalGenerator* gg, cmMakefile* makefile)
cmSystemTools::GetPath(cpath, "CPATH");
for (std::string const& cp : cpath) {
if (cmSystemTools::FileIsFullPath(cp)) {
- this->EnvCPATH.emplace(cmSystemTools::CollapseFullPath(cp));
+ this->EnvCPATH.emplace_back(cmSystemTools::CollapseFullPath(cp));
}
}
}
@@ -1248,8 +1248,18 @@ 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,
+ auto notExcluded = [this, &implicitSet, &implicitExclude, &resolvedEnvCPATH,
isCorCxx](std::string const& dir) -> bool {
std::string const& real_dir = this->GlobalGenerator->GetRealPath(dir);
return
@@ -1260,7 +1270,7 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
// 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.
- || (isCorCxx && 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*>;