diff options
author | Brad King <brad.king@kitware.com> | 2018-04-24 15:04:20 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-04-24 15:05:12 (GMT) |
commit | b928be62fa403403ba5d8bc7521b5a8ae5ff54cf (patch) | |
tree | 0f1f1b2ac6bb24d19ac6a503b4b51e56b328d83a /Source | |
parent | 1ec112c70de1718464074febdad16ede4da4a12f (diff) | |
parent | 76ad2ecb500c8652e59179959b8ecee28a5196de (diff) | |
download | CMake-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.cxx | 23 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 4 |
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) |