Commit 04c0efd4 authored by Brad King's avatar Brad King

Merge branch 'implicit-includes-autogen' into release-3.14

Merge-request: !3159
parents bd00090e a8b7cbb7
......@@ -937,10 +937,8 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
// Implicit include directories
std::vector<std::string> implicitDirs;
std::set<std::string> implicitSet;
// Checks if this is not an implicit include directory
auto notImplicit = [&implicitSet](std::string const& dir) {
return (implicitSet.find(dir) == implicitSet.end());
};
// Include directories to be excluded as if they were implicit.
std::set<std::string> implicitExclude;
{
// Raw list of implicit include directories
// Start with "standard" directories that we unconditionally add below.
......@@ -978,7 +976,8 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
[](std::string const& d) {
return cmHasLiteralSuffix(d, "/usr/include");
}) != impDirVec.end()) {
impDirVec.emplace_back("/usr/include");
// Only exclude this hard coded path for backwards compatibility.
implicitExclude.emplace("/usr/include");
}
for (std::string const& i : impDirVec) {
......@@ -988,6 +987,12 @@ 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()));
};
// Get the target-specific include directories.
std::vector<BT<std::string>> userDirs =
target->GetIncludeDirectories(config, lang);
......@@ -1004,7 +1009,7 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
cmSystemTools::ComparePath(udr.Value, topBinaryDir) ||
cmSystemTools::IsSubDirectory(udr.Value, topSourceDir) ||
cmSystemTools::IsSubDirectory(udr.Value, topBinaryDir)) {
if (notImplicit(udr.Value)) {
if (notExcluded(udr.Value)) {
emitBT(udr);
}
}
......@@ -1013,7 +1018,7 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
// Emit remaining non implicit user direcories.
for (BT<std::string> const& udr : userDirs) {
if (notImplicit(udr.Value)) {
if (notExcluded(udr.Value)) {
emitBT(udr);
}
}
......@@ -1032,7 +1037,7 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
if (!stripImplicitDirs) {
// Append implicit directories that were requested by the user only
for (BT<std::string> const& udr : userDirs) {
if (!notImplicit(udr.Value)) {
if (implicitSet.find(udr.Value) != implicitSet.end()) {
emitBT(udr);
}
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment