summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-04-24 15:04:20 (GMT)
committerKitware Robot <kwrobot@kitware.com>2018-04-24 15:05:12 (GMT)
commitb928be62fa403403ba5d8bc7521b5a8ae5ff54cf (patch)
tree0f1f1b2ac6bb24d19ac6a503b4b51e56b328d83a /Source
parent1ec112c70de1718464074febdad16ede4da4a12f (diff)
parent76ad2ecb500c8652e59179959b8ecee28a5196de (diff)
downloadCMake-b928be62fa403403ba5d8bc7521b5a8ae5ff54cf.zip
CMake-b928be62fa403403ba5d8bc7521b5a8ae5ff54cf.tar.gz
CMake-b928be62fa403403ba5d8bc7521b5a8ae5ff54cf.tar.bz2
Merge topic 'reorder-sys-includes'
76ad2ecb50 Order SYSTEM include directories after non-system directories Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1968
Diffstat (limited to 'Source')
-rw-r--r--Source/cmLocalGenerator.cxx23
-rw-r--r--Source/cmLocalGenerator.h4
2 files changed, 26 insertions, 1 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx
index 629d54a..c5370e4 100644
--- a/Source/cmLocalGenerator.cxx
+++ b/Source/cmLocalGenerator.cxx
@@ -202,6 +202,22 @@ void cmLocalGenerator::ComputeObjectMaxPath()
this->ObjectMaxPathViolations.clear();
}
+void cmLocalGenerator::MoveSystemIncludesToEnd(
+ std::vector<std::string>& includeDirs, const std::string& config,
+ const std::string& lang, const cmGeneratorTarget* target) const
+{
+ if (!target) {
+ return;
+ }
+
+ std::stable_sort(
+ includeDirs.begin(), includeDirs.end(),
+ [&target, &config, &lang](std::string const& a, std::string const& b) {
+ return !target->IsSystemIncludeDirectory(a, config, lang) &&
+ target->IsSystemIncludeDirectory(b, config, lang);
+ });
+}
+
void cmLocalGenerator::TraceDependencies()
{
std::vector<std::string> configs;
@@ -651,7 +667,7 @@ std::string cmLocalGenerator::ConvertToIncludeReference(
}
std::string cmLocalGenerator::GetIncludeFlags(
- const std::vector<std::string>& includes, cmGeneratorTarget* target,
+ const std::vector<std::string>& includeDirs, cmGeneratorTarget* target,
const std::string& lang, bool forceFullPaths, bool forResponseFile,
const std::string& config)
{
@@ -659,6 +675,9 @@ std::string cmLocalGenerator::GetIncludeFlags(
return "";
}
+ std::vector<std::string> includes = includeDirs;
+ this->MoveSystemIncludesToEnd(includes, config, lang, target);
+
OutputFormat shellFormat = forResponseFile ? RESPONSE : SHELL;
std::ostringstream includeFlags;
@@ -924,6 +943,8 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
}
}
+ this->MoveSystemIncludesToEnd(dirs, config, lang, target);
+
// Add standard include directories for this language.
// We do not filter out implicit directories here.
std::string const standardIncludesVar =
diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h
index 533ac56..9ba62cc 100644
--- a/Source/cmLocalGenerator.h
+++ b/Source/cmLocalGenerator.h
@@ -411,6 +411,10 @@ private:
int targetType);
void ComputeObjectMaxPath();
+ void MoveSystemIncludesToEnd(std::vector<std::string>& includeDirs,
+ const std::string& config,
+ const std::string& lang,
+ cmGeneratorTarget const* target) const;
};
#if defined(CMAKE_BUILD_WITH_CMAKE)