Commit f16dfdf7 authored by Sebastian Holtermann's avatar Sebastian Holtermann Committed by Brad King
Browse files

cmLocalGenerator: Simplify `GetIncludeDirectories`

This patch strips the `stripImplicitDirs` and `appendAllImplicitDirs`
parameters from the `cmLocalGenerator::GetIncludeDirectories` method and makes
it a wrapper into the new `cmLocalGenerator::GetIncludeDirectoriesImplicit`
method.  `cmLocalGenerator::GetIncludeDirectoriesImplicit` is the renamed old
implementation of `cmLocalGenerator::GetIncludeDirectories` and still
accepts `stripImplicitDirs` and `appendAllImplicitDirs`.

The motivation is that there's only *one* case where
`cmLocalGenerator::GetIncludeDirectories` is called with the
`stripImplicitDirs` parameter being `false` (QtAutoGen), but many other places
where it is called using the `true` default value.

QtAutoGen is modified to use `cmLocalGenerator::GetIncludeDirectoriesImplicit`
directly.  In two use cases of `cmLocalGenerator::GetIncludeDirectories`
the manually set `true` value for `stripImplicitDirs` is removed.
parent 8e495333
......@@ -727,7 +727,7 @@ void Target::ProcessLanguage(std::string const& lang)
lg->GetTargetDefines(this->GT, this->Config, lang);
cd.SetDefines(defines);
std::vector<BT<std::string>> includePathList =
lg->GetIncludeDirectories(this->GT, lang, this->Config, true);
lg->GetIncludeDirectories(this->GT, lang, this->Config);
for (BT<std::string> const& i : includePathList) {
cd.Includes.emplace_back(
i, this->GT->IsSystemIncludeDirectory(i.Value, this->Config, lang));
......
......@@ -578,7 +578,7 @@ static Json::Value DumpTarget(cmGeneratorTarget* target,
lg->GetTargetDefines(target, config, lang, defines);
ld.SetDefines(defines);
std::vector<std::string> includePathList;
lg->GetIncludeDirectories(includePathList, target, lang, config, true);
lg->GetIncludeDirectories(includePathList, target, lang, config);
for (std::string const& i : includePathList) {
ld.IncludePathList.emplace_back(
i, target->IsSystemIncludeDirectory(i, config, lang));
......
......@@ -881,22 +881,7 @@ void cmLocalGenerator::AddCompileOptions(std::string& flags,
this->AddCompilerRequirementFlag(flags, target, lang);
}
void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
cmGeneratorTarget const* target,
const std::string& lang,
const std::string& config,
bool stripImplicitDirs,
bool appendAllImplicitDirs) const
{
std::vector<BT<std::string>> tmp = this->GetIncludeDirectories(
target, lang, config, stripImplicitDirs, appendAllImplicitDirs);
dirs.reserve(tmp.size());
for (BT<std::string>& v : tmp) {
dirs.emplace_back(std::move(v.Value));
}
}
std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectories(
std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
cmGeneratorTarget const* target, std::string const& lang,
std::string const& config, bool stripImplicitDirs,
bool appendAllImplicitDirs) const
......@@ -1043,6 +1028,34 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectories(
return result;
}
void cmLocalGenerator::GetIncludeDirectoriesImplicit(
std::vector<std::string>& dirs, cmGeneratorTarget const* target,
const std::string& lang, const std::string& config, bool stripImplicitDirs,
bool appendAllImplicitDirs) const
{
std::vector<BT<std::string>> tmp = this->GetIncludeDirectoriesImplicit(
target, lang, config, stripImplicitDirs, appendAllImplicitDirs);
dirs.reserve(dirs.size() + tmp.size());
for (BT<std::string>& v : tmp) {
dirs.emplace_back(std::move(v.Value));
}
}
std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectories(
cmGeneratorTarget const* target, std::string const& lang,
std::string const& config) const
{
return this->GetIncludeDirectoriesImplicit(target, lang, config);
}
void cmLocalGenerator::GetIncludeDirectories(std::vector<std::string>& dirs,
cmGeneratorTarget const* target,
const std::string& lang,
const std::string& config) const
{
this->GetIncludeDirectoriesImplicit(dirs, target, lang, config);
}
void cmLocalGenerator::GetStaticLibraryFlags(std::string& flags,
std::string const& config,
std::string const& linkLanguage,
......
......@@ -239,22 +239,46 @@ public:
return true;
}
/** @brief Get the include directories for the current makefile and language.
/** @brief Get the include directories for the current makefile and language
* and optional the compiler implicit include directories.
*
* @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.
*/
std::vector<BT<std::string>> GetIncludeDirectoriesImplicit(
cmGeneratorTarget const* target, std::string const& lang = "C",
std::string const& config = "", bool stripImplicitDirs = true,
bool appendAllImplicitDirs = false) const;
/** @brief Get the include directories for the current makefile and language
* and optional the compiler implicit include directories.
*
* @arg dirs Directories are appended to this list
*/
void GetIncludeDirectoriesImplicit(std::vector<std::string>& dirs,
cmGeneratorTarget const* target,
const std::string& lang = "C",
const std::string& config = "",
bool stripImplicitDirs = true,
bool appendAllImplicitDirs = false) const;
/** @brief Get the include directories for the current makefile and language.
* @arg dirs Include directories are appended to this list
*/
void GetIncludeDirectories(std::vector<std::string>& dirs,
cmGeneratorTarget const* target,
const std::string& lang = "C",
const std::string& config = "",
bool stripImplicitDirs = true,
bool appendAllImplicitDirs = false) const;
const std::string& config = "") const;
/** @brief Get the include directories for the current makefile and language.
* @return The include directory list
*/
std::vector<BT<std::string>> GetIncludeDirectories(
cmGeneratorTarget const* target, std::string const& lang = "C",
std::string const& config = "", bool stripImplicitDirs = true,
bool appendAllImplicitDirs = false) const;
std::string const& config = "") const;
void AddCompileOptions(std::string& flags, cmGeneratorTarget* target,
const std::string& lang, const std::string& config);
......
......@@ -531,8 +531,8 @@ bool cmQtAutoGenInitializer::InitMoc()
// include dirs off, see
// https://gitlab.kitware.com/cmake/cmake/issues/13667
std::vector<std::string> dirs;
localGen->GetIncludeDirectories(dirs, this->Target, "CXX", cfg, false,
appendImplicit);
localGen->GetIncludeDirectoriesImplicit(dirs, this->Target, "CXX", cfg,
false, appendImplicit);
return dirs;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment