mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-01 20:00:51 -05:00
cmTarget: Factor out FinalizeTargetCompileInfo()
This commit is contained in:
@@ -14,6 +14,7 @@
|
|||||||
#include <utility>
|
#include <utility>
|
||||||
|
|
||||||
#include <cm/memory>
|
#include <cm/memory>
|
||||||
|
#include <cm/optional>
|
||||||
#include <cmext/algorithm>
|
#include <cmext/algorithm>
|
||||||
#include <cmext/string_view>
|
#include <cmext/string_view>
|
||||||
|
|
||||||
@@ -1848,39 +1849,14 @@ void cmGlobalGenerator::FinalizeTargetCompileInfo()
|
|||||||
|
|
||||||
// Construct per-target generator information.
|
// Construct per-target generator information.
|
||||||
for (const auto& mf : this->Makefiles) {
|
for (const auto& mf : this->Makefiles) {
|
||||||
const cmBTStringRange noconfig_compile_definitions =
|
const cmBTStringRange noConfigCompileDefinitions =
|
||||||
mf->GetCompileDefinitionsEntries();
|
mf->GetCompileDefinitionsEntries();
|
||||||
|
cm::optional<std::map<std::string, cmValue>> perConfigCompileDefinitions;
|
||||||
|
|
||||||
for (auto& target : mf->GetTargets()) {
|
for (auto& target : mf->GetTargets()) {
|
||||||
cmTarget* t = &target.second;
|
cmTarget* t = &target.second;
|
||||||
if (t->GetType() == cmStateEnums::GLOBAL_TARGET) {
|
t->FinalizeTargetCompileInfo(noConfigCompileDefinitions,
|
||||||
continue;
|
perConfigCompileDefinitions);
|
||||||
}
|
|
||||||
|
|
||||||
t->AppendBuildInterfaceIncludes();
|
|
||||||
|
|
||||||
if (t->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto const& def : noconfig_compile_definitions) {
|
|
||||||
t->InsertCompileDefinition(def);
|
|
||||||
}
|
|
||||||
|
|
||||||
cmPolicies::PolicyStatus polSt =
|
|
||||||
mf->GetPolicyStatus(cmPolicies::CMP0043);
|
|
||||||
if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD) {
|
|
||||||
std::vector<std::string> configs =
|
|
||||||
mf->GetGeneratorConfigs(cmMakefile::ExcludeEmptyConfig);
|
|
||||||
|
|
||||||
for (std::string const& c : configs) {
|
|
||||||
std::string defPropName =
|
|
||||||
cmStrCat("COMPILE_DEFINITIONS_", cmSystemTools::UpperCase(c));
|
|
||||||
if (cmValue val = mf->GetProperty(defPropName)) {
|
|
||||||
t->AppendProperty(defPropName, *val);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// The standard include directories for each language
|
// The standard include directories for each language
|
||||||
|
|||||||
@@ -1881,6 +1881,51 @@ void cmTarget::AppendBuildInterfaceIncludes()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void cmTarget::FinalizeTargetCompileInfo(
|
||||||
|
const cmBTStringRange& noConfigCompileDefinitions,
|
||||||
|
cm::optional<std::map<std::string, cmValue>>& perConfigCompileDefinitions)
|
||||||
|
{
|
||||||
|
if (this->GetType() == cmStateEnums::GLOBAL_TARGET) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->AppendBuildInterfaceIncludes();
|
||||||
|
|
||||||
|
if (this->GetType() == cmStateEnums::INTERFACE_LIBRARY) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (auto const& def : noConfigCompileDefinitions) {
|
||||||
|
this->InsertCompileDefinition(def);
|
||||||
|
}
|
||||||
|
|
||||||
|
auto* mf = this->GetMakefile();
|
||||||
|
cmPolicies::PolicyStatus polSt = mf->GetPolicyStatus(cmPolicies::CMP0043);
|
||||||
|
if (polSt == cmPolicies::WARN || polSt == cmPolicies::OLD) {
|
||||||
|
if (perConfigCompileDefinitions) {
|
||||||
|
for (auto const& it : *perConfigCompileDefinitions) {
|
||||||
|
if (cmValue val = it.second) {
|
||||||
|
this->AppendProperty(it.first, *val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
perConfigCompileDefinitions.emplace();
|
||||||
|
std::vector<std::string> configs =
|
||||||
|
mf->GetGeneratorConfigs(cmMakefile::ExcludeEmptyConfig);
|
||||||
|
|
||||||
|
for (std::string const& c : configs) {
|
||||||
|
std::string defPropName =
|
||||||
|
cmStrCat("COMPILE_DEFINITIONS_", cmSystemTools::UpperCase(c));
|
||||||
|
cmValue val = mf->GetProperty(defPropName);
|
||||||
|
(*perConfigCompileDefinitions)[defPropName] = val;
|
||||||
|
if (val) {
|
||||||
|
this->AppendProperty(defPropName, *val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void cmTarget::InsertInclude(BT<std::string> const& entry, bool before)
|
void cmTarget::InsertInclude(BT<std::string> const& entry, bool before)
|
||||||
{
|
{
|
||||||
auto position = before ? this->impl->IncludeDirectoriesEntries.begin()
|
auto position = before ? this->impl->IncludeDirectoriesEntries.begin()
|
||||||
|
|||||||
@@ -5,12 +5,15 @@
|
|||||||
#include "cmConfigure.h" // IWYU pragma: keep
|
#include "cmConfigure.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include <iosfwd>
|
#include <iosfwd>
|
||||||
|
#include <map>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include <set>
|
#include <set>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
#include <cm/optional>
|
||||||
|
|
||||||
#include "cmAlgorithms.h"
|
#include "cmAlgorithms.h"
|
||||||
#include "cmFileSet.h"
|
#include "cmFileSet.h"
|
||||||
#include "cmPolicies.h"
|
#include "cmPolicies.h"
|
||||||
@@ -233,6 +236,9 @@ public:
|
|||||||
void InsertPrecompileHeader(BT<std::string> const& entry);
|
void InsertPrecompileHeader(BT<std::string> const& entry);
|
||||||
|
|
||||||
void AppendBuildInterfaceIncludes();
|
void AppendBuildInterfaceIncludes();
|
||||||
|
void FinalizeTargetCompileInfo(
|
||||||
|
const cmBTStringRange& noConfigCompileDefinitions,
|
||||||
|
cm::optional<std::map<std::string, cmValue>>& perConfigCompileDefinitions);
|
||||||
|
|
||||||
std::string GetDebugGeneratorExpressions(const std::string& value,
|
std::string GetDebugGeneratorExpressions(const std::string& value,
|
||||||
cmTargetLinkLibraryType llt) const;
|
cmTargetLinkLibraryType llt) const;
|
||||||
|
|||||||
Reference in New Issue
Block a user