diff options
author | Brad King <brad.king@kitware.com> | 2019-02-19 12:53:50 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2019-02-19 12:54:57 (GMT) |
commit | 2dd2079152ceda32a7e5f330f7182fd658716c41 (patch) | |
tree | 685ca9abc7cd2e4a57c0deee93ff07e084d0953c /Source/cmLocalGenerator.cxx | |
parent | bc34282da63c3f25c17fee73c97fcc46a0a164ca (diff) | |
parent | 890bae524c6b97d29ffcc3fe5a6a30235d800348 (diff) | |
download | CMake-2dd2079152ceda32a7e5f330f7182fd658716c41.zip CMake-2dd2079152ceda32a7e5f330f7182fd658716c41.tar.gz CMake-2dd2079152ceda32a7e5f330f7182fd658716c41.tar.bz2 |
Merge topic 'fix-legacy-implicit-includes'
890bae524c Do not explicitly report "standard" include directories as implicit
5c171ca898 Restore unconditional use of "standard" include directories
9502276f82 Prefix implicit include directories with sysroot on construction
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !2981
Diffstat (limited to 'Source/cmLocalGenerator.cxx')
-rw-r--r-- | Source/cmLocalGenerator.cxx | 61 |
1 files changed, 27 insertions, 34 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index a2d0efe..03077b3 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; @@ -928,24 +942,21 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit( return (implicitSet.find(dir) == implicitSet.end()); }; { - std::string rootPath; - if (const char* sysrootCompile = - this->Makefile->GetDefinition("CMAKE_SYSROOT_COMPILE")) { - rootPath = sysrootCompile; - } else { - rootPath = this->Makefile->GetSafeDefinition("CMAKE_SYSROOT"); - } - cmSystemTools::ConvertToUnixSlashes(rootPath); - // 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, @@ -965,13 +976,8 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit( } for (std::string const& i : impDirVec) { - std::string imd = i; - cmSystemTools::ConvertToUnixSlashes(imd); - if (!rootPath.empty() && !cmHasPrefix(imd, rootPath)) { - imd = rootPath + imd; - } - if (implicitSet.insert(imd).second) { - implicitDirs.emplace_back(std::move(imd)); + if (implicitSet.insert(i).second) { + implicitDirs.emplace_back(i); } } } @@ -1010,23 +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); - if (notImplicit(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 |