Commit aaf3859e authored by Brad King's avatar Brad King Committed by Kitware Robot

Merge topic 'refactor-usage-requirements'

2682714a cmGeneratorTarget: Refactor usage requirement genex evaluation
3cbc1577 cmGeneratorTarget: Move static functions to anonymous namespace
33494a50 cmGeneratorTarget: Order usage requirement processing logic consistently
c131e62f cmGeneratorTarget: Remove unnecessary copy to local variable
fab72918 cmGeneratorTarget: Remove unused member of internal class
95d3598e cmGeneratorExpressionDAGChecker: Avoid const_cast
Acked-by: Kitware Robot's avatarKitware Robot <kwrobot@kitware.com>
Acked-by: Marc Chevrier's avatarMarc Chevrier <marc.chevrier@gmail.com>
Merge-request: !3578
parents 9e420754 2682714a
Pipeline #141806 failed with stage
in 0 seconds
......@@ -68,9 +68,7 @@ void cmGeneratorExpressionDAGChecker::Initialize()
return;
}
}
const_cast<cmGeneratorExpressionDAGChecker*>(top)
->Seen[this->Target]
.insert(this->Property);
top->Seen[this->Target].insert(this->Property);
}
}
......
......@@ -88,7 +88,7 @@ private:
const cmGeneratorExpressionDAGChecker* const Parent;
cmGeneratorTarget const* Target;
const std::string Property;
std::map<cmGeneratorTarget const*, std::set<std::string>> Seen;
mutable std::map<cmGeneratorTarget const*, std::set<std::string>> Seen;
const GeneratorExpressionContent* const Content;
const cmListFileBacktrace Backtrace;
Result CheckResult;
......
......@@ -92,9 +92,6 @@ public:
virtual bool GetHadContextSensitiveCondition() const { return false; }
cmLinkImplItem const& LinkImplItem;
private:
cmListFileBacktrace Backtrace;
};
cmLinkImplItem cmGeneratorTarget::TargetPropertyEntry::NoLinkImplItem;
......@@ -209,6 +206,63 @@ void CreatePropertyGeneratorExpressions(
}
}
namespace {
// Represent a target property entry after evaluating generator expressions
// and splitting up lists.
struct EvaluatedTargetPropertyEntry
{
EvaluatedTargetPropertyEntry(cmLinkImplItem const& item,
cmListFileBacktrace bt)
: LinkImplItem(item)
, Backtrace(std::move(bt))
{
}
// Move-only.
EvaluatedTargetPropertyEntry(EvaluatedTargetPropertyEntry&&) = default;
EvaluatedTargetPropertyEntry(EvaluatedTargetPropertyEntry const&) = delete;
EvaluatedTargetPropertyEntry& operator=(EvaluatedTargetPropertyEntry&&) =
delete;
EvaluatedTargetPropertyEntry& operator=(
EvaluatedTargetPropertyEntry const&) = delete;
cmLinkImplItem const& LinkImplItem;
cmListFileBacktrace Backtrace;
std::vector<std::string> Values;
bool ContextDependent = false;
};
EvaluatedTargetPropertyEntry EvaluateTargetPropertyEntry(
cmGeneratorTarget const* thisTarget, std::string const& config,
std::string const& lang, cmGeneratorExpressionDAGChecker* dagChecker,
cmGeneratorTarget::TargetPropertyEntry* entry)
{
EvaluatedTargetPropertyEntry ee(entry->LinkImplItem, entry->GetBacktrace());
cmSystemTools::ExpandListArgument(
entry->Evaluate(thisTarget->GetLocalGenerator(), config, false, thisTarget,
dagChecker, lang),
ee.Values);
if (entry->GetHadContextSensitiveCondition()) {
ee.ContextDependent = true;
}
return ee;
}
std::vector<EvaluatedTargetPropertyEntry> EvaluateTargetPropertyEntries(
cmGeneratorTarget const* thisTarget, std::string const& config,
std::string const& lang, cmGeneratorExpressionDAGChecker* dagChecker,
std::vector<cmGeneratorTarget::TargetPropertyEntry*> const& in)
{
std::vector<EvaluatedTargetPropertyEntry> out;
out.reserve(in.size());
for (cmGeneratorTarget::TargetPropertyEntry* entry : in) {
out.emplace_back(EvaluateTargetPropertyEntry(thisTarget, config, lang,
dagChecker, entry));
}
return out;
}
}
cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg)
: Target(t)
, FortranModuleDirectoryCreated(false)
......@@ -654,12 +708,14 @@ std::vector<cmSourceFile*> const* cmGeneratorTarget::GetSourceDepends(
return nullptr;
}
static void handleSystemIncludesDep(
cmLocalGenerator* lg, cmGeneratorTarget const* depTgt,
const std::string& config, cmGeneratorTarget const* headTarget,
namespace {
void handleSystemIncludesDep(cmLocalGenerator* lg,
cmGeneratorTarget const* depTgt,
const std::string& config,
cmGeneratorTarget const* headTarget,
cmGeneratorExpressionDAGChecker* dagChecker,
std::vector<std::string>& result, bool excludeImported,
std::string const& language)
std::vector<std::string>& result,
bool excludeImported, std::string const& language)
{
if (const char* dirs =
depTgt->GetProperty("INTERFACE_SYSTEM_INCLUDE_DIRECTORIES")) {
......@@ -682,6 +738,7 @@ static void handleSystemIncludesDep(
result);
}
}
}
/* clang-format off */
#define IMPLEMENT_VISIT(KIND) \
......@@ -1084,77 +1141,91 @@ bool cmGeneratorTarget::GetPropertyAsBool(const std::string& prop) const
return this->Target->GetPropertyAsBool(prop);
}
static void AddInterfaceEntries(
cmGeneratorTarget const* thisTarget, std::string const& config,
std::string const& prop,
std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries)
namespace {
void AddInterfaceEntries(cmGeneratorTarget const* headTarget,
std::string const& config, std::string const& prop,
std::string const& lang,
cmGeneratorExpressionDAGChecker* dagChecker,
std::vector<EvaluatedTargetPropertyEntry>& entries)
{
if (cmLinkImplementationLibraries const* impl =
thisTarget->GetLinkImplementationLibraries(config)) {
headTarget->GetLinkImplementationLibraries(config)) {
for (cmLinkImplItem const& lib : impl->Libraries) {
if (lib.Target) {
std::string uniqueName =
thisTarget->GetGlobalGenerator()->IndexGeneratorTargetUniquely(
headTarget->GetGlobalGenerator()->IndexGeneratorTargetUniquely(
lib.Target);
std::string genex =
"$<TARGET_PROPERTY:" + std::move(uniqueName) + "," + prop + ">";
cmGeneratorExpression ge(lib.Backtrace);
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(genex);
cge->SetEvaluateForBuildsystem(true);
entries.push_back(new TargetPropertyEntryGenex(std::move(cge), lib));
EvaluatedTargetPropertyEntry ee(lib, lib.Backtrace);
cmSystemTools::ExpandListArgument(
cge->Evaluate(headTarget->GetLocalGenerator(), config, false,
headTarget, dagChecker, lang),
ee.Values);
if (cge->GetHadContextSensitiveCondition()) {
ee.ContextDependent = true;
}
entries.emplace_back(std::move(ee));
}
}
}
}
static void AddObjectEntries(
cmGeneratorTarget const* thisTarget, std::string const& config,
std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries)
void AddObjectEntries(cmGeneratorTarget const* headTarget,
std::string const& config,
cmGeneratorExpressionDAGChecker* dagChecker,
std::vector<EvaluatedTargetPropertyEntry>& entries)
{
if (cmLinkImplementationLibraries const* impl =
thisTarget->GetLinkImplementationLibraries(config)) {
headTarget->GetLinkImplementationLibraries(config)) {
for (cmLinkImplItem const& lib : impl->Libraries) {
if (lib.Target &&
lib.Target->GetType() == cmStateEnums::OBJECT_LIBRARY) {
std::string uniqueName =
thisTarget->GetGlobalGenerator()->IndexGeneratorTargetUniquely(
headTarget->GetGlobalGenerator()->IndexGeneratorTargetUniquely(
lib.Target);
std::string genex = "$<TARGET_OBJECTS:" + std::move(uniqueName) + ">";
cmGeneratorExpression ge(lib.Backtrace);
std::unique_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(genex);
cge->SetEvaluateForBuildsystem(true);
entries.push_back(new TargetPropertyEntryGenex(std::move(cge), lib));
EvaluatedTargetPropertyEntry ee(lib, lib.Backtrace);
cmSystemTools::ExpandListArgument(
cge->Evaluate(headTarget->GetLocalGenerator(), config, false,
headTarget, dagChecker),
ee.Values);
if (cge->GetHadContextSensitiveCondition()) {
ee.ContextDependent = true;
}
entries.emplace_back(std::move(ee));
}
}
}
}
static bool processSources(
cmGeneratorTarget const* tgt,
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
bool processSources(cmGeneratorTarget const* tgt,
std::vector<EvaluatedTargetPropertyEntry>& entries,
std::vector<BT<std::string>>& srcs,
std::unordered_set<std::string>& uniqueSrcs,
cmGeneratorExpressionDAGChecker* dagChecker, std::string const& config,
bool debugSources)
{
cmMakefile* mf = tgt->Target->GetMakefile();
bool contextDependent = false;
for (cmGeneratorTarget::TargetPropertyEntry* entry : entries) {
cmLinkImplItem const& item = entry->LinkImplItem;
std::string const& targetName = item.AsStr();
std::vector<std::string> entrySources;
cmSystemTools::ExpandListArgument(entry->Evaluate(tgt->GetLocalGenerator(),
config, false, tgt, tgt,
dagChecker),
entrySources);
if (entry->GetHadContextSensitiveCondition()) {
for (EvaluatedTargetPropertyEntry& entry : entries) {
if (entry.ContextDependent) {
contextDependent = true;
}
for (std::string& src : entrySources) {
cmLinkImplItem const& item = entry.LinkImplItem;
std::string const& targetName = item.AsStr();
for (std::string& src : entry.Values) {
cmSourceFile* sf = mf->GetOrCreateSource(src);
std::string e;
std::string fullPath = sf->GetFullPath(&e);
......@@ -1183,9 +1254,9 @@ static bool processSources(
src = fullPath;
}
std::string usedSources;
for (std::string const& src : entrySources) {
for (std::string const& src : entry.Values) {
if (uniqueSrcs.insert(src).second) {
srcs.emplace_back(src, entry->GetBacktrace());
srcs.emplace_back(src, entry.Backtrace);
if (debugSources) {
usedSources += " * " + src + "\n";
}
......@@ -1196,11 +1267,12 @@ static bool processSources(
MessageType::LOG,
std::string("Used sources for target ") + tgt->GetName() + ":\n" +
usedSources,
entry->GetBacktrace());
entry.Backtrace);
}
}
return contextDependent;
}
}
std::vector<BT<std::string>> cmGeneratorTarget::GetSourceFilePaths(
std::string const& config) const
......@@ -1248,28 +1320,28 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetSourceFilePaths(
cmGeneratorExpressionDAGChecker dagChecker(this, "SOURCES", nullptr,
nullptr);
std::vector<EvaluatedTargetPropertyEntry> entries =
EvaluateTargetPropertyEntries(this, config, std::string(), &dagChecker,
this->SourceEntries);
std::unordered_set<std::string> uniqueSrcs;
bool contextDependentDirectSources =
processSources(this, this->SourceEntries, files, uniqueSrcs, &dagChecker,
config, debugSources);
processSources(this, entries, files, uniqueSrcs, debugSources);
// Collect INTERFACE_SOURCES of all direct link-dependencies.
std::vector<cmGeneratorTarget::TargetPropertyEntry*>
linkInterfaceSourcesEntries;
AddInterfaceEntries(this, config, "INTERFACE_SOURCES",
linkInterfaceSourcesEntries);
std::vector<EvaluatedTargetPropertyEntry> linkInterfaceSourcesEntries;
AddInterfaceEntries(this, config, "INTERFACE_SOURCES", std::string(),
&dagChecker, linkInterfaceSourcesEntries);
std::vector<std::string>::size_type numFilesBefore = files.size();
bool contextDependentInterfaceSources =
processSources(this, linkInterfaceSourcesEntries, files, uniqueSrcs,
&dagChecker, config, debugSources);
bool contextDependentInterfaceSources = processSources(
this, linkInterfaceSourcesEntries, files, uniqueSrcs, debugSources);
// Collect TARGET_OBJECTS of direct object link-dependencies.
std::vector<cmGeneratorTarget::TargetPropertyEntry*> linkObjectsEntries;
AddObjectEntries(this, config, linkObjectsEntries);
std::vector<EvaluatedTargetPropertyEntry> linkObjectsEntries;
AddObjectEntries(this, config, &dagChecker, linkObjectsEntries);
std::vector<std::string>::size_type numFilesBefore2 = files.size();
bool contextDependentObjects =
processSources(this, linkObjectsEntries, files, uniqueSrcs, &dagChecker,
config, debugSources);
processSources(this, linkObjectsEntries, files, uniqueSrcs, debugSources);
if (!contextDependentDirectSources &&
!(contextDependentInterfaceSources && numFilesBefore < files.size()) &&
......@@ -1277,8 +1349,6 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetSourceFilePaths(
this->LinkImplementationLanguageIsContextDependent = false;
}
cmDeleteAll(linkInterfaceSourcesEntries);
cmDeleteAll(linkObjectsEntries);
return files;
}
......@@ -1855,16 +1925,17 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const
return this->GetLibraryNames(config).SharedObject;
}
static bool shouldAddFullLevel(cmGeneratorTarget::BundleDirectoryLevel level)
namespace {
bool shouldAddFullLevel(cmGeneratorTarget::BundleDirectoryLevel level)
{
return level == cmGeneratorTarget::FullLevel;
}
static bool shouldAddContentLevel(
cmGeneratorTarget::BundleDirectoryLevel level)
bool shouldAddContentLevel(cmGeneratorTarget::BundleDirectoryLevel level)
{
return level == cmGeneratorTarget::ContentLevel || shouldAddFullLevel(level);
}
}
std::string cmGeneratorTarget::GetAppBundleDirectory(
const std::string& config, BundleDirectoryLevel level) const
......@@ -2767,27 +2838,22 @@ std::string cmGeneratorTarget::GetCreateRuleVariable(
}
return "";
}
static void processIncludeDirectories(
namespace {
void processIncludeDirectories(
cmGeneratorTarget const* tgt,
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
std::vector<EvaluatedTargetPropertyEntry>& entries,
std::vector<BT<std::string>>& includes,
std::unordered_set<std::string>& uniqueIncludes,
cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
bool debugIncludes, const std::string& language)
std::unordered_set<std::string>& uniqueIncludes, bool debugIncludes)
{
for (cmGeneratorTarget::TargetPropertyEntry* entry : entries) {
cmLinkImplItem const& item = entry->LinkImplItem;
for (EvaluatedTargetPropertyEntry& entry : entries) {
cmLinkImplItem const& item = entry.LinkImplItem;
std::string const& targetName = item.AsStr();
bool const fromImported = item.Target && item.Target->IsImported();
bool const checkCMP0027 = item.FromGenex;
std::vector<std::string> entryIncludes;
cmSystemTools::ExpandListArgument(entry->Evaluate(tgt->GetLocalGenerator(),
config, false, tgt,
dagChecker, language),
entryIncludes);
std::string usedIncludes;
for (std::string& entryInclude : entryIncludes) {
for (std::string& entryInclude : entry.Values) {
if (fromImported && !cmSystemTools::FileExists(entryInclude)) {
std::ostringstream e;
MessageType messageType = MessageType::FATAL_ERROR;
......@@ -2859,12 +2925,11 @@ static void processIncludeDirectories(
if (!cmSystemTools::IsOff(entryInclude)) {
cmSystemTools::ConvertToUnixSlashes(entryInclude);
}
std::string inc = entryInclude;
if (uniqueIncludes.insert(inc).second) {
includes.emplace_back(inc, entry->GetBacktrace());
if (uniqueIncludes.insert(entryInclude).second) {
includes.emplace_back(entryInclude, entry.Backtrace);
if (debugIncludes) {
usedIncludes += " * " + inc + "\n";
usedIncludes += " * " + entryInclude + "\n";
}
}
}
......@@ -2873,10 +2938,11 @@ static void processIncludeDirectories(
MessageType::LOG,
std::string("Used includes for target ") + tgt->GetName() + ":\n" +
usedIncludes,
entry->GetBacktrace());
entry.Backtrace);
}
}
}
}
std::vector<BT<std::string>> cmGeneratorTarget::GetIncludeDirectories(
const std::string& config, const std::string& lang) const
......@@ -2902,14 +2968,12 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetIncludeDirectories(
this->DebugIncludesDone = true;
}
processIncludeDirectories(this, this->IncludeDirectoriesEntries, includes,
uniqueIncludes, &dagChecker, config, debugIncludes,
lang);
std::vector<EvaluatedTargetPropertyEntry> entries =
EvaluateTargetPropertyEntries(this, config, lang, &dagChecker,
this->IncludeDirectoriesEntries);
std::vector<cmGeneratorTarget::TargetPropertyEntry*>
linkInterfaceIncludeDirectoriesEntries;
AddInterfaceEntries(this, config, "INTERFACE_INCLUDE_DIRECTORIES",
linkInterfaceIncludeDirectoriesEntries);
AddInterfaceEntries(this, config, "INTERFACE_INCLUDE_DIRECTORIES", lang,
&dagChecker, entries);
if (this->Makefile->IsOn("APPLE")) {
cmLinkImplementationLibraries const* impl =
......@@ -2925,16 +2989,14 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetIncludeDirectories(
libDir = frameworkCheck.match(1);
linkInterfaceIncludeDirectoriesEntries.push_back(
CreateTargetPropertyEntry(libDir));
EvaluatedTargetPropertyEntry ee(lib, cmListFileBacktrace());
ee.Values.emplace_back(std::move(libDir));
entries.emplace_back(std::move(ee));
}
}
processIncludeDirectories(this, linkInterfaceIncludeDirectoriesEntries,
includes, uniqueIncludes, &dagChecker, config,
debugIncludes, lang);
cmDeleteAll(linkInterfaceIncludeDirectoriesEntries);
processIncludeDirectories(this, entries, includes, uniqueIncludes,
debugIncludes);
return includes;
}
......@@ -2945,33 +3007,26 @@ enum class OptionsParse
Shell
};
static void processOptionsInternal(
cmGeneratorTarget const* tgt,
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
namespace {
void processOptions(cmGeneratorTarget const* tgt,
std::vector<EvaluatedTargetPropertyEntry> const& entries,
std::vector<BT<std::string>>& options,
std::unordered_set<std::string>& uniqueOptions,
cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
bool debugOptions, const char* logName, std::string const& language,
OptionsParse parse)
{
for (cmGeneratorTarget::TargetPropertyEntry* entry : entries) {
std::vector<std::string> entryOptions;
cmSystemTools::ExpandListArgument(entry->Evaluate(tgt->GetLocalGenerator(),
config, false, tgt,
dagChecker, language),
entryOptions);
bool debugOptions, const char* logName, OptionsParse parse)
{
for (EvaluatedTargetPropertyEntry const& entry : entries) {
std::string usedOptions;
for (std::string const& opt : entryOptions) {
for (std::string const& opt : entry.Values) {
if (uniqueOptions.insert(opt).second) {
if (parse == OptionsParse::Shell &&
cmHasLiteralPrefix(opt, "SHELL:")) {
std::vector<std::string> tmp;
cmSystemTools::ParseUnixCommandLine(opt.c_str() + 6, tmp);
for (std::string& o : tmp) {
options.emplace_back(std::move(o), entry->GetBacktrace());
options.emplace_back(std::move(o), entry.Backtrace);
}
} else {
options.emplace_back(opt, entry->GetBacktrace());
options.emplace_back(opt, entry.Backtrace);
}
if (debugOptions) {
usedOptions += " * " + opt + "\n";
......@@ -2983,22 +3038,10 @@ static void processOptionsInternal(
MessageType::LOG,
std::string("Used ") + logName + std::string(" for target ") +
tgt->GetName() + ":\n" + usedOptions,
entry->GetBacktrace());
entry.Backtrace);
}
}
}
static void processCompileOptions(
cmGeneratorTarget const* tgt,
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
std::vector<BT<std::string>>& options,
std::unordered_set<std::string>& uniqueOptions,
cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
bool debugOptions, std::string const& language)
{
processOptionsInternal(tgt, entries, options, uniqueOptions, dagChecker,
config, debugOptions, "compile options", language,
OptionsParse::Shell);
}
void cmGeneratorTarget::GetCompileOptions(std::vector<std::string>& result,
......@@ -3036,37 +3079,19 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileOptions(
this->DebugCompileOptionsDone = true;
}
processCompileOptions(this, this->CompileOptionsEntries, result,
uniqueOptions, &dagChecker, config, debugOptions,
language);
std::vector<cmGeneratorTarget::TargetPropertyEntry*>
linkInterfaceCompileOptionsEntries;
std::vector<EvaluatedTargetPropertyEntry> entries =
EvaluateTargetPropertyEntries(this, config, language, &dagChecker,
this->CompileOptionsEntries);
AddInterfaceEntries(this, config, "INTERFACE_COMPILE_OPTIONS",
linkInterfaceCompileOptionsEntries);
AddInterfaceEntries(this, config, "INTERFACE_COMPILE_OPTIONS", language,
&dagChecker, entries);
processCompileOptions(this, linkInterfaceCompileOptionsEntries, result,
uniqueOptions, &dagChecker, config, debugOptions,
language);
processOptions(this, entries, result, uniqueOptions, debugOptions,
"compile options", OptionsParse::Shell);
cmDeleteAll(linkInterfaceCompileOptionsEntries);
return result;
}
static void processCompileFeatures(
cmGeneratorTarget const* tgt,
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
std::vector<BT<std::string>>& options,
std::unordered_set<std::string>& uniqueOptions,
cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
bool debugOptions)
{
processOptionsInternal(tgt, entries, options, uniqueOptions, dagChecker,
config, debugOptions, "compile features",
std::string(), OptionsParse::None);
}
void cmGeneratorTarget::GetCompileFeatures(std::vector<std::string>& result,
const std::string& config) const
{
......@@ -3101,34 +3126,19 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileFeatures(
this->DebugCompileFeaturesDone = true;
}
processCompileFeatures(this, this->CompileFeaturesEntries, result,
uniqueFeatures, &dagChecker, config, debugFeatures);
std::vector<EvaluatedTargetPropertyEntry> entries =
EvaluateTargetPropertyEntries(this, config, std::string(), &dagChecker,
this->CompileFeaturesEntries);
std::vector<cmGeneratorTarget::TargetPropertyEntry*>
linkInterfaceCompileFeaturesEntries;
AddInterfaceEntries(this, config, "INTERFACE_COMPILE_FEATURES",
linkInterfaceCompileFeaturesEntries);
std::string(), &dagChecker, entries);
processCompileFeatures(this, linkInterfaceCompileFeaturesEntries, result,
uniqueFeatures, &dagChecker, config, debugFeatures);
processOptions(this, entries, result, uniqueFeatures, debugFeatures,
"compile features", OptionsParse::None);
cmDeleteAll(linkInterfaceCompileFeaturesEntries);
return result;
}
static void processCompileDefinitions(
cmGeneratorTarget const* tgt,
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
std::vector<BT<std::string>>& options,
std::unordered_set<std::string>& uniqueOptions,
cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
bool debugOptions, std::string const& language)
{
processOptionsInternal(tgt, entries, options, uniqueOptions, dagChecker,
config, debugOptions, "compile definitions", language,
OptionsParse::None);
}
void cmGeneratorTarget::GetCompileDefinitions(
std::vector<std::string>& result, const std::string& config,
const std::string& language) const
......@@ -3165,14 +3175,13 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileDefinitions(
this->DebugCompileDefinitionsDone = true;
}
processCompileDefinitions(this, this->CompileDefinitionsEntries, list,
uniqueOptions, &dagChecker, config, debugDefines,
language);
std::vector<EvaluatedTargetPropertyEntry> entries =
EvaluateTargetPropertyEntries(this, config, language, &dagChecker,
this->CompileDefinitionsEntries);
AddInterfaceEntries(this, config, "INTERFACE_COMPILE_DEFINITIONS", language,
&dagChecker, entries);
std::vector<cmGeneratorTarget::TargetPropertyEntry*>
linkInterfaceCompileDefinitionsEntries;
AddInterfaceEntries(this, config, "INTERFACE_COMPILE_DEFINITIONS",
linkInterfaceCompileDefinitionsEntries);
if (!config.empty()) {
std::string configPropName =
"COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(config);
......@@ -3187,8 +3196,10 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileDefinitions(
CM_FALLTHROUGH;
}
case cmPolicies::OLD: {
linkInterfaceCompileDefinitionsEntries.push_back(
std::unique_ptr<TargetPropertyEntry> entry(
CreateTargetPropertyEntry(configProp));
entries.emplace_back(EvaluateTargetPropertyEntry(
this, config, language, &dagChecker, entry.get()));
} break;
case cmPolicies::NEW:
case cmPolicies::REQUIRED_ALWAYS:
......@@ -3198,29 +3209,12 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetCompileDefinitions(
}
}
processCompileDefinitions(this, linkInterfaceCompileDefinitionsEntries, list,
uniqueOptions, &dagChecker, config, debugDefines,
language);
processOptions(this, entries, list, uniqueOptions, debugDefines,
"compile definitions", OptionsParse::None);
cmDeleteAll(linkInterfaceCompileDefinitionsEntries);
return list;
}
namespace {
void processLinkOptions(
cmGeneratorTarget const* tgt,
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
std::vector<BT<std::string>>& options,
std::unordered_set<std::string>& uniqueOptions,
cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
bool debugOptions, std::string const& language)
{
processOptionsInternal(tgt, entries, options, uniqueOptions, dagChecker,
config, debugOptions, "link options", language,
OptionsParse::Shell);
}
}
void cmGeneratorTarget::GetLinkOptions(std::vector<std::string>& result,
const std::string& config,
const std::string& language) const
......@@ -3256,20 +3250,15 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkOptions(
this->DebugLinkOptionsDone = true;
}
processLinkOptions(this, this->LinkOptionsEntries, result, uniqueOptions,
&dagChecker, config, debugOptions, language);
std::vector<cmGeneratorTarget::TargetPropertyEntry*>
linkInterfaceLinkOptionsEntries;
AddInterfaceEntries(this, config, "INTERFACE_LINK_OPTIONS",
linkInterfaceLinkOptionsEntries);
std::vector<EvaluatedTargetPropertyEntry> entries =
EvaluateTargetPropertyEntries(this, config, language, &dagChecker,
this->LinkOptionsEntries);
processLinkOptions(this, linkInterfaceLinkOptionsEntries, result,
uniqueOptions, &dagChecker, config, debugOptions,
language);
AddInterfaceEntries(this, config, "INTERFACE_LINK_OPTIONS", language,
&dagChecker, entries);
cmDeleteAll(linkInterfaceLinkOptionsEntries);
processOptions(this, entries, result, uniqueOptions, debugOptions,
"link options", OptionsParse::Shell);
// Last step: replace "LINKER:" prefixed elements by
// actual linker wrapper
......@@ -3375,21 +3364,6 @@ std::vector<BT<std::string>> cmGeneratorTarget::GetLinkOptions(
return result;
}
namespace {
void processStaticLibraryLinkOptions(
cmGeneratorTarget const* tgt,
const std::vector<cmGeneratorTarget::TargetPropertyEntry*>& entries,
std::vector<BT<std::string>>& options,
std::unordered_set<std::string>& uniqueOptions,
cmGeneratorExpressionDAGChecker* dagChecker, const std::string& config,
std::string const& language)
{
processOptionsInternal(tgt, entries, options, uniqueOptions, dagChecker,
config, false, "static library link options",
language, OptionsParse::Shell);
}