diff options
-rw-r--r-- | Source/cmLocalGenerator.cxx | 31 | ||||
-rw-r--r-- | Source/cmLocalGenerator.h | 10 |
2 files changed, 30 insertions, 11 deletions
diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3df701e..647697a 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -844,7 +844,8 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, cmGeneratorTarget const* target, const std::string& lang, const std::string& config, - bool stripImplicitInclDirs) const + bool stripImplicitDirs, + bool appendAllImplicitDirs) const { // Do not repeat an include path. std::set<std::string> emitted; @@ -898,12 +899,12 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, std::vector<std::string> impDirVec; cmSystemTools::ExpandListArgument(value, impDirVec); for (std::string const& i : impDirVec) { - std::string d = rootPath + i; - cmSystemTools::ConvertToUnixSlashes(d); - emitted.insert(std::move(d)); - if (!stripImplicitInclDirs) { - implicitDirs.push_back(i); + { + std::string d = rootPath + i; + cmSystemTools::ConvertToUnixSlashes(d); + emitted.insert(std::move(d)); } + implicitDirs.push_back(i); } } } @@ -958,9 +959,21 @@ void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs, } } - for (std::string const& i : implicitDirs) { - if (std::find(userDirs.begin(), userDirs.end(), i) != userDirs.end()) { - dirs.push_back(i); + if (!stripImplicitDirs) { + if (!appendAllImplicitDirs) { + // Append only those implicit directories that were requested by the user + for (std::string const& i : implicitDirs) { + if (std::find(userDirs.begin(), userDirs.end(), i) != userDirs.end()) { + dirs.push_back(i); + } + } + } else { + // Append all implicit directories + for (std::string const& i : implicitDirs) { + if (std::find(dirs.begin(), dirs.end(), i) == dirs.end()) { + dirs.push_back(i); + } + } } } } diff --git a/Source/cmLocalGenerator.h b/Source/cmLocalGenerator.h index 9ba62cc..52f0396 100644 --- a/Source/cmLocalGenerator.h +++ b/Source/cmLocalGenerator.h @@ -237,12 +237,18 @@ public: return true; } - /** Get the include flags for the current makefile and language. */ + /** @brief Get the include directories for the current makefile and language. + * @arg stripImplicitDirs Strip all directories found in + * CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES from the result. + * @arg appendAllImplicitDirs Append all directories found in + * CMAKE_<LANG>_IMPLICIT_INCLUDE_DIRECTORIES to the result. + */ void GetIncludeDirectories(std::vector<std::string>& dirs, cmGeneratorTarget const* target, const std::string& lang = "C", const std::string& config = "", - bool stripImplicitInclDirs = true) const; + bool stripImplicitDirs = true, + bool appendAllImplicitDirs = false) const; void AddCompileOptions(std::string& flags, cmGeneratorTarget* target, const std::string& lang, const std::string& config); void AddCompileDefinitions(std::set<std::string>& defines, |