summaryrefslogtreecommitdiffstats
path: root/Source/cmLocalGenerator.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2019-02-18 20:01:59 (GMT)
committerBrad King <brad.king@kitware.com>2019-02-18 22:12:14 (GMT)
commit890bae524c6b97d29ffcc3fe5a6a30235d800348 (patch)
tree2e4e04c90e3ced680511c1065ae5b0d75eee9683 /Source/cmLocalGenerator.cxx
parent5c171ca898f92e07cb68dd7fa77d0a993b08cc9c (diff)
downloadCMake-890bae524c6b97d29ffcc3fe5a6a30235d800348.zip
CMake-890bae524c6b97d29ffcc3fe5a6a30235d800348.tar.gz
CMake-890bae524c6b97d29ffcc3fe5a6a30235d800348.tar.bz2
Do not explicitly report "standard" include directories as implicit
In commit 1293ed8507 (ParseImplicitIncludeInfo: keep implicit incl. consistent when rerunning cmake, 2019-01-30, v3.14.0-rc1~26^2) we did not account for `CMAKE_<LANG>_STANDARD_INCLUDE_DIRECTORIES`. This variable lets platform modules or toolchain files specify directories that are to be explicitly passed as standard include directories. These include directories are used by the test project from which we extract implicit include directories so they appear in the parsed results whether or not the compiler really considers them implicit. Exclude these entries from the computed implicit include directories since they are not actually implied by the compiler when we invoke it with "standard" include directories passed explicitly. Instead teach the build system generators to treat the "standard" directories as implicit for purposes of excluding them from appearing earlier in the compiler command line due to `include_directories` and `target_include_directories` calls. Issue: #18936, #18944
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r--Source/cmLocalGenerator.cxx47
1 files changed, 27 insertions, 20 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index c4f2cde..8b01af1 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -920,6 +920,20 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
return result;
}
+ // Standard include directories to be added unconditionally at the end.
+ // These are intended to simulate additional implicit include directories.
+ std::vector<std::string> userStandardDirs;
+ {
+ std::string key = "CMAKE_";
+ key += lang;
+ key += "_STANDARD_INCLUDE_DIRECTORIES";
+ std::string const value = this->Makefile->GetSafeDefinition(key);
+ cmSystemTools::ExpandListArgument(value, userStandardDirs);
+ for (std::string& usd : userStandardDirs) {
+ cmSystemTools::ConvertToUnixSlashes(usd);
+ }
+ }
+
// Implicit include directories
std::vector<std::string> implicitDirs;
std::set<std::string> implicitSet;
@@ -929,14 +943,20 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
};
{
// Raw list of implicit include directories
- std::vector<std::string> impDirVec;
+ // Start with "standard" directories that we unconditionally add below.
+ std::vector<std::string> impDirVec = userStandardDirs;
// Load implicit include directories for this language.
std::string key = "CMAKE_";
key += lang;
key += "_IMPLICIT_INCLUDE_DIRECTORIES";
if (const char* value = this->Makefile->GetDefinition(key)) {
+ size_t const impDirVecOldSize = impDirVec.size();
cmSystemTools::ExpandListArgument(value, impDirVec);
+ // FIXME: Use cmRange with 'advance()' when it supports non-const.
+ for (size_t i = impDirVecOldSize; i < impDirVec.size(); ++i) {
+ cmSystemTools::ConvertToUnixSlashes(impDirVec[i]);
+ }
}
// The Platform/UnixPaths module used to hard-code /usr/include for C, CXX,
@@ -956,10 +976,8 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
}
for (std::string const& i : impDirVec) {
- std::string imd = i;
- cmSystemTools::ConvertToUnixSlashes(imd);
- if (implicitSet.insert(imd).second) {
- implicitDirs.emplace_back(std::move(imd));
+ if (implicitSet.insert(i).second) {
+ implicitDirs.emplace_back(i);
}
}
}
@@ -998,21 +1016,10 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
MoveSystemIncludesToEnd(result, config, lang, target);
// Append standard include directories for this language.
- {
- std::vector<std::string> userStandardDirs;
- {
- std::string key = "CMAKE_";
- key += lang;
- key += "_STANDARD_INCLUDE_DIRECTORIES";
- std::string const value = this->Makefile->GetSafeDefinition(key);
- cmSystemTools::ExpandListArgument(value, userStandardDirs);
- }
- userDirs.reserve(userDirs.size() + userStandardDirs.size());
- for (std::string& usd : userStandardDirs) {
- cmSystemTools::ConvertToUnixSlashes(usd);
- emitDir(usd);
- userDirs.emplace_back(std::move(usd));
- }
+ userDirs.reserve(userDirs.size() + userStandardDirs.size());
+ for (std::string& usd : userStandardDirs) {
+ emitDir(usd);
+ userDirs.emplace_back(std::move(usd));
}
// Append compiler implicit include directories