From 27252b2414f5034b16a447273e1f249fdf317b72 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Sun, 2 Aug 2015 19:35:48 +0200 Subject: [PATCH 1/9] cmComputeLinkInformation: Simplify generator object access. --- Source/cmComputeLinkInformation.cxx | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index c3f36af85..c16472ef5 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -14,6 +14,7 @@ #include "cmComputeLinkDepends.h" #include "cmOrderDirectories.h" +#include "cmLocalGenerator.h" #include "cmGlobalGenerator.h" #include "cmState.h" #include "cmOutputConverter.h" @@ -248,7 +249,8 @@ cmComputeLinkInformation // Store context information. this->Target = target; this->Makefile = this->Target->Target->GetMakefile(); - this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); + this->GlobalGenerator = + this->Target->GetLocalGenerator()->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); // Check whether to recognize OpenBSD-style library versioned names. @@ -540,9 +542,7 @@ bool cmComputeLinkInformation::Compute() i != wrongItems.end(); ++i) { cmTarget const* tgt = *i; - cmGeneratorTarget *gtgt = tgt->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(tgt); + cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(tgt); bool implib = (this->UseImportLibrary && (tgt->GetType() == cmTarget::SHARED_LIBRARY)); @@ -646,9 +646,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, if(tgt && tgt->IsLinkable()) { - cmGeneratorTarget *gtgt = tgt->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(tgt); + cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(tgt); // This is a CMake target. Ask the target for its real name. if(impexe && this->LoaderFlag) { @@ -762,7 +760,7 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, return; } - cmGeneratorTarget *gtgt = 0; + cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(tgt); // Get a full path to the dependent shared library. // Add it to the runtime path computation so that the target being @@ -1812,9 +1810,7 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, // Try to get the soname of the library. Only files with this name // could possibly conflict. - cmGeneratorTarget *gtgt = target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(target); + cmGeneratorTarget *gtgt = this->GlobalGenerator->GetGeneratorTarget(target); std::string soName = gtgt->GetSOName(this->Config); const char* soname = soName.empty()? 0 : soName.c_str(); From d9da6ee29fe0267ed347860f24f21be647ac81e8 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:49:49 +0200 Subject: [PATCH 2/9] cmLinkItem: Split to separate file. --- Source/CMakeLists.txt | 1 + Source/cmLinkItem.h | 47 +++++++++++++++++++++++++++++++++++++++++++ Source/cmTarget.h | 27 +------------------------ 3 files changed, 49 insertions(+), 26 deletions(-) create mode 100644 Source/cmLinkItem.h diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 92fee8aba..428b3648d 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -288,6 +288,7 @@ set(SRCS cmInstallDirectoryGenerator.h cmInstallDirectoryGenerator.cxx cmLinkedTree.h + cmLinkItem.h cmListFileCache.cxx cmListFileCache.h cmListFileLexer.c diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h new file mode 100644 index 000000000..da91ed156 --- /dev/null +++ b/Source/cmLinkItem.h @@ -0,0 +1,47 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2004-2015 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef cmLinkItem_h +#define cmLinkItem_h + +#include "cmListFileCache.h" + +class cmTarget; + +// Basic information about each link item. +class cmLinkItem: public std::string +{ + typedef std::string std_string; +public: + cmLinkItem(): std_string(), Target(0) {} + cmLinkItem(const std_string& n, + cmTarget const* t): std_string(n), Target(t) {} + cmLinkItem(cmLinkItem const& r): std_string(r), Target(r.Target) {} + cmTarget const* Target; +}; + +class cmLinkImplItem: public cmLinkItem +{ +public: + cmLinkImplItem(): cmLinkItem(), Backtrace(), FromGenex(false) {} + cmLinkImplItem(std::string const& n, + cmTarget const* t, + cmListFileBacktrace const& bt, + bool fromGenex): + cmLinkItem(n, t), Backtrace(bt), FromGenex(fromGenex) {} + cmLinkImplItem(cmLinkImplItem const& r): + cmLinkItem(r), Backtrace(r.Backtrace), FromGenex(r.FromGenex) {} + cmListFileBacktrace Backtrace; + bool FromGenex; +}; + +#endif diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e3fbdfd57..c4f38178c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -16,6 +16,7 @@ #include "cmPropertyMap.h" #include "cmPolicies.h" #include "cmListFileCache.h" +#include "cmLinkItem.h" #include #if defined(CMAKE_BUILD_WITH_CMAKE) @@ -52,32 +53,6 @@ class cmTarget; class cmGeneratorTarget; class cmTargetTraceDependencies; -// Basic information about each link item. -class cmLinkItem: public std::string -{ - typedef std::string std_string; -public: - cmLinkItem(): std_string(), Target(0) {} - cmLinkItem(const std_string& n, - cmTarget const* t): std_string(n), Target(t) {} - cmLinkItem(cmLinkItem const& r): std_string(r), Target(r.Target) {} - cmTarget const* Target; -}; -class cmLinkImplItem: public cmLinkItem -{ -public: - cmLinkImplItem(): cmLinkItem(), Backtrace(), FromGenex(false) {} - cmLinkImplItem(std::string const& n, - cmTarget const* t, - cmListFileBacktrace const& bt, - bool fromGenex): - cmLinkItem(n, t), Backtrace(bt), FromGenex(fromGenex) {} - cmLinkImplItem(cmLinkImplItem const& r): - cmLinkItem(r), Backtrace(r.Backtrace), FromGenex(r.FromGenex) {} - cmListFileBacktrace Backtrace; - bool FromGenex; -}; - class cmTargetInternals; class cmTargetInternalPointer { From 10040601a2e13cbb0653a20c55c1c696b5cacf29 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:55:46 +0200 Subject: [PATCH 3/9] cmLinkImplementationLibraries: Move to namespace scope. --- Source/cmGeneratorExpressionNode.cxx | 2 +- Source/cmGeneratorTarget.cxx | 2 +- Source/cmLinkItem.h | 12 ++++++++++++ Source/cmTarget.cxx | 12 ++++++------ Source/cmTarget.h | 17 +++-------------- 5 files changed, 23 insertions(+), 22 deletions(-) diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index a86c2bcc0..49f25152e 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1120,7 +1120,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } else if(!interfacePropertyName.empty()) { - if(cmTarget::LinkImplementationLibraries const* impl = + if(cmLinkImplementationLibraries const* impl = target->GetLinkImplementationLibraries(context->Config)) { linkedTargetsContent = diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c831704ac..aed2c070e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1506,7 +1506,7 @@ cmGeneratorTarget::GetLinkImplementationClosure( tgts.Done = true; std::set emitted; - cmTarget::LinkImplementationLibraries const* impl + cmLinkImplementationLibraries const* impl = this->Target->GetLinkImplementationLibraries(config); for(std::vector::const_iterator diff --git a/Source/cmLinkItem.h b/Source/cmLinkItem.h index da91ed156..a5427de49 100644 --- a/Source/cmLinkItem.h +++ b/Source/cmLinkItem.h @@ -44,4 +44,16 @@ public: bool FromGenex; }; +/** The link implementation specifies the direct library + dependencies needed by the object files of the target. */ +struct cmLinkImplementationLibraries +{ + // Libraries linked directly in this configuration. + std::vector Libraries; + + // Libraries linked directly in other configurations. + // Needed only for OLD behavior of CMP0003. + std::vector WrongConfigLibraries; +}; + #endif diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1f8f07ac1..1d4313ead 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3381,7 +3381,7 @@ bool cmTarget::HaveBuildTreeRPATH(const std::string& config) const { return false; } - if(LinkImplementationLibraries const* impl = + if(cmLinkImplementationLibraries const* impl = this->GetLinkImplementationLibraries(config)) { return !impl->Libraries.empty(); @@ -4331,7 +4331,7 @@ cmTargetInternals::ComputeLinkInterfaceLibraries( // to the link implementation. { // The link implementation is the default link interface. - cmTarget::LinkImplementationLibraries const* impl = + cmLinkImplementationLibraries const* impl = thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); iface.Libraries.insert(iface.Libraries.end(), impl->Libraries.begin(), impl->Libraries.end()); @@ -4431,7 +4431,7 @@ void cmTargetInternals::ComputeLinkInterface(cmTarget const* thisTarget, || thisTarget->GetPolicyStatusCMP0022() == cmPolicies::OLD) { // The link implementation is the default link interface. - cmTarget::LinkImplementationLibraries const* + cmLinkImplementationLibraries const* impl = thisTarget->GetLinkImplementationLibrariesInternal(config, headTarget); iface.ImplementationIsInterface = true; @@ -4482,7 +4482,7 @@ void cmTargetInternals::AddInterfaceEntries( cmTarget const* thisTarget, std::string const& config, std::string const& prop, std::vector& entries) { - if(cmTarget::LinkImplementationLibraries const* impl = + if(cmLinkImplementationLibraries const* impl = thisTarget->GetLinkImplementationLibraries(config)) { for (std::vector::const_iterator @@ -4532,14 +4532,14 @@ cmTarget::GetLinkImplementation(const std::string& config) const } //---------------------------------------------------------------------------- -cmTarget::LinkImplementationLibraries const* +cmLinkImplementationLibraries const* cmTarget::GetLinkImplementationLibraries(const std::string& config) const { return this->GetLinkImplementationLibrariesInternal(config, this); } //---------------------------------------------------------------------------- -cmTarget::LinkImplementationLibraries const* +cmLinkImplementationLibraries const* cmTarget::GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index c4f38178c..c5918ba7b 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -268,18 +268,7 @@ public: cmTarget const* headTarget, bool usage_requirements_only) const; - /** The link implementation specifies the direct library - dependencies needed by the object files of the target. */ - struct LinkImplementationLibraries - { - // Libraries linked directly in this configuration. - std::vector Libraries; - - // Libraries linked directly in other configurations. - // Needed only for OLD behavior of CMP0003. - std::vector WrongConfigLibraries; - }; - struct LinkImplementation: public LinkImplementationLibraries + struct LinkImplementation: public cmLinkImplementationLibraries { // Languages whose runtime libraries must be linked. std::vector Languages; @@ -287,7 +276,7 @@ public: LinkImplementation const* GetLinkImplementation(const std::string& config) const; - LinkImplementationLibraries const* + cmLinkImplementationLibraries const* GetLinkImplementationLibraries(const std::string& config) const; cmTarget const* FindTargetToLink(std::string const& name) const; @@ -606,7 +595,7 @@ private: GetImportLinkInterface(const std::string& config, cmTarget const* head, bool usage_requirements_only) const; - LinkImplementationLibraries const* + cmLinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; From 7568199b4de18ed56ad8ef735c145c4a44327355 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:22:30 +0200 Subject: [PATCH 4/9] cmTarget: Request only the link libraries where needed. --- Source/cmTarget.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1d4313ead..7b258194a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2099,7 +2099,8 @@ cmTarget::GetIncludeDirectories(const std::string& config, if(this->Makefile->IsOn("APPLE")) { - LinkImplementation const* impl = this->GetLinkImplementation(config); + cmLinkImplementationLibraries const* impl = + this->GetLinkImplementationLibraries(config); for(std::vector::const_iterator it = impl->Libraries.begin(); it != impl->Libraries.end(); ++it) From 1f54bc1cf35707a5f1410ff4c6632d7cba351c40 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 20:25:02 +0200 Subject: [PATCH 5/9] cmTarget: Split storage of include directories from genexes. --- Source/cmGlobalGenerator.cxx | 1 + Source/cmGlobalVisualStudio8Generator.cxx | 1 + Source/cmGlobalVisualStudioGenerator.cxx | 1 + Source/cmGlobalXCodeGenerator.cxx | 2 + Source/cmQtAutoGenerators.cxx | 2 + Source/cmTarget.cxx | 77 +++++++++++++++-------- Source/cmTarget.h | 2 + 7 files changed, 60 insertions(+), 26 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 3c818ff5f..50e2cd965 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -1549,6 +1549,7 @@ void cmGlobalGenerator::CreateGeneratorTargets(TargetTypes targetTypes, ti != targets.end(); ++ti) { cmTarget* t = &ti->second; + t->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(t, lg); this->GeneratorTargets[t] = gt; generatorTargets[t] = gt; diff --git a/Source/cmGlobalVisualStudio8Generator.cxx b/Source/cmGlobalVisualStudio8Generator.cxx index d5a558553..51dcab06b 100644 --- a/Source/cmGlobalVisualStudio8Generator.cxx +++ b/Source/cmGlobalVisualStudio8Generator.cxx @@ -254,6 +254,7 @@ bool cmGlobalVisualStudio8Generator::AddCheckTarget() mf->AddUtilityCommand(CMAKE_CHECK_BUILD_SYSTEM_TARGET, false, no_working_directory, no_depends, noCommandLines); + tgt->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(tgt, lg); mf->AddGeneratorTarget(tgt, gt); diff --git a/Source/cmGlobalVisualStudioGenerator.cxx b/Source/cmGlobalVisualStudioGenerator.cxx index 2f9d79a97..b69fc65a5 100644 --- a/Source/cmGlobalVisualStudioGenerator.cxx +++ b/Source/cmGlobalVisualStudioGenerator.cxx @@ -90,6 +90,7 @@ bool cmGlobalVisualStudioGenerator::Compute() AddUtilityCommand("ALL_BUILD", true, no_working_dir, no_depends, no_commands, false, "Build all projects"); + allBuild->Compute(); cmGeneratorTarget* gt = new cmGeneratorTarget(allBuild, gen[0]); allBuild->GetMakefile()->AddGeneratorTarget(allBuild, gt); diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 500682825..39933cb6d 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -463,6 +463,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, cmTarget* allbuild = mf->AddUtilityCommand("ALL_BUILD", true, no_depends, no_working_directory, "echo", "Build all projects"); + allbuild->Compute(); cmGeneratorTarget* allBuildGt = new cmGeneratorTarget(allbuild, root); mf->AddGeneratorTarget(allbuild, allBuildGt); @@ -497,6 +498,7 @@ cmGlobalXCodeGenerator::AddExtraTargets(cmLocalGenerator* root, true, no_depends, no_working_directory, "make", "-f", file.c_str()); + check->Compute(); cmGeneratorTarget* checkGt = new cmGeneratorTarget(check, root); mf->AddGeneratorTarget(check, checkGt); } diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index f1ba2f477..ce806ba76 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -475,6 +475,8 @@ bool cmQtAutoGenerators::InitializeAutogenTarget(cmLocalGenerator* lg, /*byproducts=*/rcc_output, depends, commandLines, false, autogenComment.c_str()); + autogenTarget->Compute(); + cmGeneratorTarget* gt = new cmGeneratorTarget(autogenTarget, lg); makefile->AddGeneratorTarget(autogenTarget, gt); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 7b258194a..1eb8e6a18 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -168,7 +168,9 @@ public: const cmsys::auto_ptr ge; cmLinkImplItem const& LinkImplItem; }; - std::vector IncludeDirectoriesEntries; + std::vector IncludeDirectoriesEntries; + std::vector IncludeDirectoriesBacktraces; + std::vector IncludeDirectoriesItems; std::vector CompileOptionsEntries; std::vector CompileFeaturesEntries; std::vector CompileDefinitionsEntries; @@ -366,13 +368,13 @@ void cmTarget::SetMakefile(cmMakefile* mf) const cmBacktraceRange parentIncludesBts = this->Makefile->GetIncludeDirectoriesBacktraces(); - cmBacktraceRange::const_iterator btIt = parentIncludesBts.begin(); - for (cmStringRange::const_iterator it - = parentIncludes.begin(); - it != parentIncludes.end(); ++it, ++btIt) - { - this->InsertInclude(*it, *btIt); - } + this->Internal->IncludeDirectoriesEntries.insert( + this->Internal->IncludeDirectoriesEntries.end(), + parentIncludes.begin(), parentIncludes.end()); + this->Internal->IncludeDirectoriesBacktraces.insert( + this->Internal->IncludeDirectoriesBacktraces.end(), + parentIncludesBts.begin(), parentIncludesBts.end()); + const std::set parentSystemIncludes = this->Makefile->GetSystemIncludeDirectories(); @@ -384,7 +386,7 @@ void cmTarget::SetMakefile(cmMakefile* mf) const cmBacktraceRange parentOptionsBts = this->Makefile->GetCompileOptionsBacktraces(); - btIt = parentOptionsBts.begin(); + cmBacktraceRange::const_iterator btIt = parentOptionsBts.begin(); for (cmStringRange::const_iterator it = parentOptions.begin(); it != parentOptions.end(); ++it, ++btIt) @@ -438,6 +440,29 @@ void cmTarget::SetMakefile(cmMakefile* mf) } } +void CreatePropertyGeneratorExpressions( + std::vector const& entries, + std::vector const& backtraces, + std::vector& items) +{ + std::vector::const_iterator btIt = backtraces.begin(); + for (std::vector::const_iterator it = entries.begin(); + it != entries.end(); ++it, ++btIt) + { + cmGeneratorExpression ge(*btIt); + cmsys::auto_ptr cge = ge.Parse(*it); + items.push_back(new cmTargetInternals::TargetPropertyEntry(cge)); + } +} + +void cmTarget::Compute() +{ + CreatePropertyGeneratorExpressions( + this->Internal->IncludeDirectoriesEntries, + this->Internal->IncludeDirectoriesBacktraces, + this->Internal->IncludeDirectoriesItems); +} + //---------------------------------------------------------------------------- void cmTarget::AddUtility(const std::string& u, cmMakefile *makefile) { @@ -1666,12 +1691,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } else if(prop == "INCLUDE_DIRECTORIES") { + this->Internal->IncludeDirectoriesEntries.clear(); + this->Internal->IncludeDirectoriesBacktraces.clear(); + this->Internal->IncludeDirectoriesEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - deleteAndClear(this->Internal->IncludeDirectoriesEntries); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->IncludeDirectoriesEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt); } else if(prop == "COMPILE_OPTIONS") { @@ -1764,10 +1788,9 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if(prop == "INCLUDE_DIRECTORIES") { + this->Internal->IncludeDirectoriesEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - this->Internal->IncludeDirectoriesEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); + this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt); } else if(prop == "COMPILE_OPTIONS") { @@ -1887,14 +1910,16 @@ void cmTarget::InsertInclude(std::string const& entry, cmListFileBacktrace const& bt, bool before) { - cmGeneratorExpression ge(bt); + std::vector::iterator position = + before ? this->Internal->IncludeDirectoriesEntries.begin() + : this->Internal->IncludeDirectoriesEntries.end(); - std::vector::iterator position - = before ? this->Internal->IncludeDirectoriesEntries.begin() - : this->Internal->IncludeDirectoriesEntries.end(); + std::vector::iterator btPosition = + before ? this->Internal->IncludeDirectoriesBacktraces.begin() + : this->Internal->IncludeDirectoriesBacktraces.end(); - this->Internal->IncludeDirectoriesEntries.insert(position, - new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry))); + this->Internal->IncludeDirectoriesEntries.insert(position, entry); + this->Internal->IncludeDirectoriesBacktraces.insert(btPosition, bt); } //---------------------------------------------------------------------------- @@ -2083,7 +2108,7 @@ cmTarget::GetIncludeDirectories(const std::string& config, } processIncludeDirectories(this, - this->Internal->IncludeDirectoriesEntries, + this->Internal->IncludeDirectoriesItems, includes, uniqueIncludes, &dagChecker, @@ -2899,7 +2924,7 @@ const char *cmTarget::GetProperty(const std::string& prop, } static std::string output; - MakePropertyList(output, this->Internal->IncludeDirectoriesEntries); + output = cmJoin(this->Internal->IncludeDirectoriesEntries, ";"); return output.c_str(); } else if(prop == propCOMPILE_FEATURES) @@ -4805,7 +4830,7 @@ cmTargetInternalPointer //---------------------------------------------------------------------------- cmTargetInternalPointer::~cmTargetInternalPointer() { - cmDeleteAll(this->Pointer->IncludeDirectoriesEntries); + cmDeleteAll(this->Pointer->IncludeDirectoriesItems); cmDeleteAll(this->Pointer->CompileOptionsEntries); cmDeleteAll(this->Pointer->CompileFeaturesEntries); cmDeleteAll(this->Pointer->CompileDefinitionsEntries); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index c5918ba7b..490aaa350 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -132,6 +132,8 @@ public: void AddPostBuildCommand(cmCustomCommand const &cmd) {this->PostBuildCommands.push_back(cmd);} + void Compute(); + /** * Get the list of the source files used by this target */ From 772ecef4b8037d5ce59d24772c05829872aff406 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 21:19:00 +0200 Subject: [PATCH 6/9] cmTarget: Split storage of compile options from genexes. --- Source/cmTarget.cxx | 56 +++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1eb8e6a18..09806e275 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -171,7 +171,9 @@ public: std::vector IncludeDirectoriesEntries; std::vector IncludeDirectoriesBacktraces; std::vector IncludeDirectoriesItems; - std::vector CompileOptionsEntries; + std::vector CompileOptionsEntries; + std::vector CompileOptionsBacktraces; + std::vector CompileOptionsItems; std::vector CompileFeaturesEntries; std::vector CompileDefinitionsEntries; std::vector SourceEntries; @@ -386,13 +388,12 @@ void cmTarget::SetMakefile(cmMakefile* mf) const cmBacktraceRange parentOptionsBts = this->Makefile->GetCompileOptionsBacktraces(); - cmBacktraceRange::const_iterator btIt = parentOptionsBts.begin(); - for (cmStringRange::const_iterator it - = parentOptions.begin(); - it != parentOptions.end(); ++it, ++btIt) - { - this->InsertCompileOption(*it, *btIt); - } + this->Internal->CompileOptionsEntries.insert( + this->Internal->CompileOptionsEntries.end(), + parentOptions.begin(), parentOptions.end()); + this->Internal->CompileOptionsBacktraces.insert( + this->Internal->CompileOptionsBacktraces.end(), + parentOptionsBts.begin(), parentOptionsBts.end()); } if (this->GetType() != INTERFACE_LIBRARY && this->GetType() != UTILITY) @@ -461,6 +462,11 @@ void cmTarget::Compute() this->Internal->IncludeDirectoriesEntries, this->Internal->IncludeDirectoriesBacktraces, this->Internal->IncludeDirectoriesItems); + + CreatePropertyGeneratorExpressions( + this->Internal->CompileOptionsEntries, + this->Internal->CompileOptionsBacktraces, + this->Internal->CompileOptionsItems); } //---------------------------------------------------------------------------- @@ -1699,12 +1705,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } else if(prop == "COMPILE_OPTIONS") { + this->Internal->CompileOptionsEntries.clear(); + this->Internal->CompileOptionsBacktraces.clear(); + this->Internal->CompileOptionsEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - deleteAndClear(this->Internal->CompileOptionsEntries); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->CompileOptionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->CompileOptionsBacktraces.push_back(lfbt); } else if(prop == "COMPILE_FEATURES") { @@ -1794,10 +1799,9 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if(prop == "COMPILE_OPTIONS") { + this->Internal->CompileOptionsEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - this->Internal->CompileOptionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); + this->Internal->CompileOptionsBacktraces.push_back(lfbt); } else if(prop == "COMPILE_FEATURES") { @@ -1927,14 +1931,16 @@ void cmTarget::InsertCompileOption(std::string const& entry, cmListFileBacktrace const& bt, bool before) { - cmGeneratorExpression ge(bt); + std::vector::iterator position = + before ? this->Internal->CompileOptionsEntries.begin() + : this->Internal->CompileOptionsEntries.end(); - std::vector::iterator position - = before ? this->Internal->CompileOptionsEntries.begin() - : this->Internal->CompileOptionsEntries.end(); + std::vector::iterator btPosition = + before ? this->Internal->CompileOptionsBacktraces.begin() + : this->Internal->CompileOptionsBacktraces.end(); - this->Internal->CompileOptionsEntries.insert(position, - new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry))); + this->Internal->CompileOptionsEntries.insert(position, entry); + this->Internal->CompileOptionsBacktraces.insert(btPosition, bt); } //---------------------------------------------------------------------------- @@ -2255,7 +2261,7 @@ void cmTarget::GetCompileOptions(std::vector &result, } processCompileOptions(this, - this->Internal->CompileOptionsEntries, + this->Internal->CompileOptionsItems, result, uniqueOptions, &dagChecker, @@ -2946,7 +2952,7 @@ const char *cmTarget::GetProperty(const std::string& prop, } static std::string output; - MakePropertyList(output, this->Internal->CompileOptionsEntries); + output = cmJoin(this->Internal->CompileOptionsEntries, ";"); return output.c_str(); } else if(prop == propCOMPILE_DEFINITIONS) @@ -4831,7 +4837,7 @@ cmTargetInternalPointer cmTargetInternalPointer::~cmTargetInternalPointer() { cmDeleteAll(this->Pointer->IncludeDirectoriesItems); - cmDeleteAll(this->Pointer->CompileOptionsEntries); + cmDeleteAll(this->Pointer->CompileOptionsItems); cmDeleteAll(this->Pointer->CompileFeaturesEntries); cmDeleteAll(this->Pointer->CompileDefinitionsEntries); cmDeleteAll(this->Pointer->SourceEntries); From 44e071aeff4d533f116a7721919f9036c5d5a1d1 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 21:23:38 +0200 Subject: [PATCH 7/9] cmTarget: Split storage of compile features from genexes. --- Source/cmTarget.cxx | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 09806e275..cc1df846d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -174,7 +174,9 @@ public: std::vector CompileOptionsEntries; std::vector CompileOptionsBacktraces; std::vector CompileOptionsItems; - std::vector CompileFeaturesEntries; + std::vector CompileFeaturesEntries; + std::vector CompileFeaturesBacktraces; + std::vector CompileFeaturesItems; std::vector CompileDefinitionsEntries; std::vector SourceEntries; std::vector LinkImplementationPropertyEntries; @@ -467,6 +469,11 @@ void cmTarget::Compute() this->Internal->CompileOptionsEntries, this->Internal->CompileOptionsBacktraces, this->Internal->CompileOptionsItems); + + CreatePropertyGeneratorExpressions( + this->Internal->CompileFeaturesEntries, + this->Internal->CompileFeaturesBacktraces, + this->Internal->CompileFeaturesItems); } //---------------------------------------------------------------------------- @@ -1713,12 +1720,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } else if(prop == "COMPILE_FEATURES") { + this->Internal->CompileFeaturesEntries.clear(); + this->Internal->CompileFeaturesBacktraces.clear(); + this->Internal->CompileFeaturesEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - deleteAndClear(this->Internal->CompileFeaturesEntries); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->CompileFeaturesEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->CompileFeaturesBacktraces.push_back(lfbt); } else if(prop == "COMPILE_DEFINITIONS") { @@ -1805,10 +1811,9 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if(prop == "COMPILE_FEATURES") { + this->Internal->CompileFeaturesEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - this->Internal->CompileFeaturesEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); + this->Internal->CompileFeaturesBacktraces.push_back(lfbt); } else if(prop == "COMPILE_DEFINITIONS") { @@ -2433,7 +2438,7 @@ void cmTarget::GetCompileFeatures(std::vector &result, } processCompileFeatures(this, - this->Internal->CompileFeaturesEntries, + this->Internal->CompileFeaturesItems, result, uniqueFeatures, &dagChecker, @@ -2941,7 +2946,7 @@ const char *cmTarget::GetProperty(const std::string& prop, } static std::string output; - MakePropertyList(output, this->Internal->CompileFeaturesEntries); + output = cmJoin(this->Internal->CompileFeaturesEntries, ";"); return output.c_str(); } else if(prop == propCOMPILE_OPTIONS) @@ -4838,7 +4843,7 @@ cmTargetInternalPointer::~cmTargetInternalPointer() { cmDeleteAll(this->Pointer->IncludeDirectoriesItems); cmDeleteAll(this->Pointer->CompileOptionsItems); - cmDeleteAll(this->Pointer->CompileFeaturesEntries); + cmDeleteAll(this->Pointer->CompileFeaturesItems); cmDeleteAll(this->Pointer->CompileDefinitionsEntries); cmDeleteAll(this->Pointer->SourceEntries); delete this->Pointer; From 197f4de110a59332757360110b1e90f6b07e1c97 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 21:30:17 +0200 Subject: [PATCH 8/9] cmTarget: Split storage of compile definitions from genexes. --- Source/cmTarget.cxx | 51 +++++++++++++++++---------------------------- 1 file changed, 19 insertions(+), 32 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index cc1df846d..1277fc2c2 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -177,7 +177,9 @@ public: std::vector CompileFeaturesEntries; std::vector CompileFeaturesBacktraces; std::vector CompileFeaturesItems; - std::vector CompileDefinitionsEntries; + std::vector CompileDefinitionsEntries; + std::vector CompileDefinitionsBacktraces; + std::vector CompileDefinitionsItems; std::vector SourceEntries; std::vector LinkImplementationPropertyEntries; @@ -474,6 +476,11 @@ void cmTarget::Compute() this->Internal->CompileFeaturesEntries, this->Internal->CompileFeaturesBacktraces, this->Internal->CompileFeaturesItems); + + CreatePropertyGeneratorExpressions( + this->Internal->CompileDefinitionsEntries, + this->Internal->CompileDefinitionsBacktraces, + this->Internal->CompileDefinitionsItems); } //---------------------------------------------------------------------------- @@ -1728,12 +1735,11 @@ void cmTarget::SetProperty(const std::string& prop, const char* value) } else if(prop == "COMPILE_DEFINITIONS") { + this->Internal->CompileDefinitionsEntries.clear(); + this->Internal->CompileDefinitionsBacktraces.clear(); + this->Internal->CompileDefinitionsEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - deleteAndClear(this->Internal->CompileDefinitionsEntries); - cmsys::auto_ptr cge = ge.Parse(value); - this->Internal->CompileDefinitionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(cge)); + this->Internal->CompileDefinitionsBacktraces.push_back(lfbt); } else if(prop == "EXPORT_NAME" && this->IsImported()) { @@ -1817,10 +1823,9 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value, } else if(prop == "COMPILE_DEFINITIONS") { + this->Internal->CompileDefinitionsEntries.push_back(value); cmListFileBacktrace lfbt = this->Makefile->GetBacktrace(); - cmGeneratorExpression ge(lfbt); - this->Internal->CompileDefinitionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(value))); + this->Internal->CompileDefinitionsBacktraces.push_back(lfbt); } else if(prop == "EXPORT_NAME" && this->IsImported()) { @@ -1952,10 +1957,8 @@ void cmTarget::InsertCompileOption(std::string const& entry, void cmTarget::InsertCompileDefinition(std::string const& entry, cmListFileBacktrace const& bt) { - cmGeneratorExpression ge(bt); - - this->Internal->CompileDefinitionsEntries.push_back( - new cmTargetInternals::TargetPropertyEntry(ge.Parse(entry))); + this->Internal->CompileDefinitionsEntries.push_back(entry); + this->Internal->CompileDefinitionsBacktraces.push_back(bt); } //---------------------------------------------------------------------------- @@ -2337,7 +2340,7 @@ void cmTarget::GetCompileDefinitions(std::vector &list, } processCompileDefinitions(this, - this->Internal->CompileDefinitionsEntries, + this->Internal->CompileDefinitionsItems, list, uniqueOptions, &dagChecker, @@ -2744,22 +2747,6 @@ bool cmTarget::HandleLocationPropertyPolicy(cmMakefile* context) const return messageType != cmake::FATAL_ERROR; } -//---------------------------------------------------------------------------- -static void MakePropertyList(std::string& output, - std::vector const& values) -{ - output = ""; - std::string sep; - for (std::vector::const_iterator - it = values.begin(), end = values.end(); - it != end; ++it) - { - output += sep; - output += (*it)->ge->GetInput(); - sep = ";"; - } -} - //---------------------------------------------------------------------------- const char *cmTarget::GetProperty(const std::string& prop) const { @@ -2968,7 +2955,7 @@ const char *cmTarget::GetProperty(const std::string& prop, } static std::string output; - MakePropertyList(output, this->Internal->CompileDefinitionsEntries); + output = cmJoin(this->Internal->CompileDefinitionsEntries, ";"); return output.c_str(); } else if (prop == propIMPORTED) @@ -4844,7 +4831,7 @@ cmTargetInternalPointer::~cmTargetInternalPointer() cmDeleteAll(this->Pointer->IncludeDirectoriesItems); cmDeleteAll(this->Pointer->CompileOptionsItems); cmDeleteAll(this->Pointer->CompileFeaturesItems); - cmDeleteAll(this->Pointer->CompileDefinitionsEntries); + cmDeleteAll(this->Pointer->CompileDefinitionsItems); cmDeleteAll(this->Pointer->SourceEntries); delete this->Pointer; } From 29886ce76482a8c857841015b58d1e91a9ee5c8e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 23:16:12 +0200 Subject: [PATCH 9/9] cmTarget: Use a simpler delete algorithm. This way, the methods can be moved without requiring a local algorithm. The containers use automatic storage. --- Source/cmTarget.cxx | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1277fc2c2..d3170e4ae 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -190,14 +190,6 @@ public: cmLinkImplItem cmTargetInternals::TargetPropertyEntry::NoLinkImplItem; -//---------------------------------------------------------------------------- -static void deleteAndClear( - std::vector &entries) -{ - cmDeleteAll(entries); - entries.clear(); -} - //---------------------------------------------------------------------------- cmTargetInternals::~cmTargetInternals() { @@ -810,7 +802,7 @@ void cmTarget::GetSourceFiles(std::vector &files, this->LinkImplementationLanguageIsContextDependent = false; } - deleteAndClear(linkInterfaceSourcesEntries); + cmDeleteAll(linkInterfaceSourcesEntries); } //---------------------------------------------------------------------------- @@ -2172,7 +2164,7 @@ cmTarget::GetIncludeDirectories(const std::string& config, debugIncludes, language); - deleteAndClear(linkInterfaceIncludeDirectoriesEntries); + cmDeleteAll(linkInterfaceIncludeDirectoriesEntries); return includes; } @@ -2293,7 +2285,7 @@ void cmTarget::GetCompileOptions(std::vector &result, debugOptions, language); - deleteAndClear(linkInterfaceCompileOptionsEntries); + cmDeleteAll(linkInterfaceCompileOptionsEntries); } //---------------------------------------------------------------------------- @@ -2395,7 +2387,7 @@ void cmTarget::GetCompileDefinitions(std::vector &list, debugDefines, language); - deleteAndClear(linkInterfaceCompileDefinitionsEntries); + cmDeleteAll(linkInterfaceCompileDefinitionsEntries); } //---------------------------------------------------------------------------- @@ -2462,7 +2454,7 @@ void cmTarget::GetCompileFeatures(std::vector &result, config, debugFeatures); - deleteAndClear(linkInterfaceCompileFeaturesEntries); + cmDeleteAll(linkInterfaceCompileFeaturesEntries); } //----------------------------------------------------------------------------