diff options
author | Craig Scott <craig.scott@crascit.com> | 2023-04-10 22:05:54 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2023-04-10 22:06:06 (GMT) |
commit | e245b4df7505f2190dbc1442b7ceb94fc507a40e (patch) | |
tree | 4ec32f0f25d3cfa2c76ee04a7545d4361671a1da /Source | |
parent | 453cf8a1968081731b667edd01ff942adf1f7bcc (diff) | |
parent | c5c3aff1f5aa36d44f3c639726dd36eedc28f823 (diff) | |
download | CMake-e245b4df7505f2190dbc1442b7ceb94fc507a40e.zip CMake-e245b4df7505f2190dbc1442b7ceb94fc507a40e.tar.gz CMake-e245b4df7505f2190dbc1442b7ceb94fc507a40e.tar.bz2 |
Merge topic 'automoc-macro-names'
c5c3aff1f5 Autogen: Add INTERFACE_AUTOMOC_MACRO_NAMES target property
69cf9700e6 Autogen: Defer setup until Generate step
7cecb6353e cmGeneratorTarget: Factor out EvaluatedTargetProperty infrastructure
2daba01ddf cmGeneratorTarget: Avoid incidental include-what-you-use warning
850b4d990c IWYU: Add mapping for 'std::remove_reference<Defer &>::type'
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !8391
Diffstat (limited to 'Source')
-rw-r--r-- | Source/CMakeLists.txt | 2 | ||||
-rw-r--r-- | Source/cmEvaluatedTargetProperty.cxx | 111 | ||||
-rw-r--r-- | Source/cmEvaluatedTargetProperty.h | 80 | ||||
-rw-r--r-- | Source/cmExportBuildFileGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmExportInstallFileGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 230 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 22 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 22 | ||||
-rw-r--r-- | Source/cmGlobalGenerator.h | 6 | ||||
-rw-r--r-- | Source/cmQtAutoGenInitializer.cxx | 19 |
10 files changed, 299 insertions, 199 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index b691d38..4a7d9bc 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -193,6 +193,8 @@ add_library( cmDyndepCollation.h cmELF.h cmELF.cxx + cmEvaluatedTargetProperty.cxx + cmEvaluatedTargetProperty.h cmExprParserHelper.cxx cmExportBuildAndroidMKGenerator.h cmExportBuildAndroidMKGenerator.cxx diff --git a/Source/cmEvaluatedTargetProperty.cxx b/Source/cmEvaluatedTargetProperty.cxx new file mode 100644 index 0000000..1173690 --- /dev/null +++ b/Source/cmEvaluatedTargetProperty.cxx @@ -0,0 +1,111 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cmEvaluatedTargetProperty.h" + +#include <unordered_map> +#include <utility> + +#include "cmGeneratorExpressionContext.h" +#include "cmGeneratorTarget.h" +#include "cmLinkItem.h" +#include "cmStringAlgorithms.h" + +struct cmGeneratorExpressionDAGChecker; + +EvaluatedTargetPropertyEntry::EvaluatedTargetPropertyEntry( + cmLinkImplItem const& item, cmListFileBacktrace bt) + : LinkImplItem(item) + , Backtrace(std::move(bt)) +{ +} + +EvaluatedTargetPropertyEntry EvaluateTargetPropertyEntry( + cmGeneratorTarget const* thisTarget, std::string const& config, + std::string const& lang, cmGeneratorExpressionDAGChecker* dagChecker, + cmGeneratorTarget::TargetPropertyEntry& entry) +{ + EvaluatedTargetPropertyEntry ee(entry.LinkImplItem, entry.GetBacktrace()); + cmExpandList(entry.Evaluate(thisTarget->GetLocalGenerator(), config, + thisTarget, dagChecker, lang), + ee.Values); + if (entry.GetHadContextSensitiveCondition()) { + ee.ContextDependent = true; + } + return ee; +} + +EvaluatedTargetPropertyEntries EvaluateTargetPropertyEntries( + cmGeneratorTarget const* thisTarget, std::string const& config, + std::string const& lang, cmGeneratorExpressionDAGChecker* dagChecker, + std::vector<std::unique_ptr<cmGeneratorTarget::TargetPropertyEntry>> const& + in) +{ + EvaluatedTargetPropertyEntries out; + out.Entries.reserve(in.size()); + for (auto const& entry : in) { + out.Entries.emplace_back(EvaluateTargetPropertyEntry( + thisTarget, config, lang, dagChecker, *entry)); + } + return out; +} + +namespace { +void addInterfaceEntry(cmGeneratorTarget const* headTarget, + std::string const& config, std::string const& prop, + std::string const& lang, + cmGeneratorExpressionDAGChecker* dagChecker, + EvaluatedTargetPropertyEntries& entries, + cmGeneratorTarget::LinkInterfaceFor interfaceFor, + std::vector<cmLinkImplItem> const& libraries) +{ + for (cmLinkImplItem const& lib : libraries) { + if (lib.Target) { + EvaluatedTargetPropertyEntry ee(lib, lib.Backtrace); + // Pretend $<TARGET_PROPERTY:lib.Target,prop> appeared in our + // caller's property and hand-evaluate it as if it were compiled. + // Create a context as cmCompiledGeneratorExpression::Evaluate does. + cmGeneratorExpressionContext context( + headTarget->GetLocalGenerator(), config, false, headTarget, headTarget, + true, lib.Backtrace, lang); + cmExpandList(lib.Target->EvaluateInterfaceProperty( + prop, &context, dagChecker, interfaceFor), + ee.Values); + ee.ContextDependent = context.HadContextSensitiveCondition; + entries.Entries.emplace_back(std::move(ee)); + } + } +} +} + +void AddInterfaceEntries(cmGeneratorTarget const* headTarget, + std::string const& config, std::string const& prop, + std::string const& lang, + cmGeneratorExpressionDAGChecker* dagChecker, + EvaluatedTargetPropertyEntries& entries, + IncludeRuntimeInterface searchRuntime, + cmGeneratorTarget::LinkInterfaceFor interfaceFor) +{ + if (searchRuntime == IncludeRuntimeInterface::Yes) { + if (cmLinkImplementation const* impl = + headTarget->GetLinkImplementation(config, interfaceFor)) { + entries.HadContextSensitiveCondition = + impl->HadContextSensitiveCondition; + + auto runtimeLibIt = impl->LanguageRuntimeLibraries.find(lang); + if (runtimeLibIt != impl->LanguageRuntimeLibraries.end()) { + addInterfaceEntry(headTarget, config, prop, lang, dagChecker, entries, + interfaceFor, runtimeLibIt->second); + } + addInterfaceEntry(headTarget, config, prop, lang, dagChecker, entries, + interfaceFor, impl->Libraries); + } + } else { + if (cmLinkImplementationLibraries const* impl = + headTarget->GetLinkImplementationLibraries(config, interfaceFor)) { + entries.HadContextSensitiveCondition = + impl->HadContextSensitiveCondition; + addInterfaceEntry(headTarget, config, prop, lang, dagChecker, entries, + interfaceFor, impl->Libraries); + } + } +} diff --git a/Source/cmEvaluatedTargetProperty.h b/Source/cmEvaluatedTargetProperty.h new file mode 100644 index 0000000..e413ab0 --- /dev/null +++ b/Source/cmEvaluatedTargetProperty.h @@ -0,0 +1,80 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#pragma once + +#include <memory> +#include <string> +#include <vector> + +#include "cmGeneratorTarget.h" +#include "cmListFileCache.h" + +class cmLinkImplItem; +struct cmGeneratorExpressionDAGChecker; + +// Represent a target property entry after evaluating generator expressions +// and splitting up lists. +struct EvaluatedTargetPropertyEntry +{ + EvaluatedTargetPropertyEntry(cmLinkImplItem const& item, + cmListFileBacktrace 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); + +struct EvaluatedTargetPropertyEntries +{ + std::vector<EvaluatedTargetPropertyEntry> Entries; + bool HadContextSensitiveCondition = false; +}; + +EvaluatedTargetPropertyEntries EvaluateTargetPropertyEntries( + cmGeneratorTarget const* thisTarget, std::string const& config, + std::string const& lang, cmGeneratorExpressionDAGChecker* dagChecker, + std::vector<std::unique_ptr<cmGeneratorTarget::TargetPropertyEntry>> const& + in); + +// IncludeRuntimeInterface is used to break the cycle in computing +// the necessary transitive dependencies of targets that can occur +// now that we have implicit language runtime targets. +// +// To determine the set of languages that a target has we need to iterate +// all the sources which includes transitive INTERFACE sources. +// Therefore we can't determine what language runtimes are needed +// for a target until after all sources are computed. +// +// Therefore while computing the applicable INTERFACE_SOURCES we +// must ignore anything in LanguageRuntimeLibraries or we would +// create a cycle ( INTERFACE_SOURCES requires LanguageRuntimeLibraries, +// LanguageRuntimeLibraries requires INTERFACE_SOURCES). +// +enum class IncludeRuntimeInterface +{ + Yes, + No +}; + +void AddInterfaceEntries(cmGeneratorTarget const* headTarget, + std::string const& config, std::string const& prop, + std::string const& lang, + cmGeneratorExpressionDAGChecker* dagChecker, + EvaluatedTargetPropertyEntries& entries, + IncludeRuntimeInterface searchRuntime, + cmGeneratorTarget::LinkInterfaceFor interfaceFor = + cmGeneratorTarget::LinkInterfaceFor::Usage); diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index caf8ac2..437ae69 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -106,6 +106,9 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", gte, cmGeneratorExpression::BuildInterface, properties); + this->PopulateInterfaceProperty("INTERFACE_AUTOMOC_MACRO_NAMES", gte, + cmGeneratorExpression::BuildInterface, + properties); this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", gte, cmGeneratorExpression::BuildInterface, properties); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index def8227..51c91f3 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -110,6 +110,9 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) this->PopulateInterfaceProperty("INTERFACE_AUTOUIC_OPTIONS", gt, cmGeneratorExpression::InstallInterface, properties); + this->PopulateInterfaceProperty("INTERFACE_AUTOMOC_MACRO_NAMES", gt, + cmGeneratorExpression::InstallInterface, + properties); this->PopulateInterfaceProperty("INTERFACE_COMPILE_FEATURES", gt, cmGeneratorExpression::InstallInterface, properties); diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index bc5505f..90cddb5 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -27,6 +27,7 @@ #include "cmAlgorithms.h" #include "cmComputeLinkInformation.h" #include "cmCustomCommandGenerator.h" +#include "cmEvaluatedTargetProperty.h" #include "cmFileSet.h" #include "cmFileTimes.h" #include "cmGeneratedFileStream.h" @@ -89,31 +90,38 @@ cmTargetPropertyComputer::ComputeLocation<cmGeneratorTarget>( return tgt->GetLocation(config); } -class cmGeneratorTarget::TargetPropertyEntry -{ -protected: - static cmLinkImplItem NoLinkImplItem; +cmLinkImplItem cmGeneratorTarget::TargetPropertyEntry::NoLinkImplItem; +class TargetPropertyEntryString : public cmGeneratorTarget::TargetPropertyEntry +{ public: - TargetPropertyEntry(cmLinkImplItem const& item) - : LinkImplItem(item) + TargetPropertyEntryString(BT<std::string> propertyValue, + cmLinkImplItem const& item = NoLinkImplItem) + : cmGeneratorTarget::TargetPropertyEntry(item) + , PropertyValue(std::move(propertyValue)) { } - virtual ~TargetPropertyEntry() = default; - virtual const std::string& Evaluate( - cmLocalGenerator* lg, const std::string& config, - cmGeneratorTarget const* headTarget, - cmGeneratorExpressionDAGChecker* dagChecker, - std::string const& language) const = 0; + const std::string& Evaluate(cmLocalGenerator*, const std::string&, + cmGeneratorTarget const*, + cmGeneratorExpressionDAGChecker*, + std::string const&) const override + { + return this->PropertyValue.Value; + } - virtual cmListFileBacktrace GetBacktrace() const = 0; - virtual std::string const& GetInput() const = 0; - virtual bool GetHadContextSensitiveCondition() const { return false; } + cmListFileBacktrace GetBacktrace() const override + { + return this->PropertyValue.Backtrace; + } + std::string const& GetInput() const override + { + return this->PropertyValue.Value; + } - cmLinkImplItem const& LinkImplItem; +private: + BT<std::string> PropertyValue; }; -cmLinkImplItem cmGeneratorTarget::TargetPropertyEntry::NoLinkImplItem; class TargetPropertyEntryGenex : public cmGeneratorTarget::TargetPropertyEntry { @@ -150,37 +158,6 @@ private: const std::unique_ptr<cmCompiledGeneratorExpression> ge; }; -class TargetPropertyEntryString : public cmGeneratorTarget::TargetPropertyEntry -{ -public: - TargetPropertyEntryString(BT<std::string> propertyValue, - cmLinkImplItem const& item = NoLinkImplItem) - : cmGeneratorTarget::TargetPropertyEntry(item) - , PropertyValue(std::move(propertyValue)) - { - } - - const std::string& Evaluate(cmLocalGenerator*, const std::string&, - cmGeneratorTarget const*, - cmGeneratorExpressionDAGChecker*, - std::string const&) const override - { - return this->PropertyValue.Value; - } - - cmListFileBacktrace GetBacktrace() const override - { - return this->PropertyValue.Backtrace; - } - std::string const& GetInput() const override - { - return this->PropertyValue.Value; - } - -private: - BT<std::string> PropertyValue; -}; - class TargetPropertyEntryFileSet : public cmGeneratorTarget::TargetPropertyEntry { @@ -263,6 +240,18 @@ std::unique_ptr< cm::make_unique<TargetPropertyEntryString>(propertyValue)); } +cmGeneratorTarget::TargetPropertyEntry::TargetPropertyEntry( + cmLinkImplItem const& item) + : LinkImplItem(item) +{ +} + +bool cmGeneratorTarget::TargetPropertyEntry::GetHadContextSensitiveCondition() + const +{ + return false; +} + static void CreatePropertyGeneratorExpressions( cmake& cmakeInstance, cmBTStringRange entries, std::vector<std::unique_ptr<cmGeneratorTarget::TargetPropertyEntry>>& items, @@ -274,69 +263,6 @@ static 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()); - cmExpandList(entry.Evaluate(thisTarget->GetLocalGenerator(), config, - thisTarget, dagChecker, lang), - ee.Values); - if (entry.GetHadContextSensitiveCondition()) { - ee.ContextDependent = true; - } - return ee; -} - -struct EvaluatedTargetPropertyEntries -{ - std::vector<EvaluatedTargetPropertyEntry> Entries; - bool HadContextSensitiveCondition = false; -}; - -EvaluatedTargetPropertyEntries EvaluateTargetPropertyEntries( - cmGeneratorTarget const* thisTarget, std::string const& config, - std::string const& lang, cmGeneratorExpressionDAGChecker* dagChecker, - std::vector<std::unique_ptr<cmGeneratorTarget::TargetPropertyEntry>> const& - in) -{ - EvaluatedTargetPropertyEntries out; - out.Entries.reserve(in.size()); - for (auto const& entry : in) { - out.Entries.emplace_back(EvaluateTargetPropertyEntry( - thisTarget, config, lang, dagChecker, *entry)); - } - return out; -} -} - cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) : Target(t) { @@ -1607,84 +1533,6 @@ void AddLangSpecificImplicitIncludeDirectories( } } -void addInterfaceEntry(cmGeneratorTarget const* headTarget, - std::string const& config, std::string const& prop, - std::string const& lang, - cmGeneratorExpressionDAGChecker* dagChecker, - EvaluatedTargetPropertyEntries& entries, - LinkInterfaceFor interfaceFor, - std::vector<cmLinkImplItem> const& libraries) -{ - for (cmLinkImplItem const& lib : libraries) { - if (lib.Target) { - EvaluatedTargetPropertyEntry ee(lib, lib.Backtrace); - // Pretend $<TARGET_PROPERTY:lib.Target,prop> appeared in our - // caller's property and hand-evaluate it as if it were compiled. - // Create a context as cmCompiledGeneratorExpression::Evaluate does. - cmGeneratorExpressionContext context( - headTarget->GetLocalGenerator(), config, false, headTarget, headTarget, - true, lib.Backtrace, lang); - cmExpandList(lib.Target->EvaluateInterfaceProperty( - prop, &context, dagChecker, interfaceFor), - ee.Values); - ee.ContextDependent = context.HadContextSensitiveCondition; - entries.Entries.emplace_back(std::move(ee)); - } - } -} - -// IncludeRuntimeInterface is used to break the cycle in computing -// the necessary transitive dependencies of targets that can occur -// now that we have implicit language runtime targets. -// -// To determine the set of languages that a target has we need to iterate -// all the sources which includes transitive INTERFACE sources. -// Therefore we can't determine what language runtimes are needed -// for a target until after all sources are computed. -// -// Therefore while computing the applicable INTERFACE_SOURCES we -// must ignore anything in LanguageRuntimeLibraries or we would -// create a cycle ( INTERFACE_SOURCES requires LanguageRuntimeLibraries, -// LanguageRuntimeLibraries requires INTERFACE_SOURCES). -// -enum class IncludeRuntimeInterface -{ - Yes, - No -}; -void AddInterfaceEntries( - cmGeneratorTarget const* headTarget, std::string const& config, - std::string const& prop, std::string const& lang, - cmGeneratorExpressionDAGChecker* dagChecker, - EvaluatedTargetPropertyEntries& entries, - IncludeRuntimeInterface searchRuntime, - LinkInterfaceFor interfaceFor = LinkInterfaceFor::Usage) -{ - if (searchRuntime == IncludeRuntimeInterface::Yes) { - if (cmLinkImplementation const* impl = - headTarget->GetLinkImplementation(config, interfaceFor)) { - entries.HadContextSensitiveCondition = - impl->HadContextSensitiveCondition; - - auto runtimeLibIt = impl->LanguageRuntimeLibraries.find(lang); - if (runtimeLibIt != impl->LanguageRuntimeLibraries.end()) { - addInterfaceEntry(headTarget, config, prop, lang, dagChecker, entries, - interfaceFor, runtimeLibIt->second); - } - addInterfaceEntry(headTarget, config, prop, lang, dagChecker, entries, - interfaceFor, impl->Libraries); - } - } else { - if (cmLinkImplementationLibraries const* impl = - headTarget->GetLinkImplementationLibraries(config, interfaceFor)) { - entries.HadContextSensitiveCondition = - impl->HadContextSensitiveCondition; - addInterfaceEntry(headTarget, config, prop, lang, dagChecker, entries, - interfaceFor, impl->Libraries); - } - } -} - void AddObjectEntries(cmGeneratorTarget const* headTarget, std::string const& config, cmGeneratorExpressionDAGChecker* dagChecker, @@ -8977,10 +8825,10 @@ std::string cmGeneratorTarget::GenerateHeaderSetVerificationFile( cmGeneratedFileStream fout(filename); fout.SetCopyIfDifferent(true); - // IWYU pragma: associated allows include what you use to + // The IWYU "associated" pragma tells include-what-you-use to // consider the headerFile as part of the entire language // unit within include-what-you-use and as a result allows - // one to get IWYU advice for headers :) + // one to get IWYU advice for headers. fout << "#include <" << headerFilename << "> // IWYU pragma: associated\n"; fout.close(); diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 256ca3b..87227fd 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -1291,3 +1291,25 @@ private: }; mutable std::map<std::string, InfoByConfig> Configs; }; + +class cmGeneratorTarget::TargetPropertyEntry +{ +protected: + static cmLinkImplItem NoLinkImplItem; + +public: + TargetPropertyEntry(cmLinkImplItem const& item); + virtual ~TargetPropertyEntry() = default; + + virtual const std::string& Evaluate( + cmLocalGenerator* lg, const std::string& config, + cmGeneratorTarget const* headTarget, + cmGeneratorExpressionDAGChecker* dagChecker, + std::string const& language) const = 0; + + virtual cmListFileBacktrace GetBacktrace() const = 0; + virtual std::string const& GetInput() const = 0; + virtual bool GetHadContextSensitiveCondition() const; + + cmLinkImplItem const& LinkImplItem; +}; diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index eb3f433..3563a1a 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1544,8 +1544,9 @@ bool cmGlobalGenerator::Compute() } #ifndef CMAKE_BOOTSTRAP - cmQtAutoGenGlobalInitializer qtAutoGen(this->LocalGenerators); - if (!qtAutoGen.InitializeCustomTargets()) { + this->QtAutoGen = + cm::make_unique<cmQtAutoGenGlobalInitializer>(this->LocalGenerators); + if (!this->QtAutoGen->InitializeCustomTargets()) { return false; } #endif @@ -1565,12 +1566,6 @@ bool cmGlobalGenerator::Compute() } } -#ifndef CMAKE_BOOTSTRAP - if (!qtAutoGen.SetupCustomTargets()) { - return false; - } -#endif - for (const auto& localGen : this->LocalGenerators) { cmMakefile* mf = localGen->GetMakefile(); for (const auto& g : mf->GetInstallGenerators()) { @@ -1635,6 +1630,17 @@ void cmGlobalGenerator::Generate() this->CMakeInstance->UpdateProgress("Generating", 0.1f); +#ifndef CMAKE_BOOTSTRAP + if (!this->QtAutoGen->SetupCustomTargets()) { + if (!cmSystemTools::GetErrorOccurredFlag()) { + this->GetCMakeInstance()->IssueMessage( + MessageType::FATAL_ERROR, + "Problem setting up custom targets for QtAutoGen"); + } + return; + } +#endif + // Generate project files for (unsigned int i = 0; i < this->LocalGenerators.size(); ++i) { this->SetCurrentMakefile(this->LocalGenerators[i]->GetMakefile()); diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index 0e0624a..dde3648 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -50,6 +50,7 @@ class cmLinkLineComputer; class cmLocalGenerator; class cmMakefile; class cmOutputConverter; +class cmQtAutoGenGlobalInitializer; class cmSourceFile; class cmState; class cmStateDirectory; @@ -683,6 +684,11 @@ protected: cmake* CMakeInstance; std::vector<std::unique_ptr<cmMakefile>> Makefiles; LocalGeneratorVector LocalGenerators; + +#ifndef CMAKE_BOOTSTRAP + std::unique_ptr<cmQtAutoGenGlobalInitializer> QtAutoGen; +#endif + cmMakefile* CurrentConfigureMakefile; // map from project name to vector of local generators in that project std::map<std::string, std::vector<cmLocalGenerator*>> ProjectMap; diff --git a/Source/cmQtAutoGenInitializer.cxx b/Source/cmQtAutoGenInitializer.cxx index ba4c4d8..782c154 100644 --- a/Source/cmQtAutoGenInitializer.cxx +++ b/Source/cmQtAutoGenInitializer.cxx @@ -28,8 +28,10 @@ #include "cmAlgorithms.h" #include "cmCustomCommand.h" #include "cmCustomCommandLines.h" +#include "cmEvaluatedTargetProperty.h" #include "cmGeneratedFileStream.h" #include "cmGeneratorExpression.h" +#include "cmGeneratorExpressionDAGChecker.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" #include "cmLinkItem.h" @@ -1691,6 +1693,23 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo() info.SetArray("MOC_OPTIONS", this->Moc.Options); info.SetBool("MOC_RELAXED_MODE", this->Moc.RelaxedMode); info.SetBool("MOC_PATH_PREFIX", this->Moc.PathPrefix); + + cmGeneratorExpressionDAGChecker dagChecker( + this->GenTarget, "AUTOMOC_MACRO_NAMES", nullptr, nullptr); + EvaluatedTargetPropertyEntries InterfaceAutoMocMacroNamesEntries; + + AddInterfaceEntries(this->GenTarget, this->ConfigDefault, + "INTERFACE_AUTOMOC_MACRO_NAMES", "CXX", &dagChecker, + InterfaceAutoMocMacroNamesEntries, + IncludeRuntimeInterface::Yes); + + for (auto const& entry : InterfaceAutoMocMacroNamesEntries.Entries) { + this->Moc.MacroNames.insert(this->Moc.MacroNames.end(), + entry.Values.begin(), entry.Values.end()); + } + this->Moc.MacroNames.erase(cmRemoveDuplicates(this->Moc.MacroNames), + this->Moc.MacroNames.end()); + info.SetArray("MOC_MACRO_NAMES", this->Moc.MacroNames); info.SetArrayArray( "MOC_DEPEND_FILTERS", this->Moc.DependFilters, |