mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 21:31:08 -06:00
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
This commit is contained in:
committed by
Brad King
parent
5c02964aff
commit
c00f928ce1
@@ -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.
|
||||
|
||||
@@ -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*>;
|
||||
|
||||
Reference in New Issue
Block a user