From 1ab59f688f647abe1bc0b5e7a187ec0bac988e0f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:40 +0200 Subject: cmGlobalNinjaGenerator: Simplify usage of API. --- Source/cmGlobalNinjaGenerator.cxx | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index d24cce8..5bdd35f 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -911,9 +911,7 @@ cmGlobalNinjaGenerator case cmTarget::STATIC_LIBRARY: case cmTarget::MODULE_LIBRARY: { - cmGeneratorTarget *gtgt = target->GetMakefile()->GetLocalGenerator() - ->GetGlobalGenerator() - ->GetGeneratorTarget(target); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(target); outputs.push_back(ng->ConvertToNinjaPath( gtgt->GetFullPath(configName, false, realname))); break; -- cgit v0.12 From 1aa13f2b58e477095f76d28a8d9bb1b83a9dd1f5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:41 +0200 Subject: cmExportInstallFileGenerator: Simplify local generator access. --- Source/cmExportInstallFileGenerator.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index 1d75f43..c88b7b2 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -358,7 +358,7 @@ cmExportInstallFileGenerator if(!properties.empty()) { // Get the rest of the target details. - cmGeneratorTarget *gtgt = te->Target->GetMakefile()->GetLocalGenerator() + cmGeneratorTarget *gtgt = te->Target->GetMakefile() ->GetGlobalGenerator()->GetGeneratorTarget(te->Target); this->SetImportDetailProperties(config, suffix, gtgt, properties, missingTargets); -- cgit v0.12 From 41abdc17df99662a8e99ba895050dbc8c0e34b8e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:41 +0200 Subject: cmGeneratorTarget: Move GetSOName from cmTarget.. --- Source/cmComputeLinkInformation.cxx | 16 ++++++---- Source/cmExportFileGenerator.cxx | 2 +- Source/cmGeneratorExpressionNode.cxx | 2 +- Source/cmGeneratorTarget.cxx | 43 +++++++++++++++++++++++++++ Source/cmGeneratorTarget.h | 3 ++ Source/cmGlobalXCodeGenerator.cxx | 2 +- Source/cmTarget.cxx | 57 ------------------------------------ Source/cmTarget.h | 18 +++++++++--- 8 files changed, 73 insertions(+), 70 deletions(-) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index e63b44f..72db6f8 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -756,15 +756,16 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, return; } + cmGeneratorTarget *gtgt = 0; + // Get a full path to the dependent shared library. // Add it to the runtime path computation so that the target being // linked will be able to find it. std::string lib; if(tgt) { - cmGeneratorTarget *gtgt = tgt->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(tgt); + gtgt = tgt->GetMakefile()->GetGlobalGenerator()->GetGeneratorTarget(tgt); + lib = gtgt->GetFullPath(this->Config, this->UseImportLibrary); this->AddLibraryRuntimeInfo(lib, tgt); } @@ -790,9 +791,9 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, } if(order) { - if(tgt) + if(gtgt) { - std::string soName = tgt->GetSOName(this->Config); + std::string soName = gtgt->GetSOName(this->Config); const char* soname = soName.empty()? 0 : soName.c_str(); order->AddRuntimeLibrary(lib, soname); } @@ -1804,7 +1805,10 @@ cmComputeLinkInformation::AddLibraryRuntimeInfo(std::string const& fullPath, // Try to get the soname of the library. Only files with this name // could possibly conflict. - std::string soName = target->GetSOName(this->Config); + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); + std::string soName = gtgt->GetSOName(this->Config); const char* soname = soName.empty()? 0 : soName.c_str(); // Include this library in the runtime path ordering. diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index a33cd59..3aa2b65 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -895,7 +895,7 @@ cmExportFileGenerator value = this->InstallNameDir(target->Target, config); } prop = "IMPORTED_SONAME"; - value += target->Target->GetSOName(config); + value += target->GetSOName(config); } else { diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index f3527ff..c0485db 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1584,7 +1584,7 @@ struct TargetFilesystemArtifactResultCreator } std::string result = target->Target->GetDirectory(context->Config); result += "/"; - result += target->Target->GetSOName(context->Config); + result += target->GetSOName(context->Config); return result; } }; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index bd57b3d..e17df9e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -650,6 +650,49 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetSOName(const std::string& config) const +{ + if(this->Target->IsImported()) + { + // Lookup the imported soname. + if(cmTarget::ImportInfo const* info = this->Target->GetImportInfo(config)) + { + if(info->NoSOName) + { + // The imported library has no builtin soname so the name + // searched at runtime will be just the filename. + return cmSystemTools::GetFilenameName(info->Location); + } + else + { + // Use the soname given if any. + if(info->SOName.find("@rpath/") == 0) + { + return info->SOName.substr(6); + } + return info->SOName; + } + } + else + { + return ""; + } + } + else + { + // Compute the soname that will be built. + std::string name; + std::string soName; + std::string realName; + std::string impName; + std::string pdbName; + this->Target->GetLibraryNames(name, soName, realName, + impName, pdbName, config); + return soName; + } +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index a584c71..8e5c2ab 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -90,6 +90,9 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** Get the soname of the target. Allowed only for a shared library. */ + std::string GetSOName(const std::string& config) const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7dea107..8cb59f8 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2345,7 +2345,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, install_name += install_name_dir; install_name += "/"; } - install_name += target.GetSOName(configName); + install_name += gtgt->GetSOName(configName); if((realName != soName) || install_name_dir.empty()) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index cf33791..54f9cf0 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -69,21 +69,6 @@ struct cmTarget::OutputInfo }; //---------------------------------------------------------------------------- -struct cmTarget::ImportInfo -{ - ImportInfo(): NoSOName(false), Multiplicity(0) {} - bool NoSOName; - int Multiplicity; - std::string Location; - std::string SOName; - std::string ImportLibrary; - std::string Languages; - std::string Libraries; - std::string LibrariesProp; - std::string SharedDeps; -}; - -//---------------------------------------------------------------------------- struct cmTarget::CompileInfo { std::string CompilePdbDir; @@ -3602,48 +3587,6 @@ bool cmTarget::HasSOName(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetSOName(const std::string& config) const -{ - if(this->IsImported()) - { - // Lookup the imported soname. - if(cmTarget::ImportInfo const* info = this->GetImportInfo(config)) - { - if(info->NoSOName) - { - // The imported library has no builtin soname so the name - // searched at runtime will be just the filename. - return cmSystemTools::GetFilenameName(info->Location); - } - else - { - // Use the soname given if any. - if(info->SOName.find("@rpath/") == 0) - { - return info->SOName.substr(6); - } - return info->SOName; - } - } - else - { - return ""; - } - } - else - { - // Compute the soname that will be built. - std::string name; - std::string soName; - std::string realName; - std::string impName; - std::string pdbName; - this->GetLibraryNames(name, soName, realName, impName, pdbName, config); - return soName; - } -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index f567d50..389f9cd 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -411,9 +411,6 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; - /** Get the soname of the target. Allowed only for a shared library. */ - std::string GetSOName(const std::string& config) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; @@ -768,7 +765,20 @@ private: std::string& out) const; // Cache import information from properties for each configuration. - struct ImportInfo; + struct ImportInfo + { + ImportInfo(): NoSOName(false), Multiplicity(0) {} + bool NoSOName; + int Multiplicity; + std::string Location; + std::string SOName; + std::string ImportLibrary; + std::string Languages; + std::string Libraries; + std::string LibrariesProp; + std::string SharedDeps; + }; + ImportInfo const* GetImportInfo(const std::string& config) const; void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; -- cgit v0.12 From 12bc571c13eda8d504eac788d6b3e5e8d83e3ad3 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:41 +0200 Subject: cmGeneratorTarget: Move GetAutoUicOptions from cmTarget. --- Source/cmGeneratorTarget.cxx | 26 ++++++++++++++++++++++++++ Source/cmGeneratorTarget.h | 4 +++- Source/cmQtAutoGenerators.cxx | 5 ++++- Source/cmTarget.cxx | 25 ------------------------- Source/cmTarget.h | 2 -- 5 files changed, 33 insertions(+), 29 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index e17df9e..95f6aaa 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -743,6 +743,32 @@ cmGeneratorTarget::UseObjectLibraries(std::vector& objs, } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, + const std::string& config) const +{ + const char *prop + = this->Target-> + GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", + config); + if (!prop) + { + return; + } + cmGeneratorExpression ge; + + cmGeneratorExpressionDAGChecker dagChecker( + this->GetName(), + "AUTOUIC_OPTIONS", 0, 0); + cmSystemTools::ExpandListArgument(ge.Parse(prop) + ->Evaluate(this->Makefile, + config, + false, + this->Target, + &dagChecker), + result); +} + +//---------------------------------------------------------------------------- class cmTargetTraceDependencies { public: diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8e5c2ab..3e43711 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -156,6 +156,9 @@ public: SourceFileType Type; const char* MacFolder; // location inside Mac content folders }; + void GetAutoUicOptions(std::vector &result, + const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; @@ -176,7 +179,6 @@ private: struct SourceEntry { std::vector Depends; }; typedef std::map SourceEntriesType; SourceEntriesType SourceEntries; - mutable std::map Objects; std::set ExplicitObjectName; mutable std::map > SystemIncludesCache; diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index 1322dea..a72b176 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -878,8 +878,11 @@ void cmQtAutoGenerators::MergeUicOptions(std::vector &opts, static void GetUicOpts(cmTarget const* target, const std::string& config, std::string &optString) { + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); std::vector opts; - target->GetAutoUicOptions(opts, config); + gtgt->GetAutoUicOptions(opts, config); optString = cmJoin(opts, ";"); } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 54f9cf0..3074f9b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2236,31 +2236,6 @@ static void processCompileOptions(cmTarget const* tgt, } //---------------------------------------------------------------------------- -void cmTarget::GetAutoUicOptions(std::vector &result, - const std::string& config) const -{ - const char *prop - = this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", - config); - if (!prop) - { - return; - } - cmGeneratorExpression ge; - - cmGeneratorExpressionDAGChecker dagChecker( - this->GetName(), - "AUTOUIC_OPTIONS", 0, 0); - cmSystemTools::ExpandListArgument(ge.Parse(prop) - ->Evaluate(this->Makefile, - config, - false, - this, - &dagChecker), - result); -} - -//---------------------------------------------------------------------------- void cmTarget::GetCompileOptions(std::vector &result, const std::string& config, const std::string& language) const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 389f9cd..d5374a6 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -571,8 +571,6 @@ public: void GetCompileOptions(std::vector &result, const std::string& config, const std::string& language) const; - void GetAutoUicOptions(std::vector &result, - const std::string& config) const; void GetCompileFeatures(std::vector &features, const std::string& config) const; -- cgit v0.12 From 244c5b5dcdc5af1f91a79a81f7f7ec4047759fe8 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:42 +0200 Subject: cmGeneratorTarget: Move IsLinkInterfaceDependent* from cmTarget. --- Source/cmGeneratorExpressionNode.cxx | 27 ++++++----- Source/cmGeneratorTarget.cxx | 81 +++++++++++++++++++++++++++++++++ Source/cmGeneratorTarget.h | 26 +++++++++++ Source/cmTarget.cxx | 88 ------------------------------------ Source/cmTarget.h | 19 -------- 5 files changed, 122 insertions(+), 119 deletions(-) diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index c0485db..c1641cc 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1128,6 +1128,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } } + cmGeneratorTarget* gtgt = + context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); + if (!prop) { if (target->IsImported() @@ -1135,16 +1138,16 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { return linkedTargetsContent; } - if (target->IsLinkInterfaceDependentBoolProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentBoolProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; return target->GetLinkInterfaceDependentBoolProperty( propertyName, context->Config) ? "1" : "0"; } - if (target->IsLinkInterfaceDependentStringProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentStringProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1153,8 +1156,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config); return propContent ? propContent : ""; } - if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMinProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1163,8 +1166,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config); return propContent ? propContent : ""; } - if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMaxProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1180,8 +1183,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode if (!target->IsImported() && dagCheckerParent && !dagCheckerParent->EvaluatingLinkLibraries()) { - if (target->IsLinkInterfaceDependentNumberMinProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMinProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = @@ -1190,8 +1193,8 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config); return propContent ? propContent : ""; } - if (target->IsLinkInterfaceDependentNumberMaxProperty(propertyName, - context->Config)) + if (gtgt->IsLinkInterfaceDependentNumberMaxProperty(propertyName, + context->Config)) { context->HadContextSensitiveCondition = true; const char *propContent = diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 95f6aaa..3dbeff2 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1436,3 +1436,84 @@ void cmGeneratorTarget::ConstructSourceFileFlags() const } } } + +//---------------------------------------------------------------------------- +const cmGeneratorTarget::CompatibleInterfacesBase& +cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const +{ + cmGeneratorTarget::CompatibleInterfaces& compat = + this->CompatibleInterfacesMap[config]; + if(!compat.Done) + { + compat.Done = true; + compat.PropsBool.insert("POSITION_INDEPENDENT_CODE"); + compat.PropsString.insert("AUTOUIC_OPTIONS"); + std::vector const& deps = + this->Target->GetLinkImplementationClosure(config); + for(std::vector::const_iterator li = deps.begin(); + li != deps.end(); ++li) + { +#define CM_READ_COMPATIBLE_INTERFACE(X, x) \ + if(const char* prop = (*li)->GetProperty("COMPATIBLE_INTERFACE_" #X)) \ + { \ + std::vector props; \ + cmSystemTools::ExpandListArgument(prop, props); \ + compat.Props##x.insert(props.begin(), props.end()); \ + } + CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool) + CM_READ_COMPATIBLE_INTERFACE(STRING, String) + CM_READ_COMPATIBLE_INTERFACE(NUMBER_MIN, NumberMin) + CM_READ_COMPATIBLE_INTERFACE(NUMBER_MAX, NumberMax) +#undef CM_READ_COMPATIBLE_INTERFACE + } + } + return compat; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentBoolProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsBool.count(p) > 0; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentStringProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsString.count(p) > 0; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMinProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsNumberMin.count(p) > 0; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( + const std::string &p, const std::string& config) const +{ + if (this->Target->GetType() == cmTarget::OBJECT_LIBRARY + || this->Target->GetType() == cmTarget::INTERFACE_LIBRARY) + { + return false; + } + return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 3e43711..3b32bf5 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -82,6 +82,15 @@ public: bool GetFeatureAsBool(const std::string& feature, const std::string& config) const; + bool IsLinkInterfaceDependentBoolProperty(const std::string &p, + const std::string& config) const; + bool IsLinkInterfaceDependentStringProperty(const std::string &p, + const std::string& config) const; + bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p, + const std::string& config) const; + bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, + const std::string& config) const; + /** Get the full path to the target according to the settings in its makefile and the configuration type. */ std::string GetFullPath(const std::string& config="", bool implib = false, @@ -187,6 +196,23 @@ private: mutable bool SourceFileFlagsConstructed; mutable std::map SourceFlagsMap; + struct CompatibleInterfacesBase + { + std::set PropsBool; + std::set PropsString; + std::set PropsNumberMax; + std::set PropsNumberMin; + }; + CompatibleInterfacesBase const& + GetCompatibleInterfaces(std::string const& config) const; + + struct CompatibleInterfaces: public CompatibleInterfacesBase + { + CompatibleInterfaces(): Done(false) {} + bool Done; + }; + mutable std::map CompatibleInterfacesMap; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 3074f9b..9c7e46a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -170,13 +170,6 @@ public: }; std::map LinkImplClosureMap; - struct CompatibleInterfaces: public cmTarget::CompatibleInterfaces - { - CompatibleInterfaces(): Done(false) {} - bool Done; - }; - std::map CompatibleInterfacesMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -4991,54 +4984,6 @@ const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty( } //---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsBool.count(p) > 0; -} - -//---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentStringProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsString.count(p) > 0; -} - -//---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentNumberMinProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsNumberMin.count(p) > 0; -} - -//---------------------------------------------------------------------------- -bool cmTarget::IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const std::string& config) const -{ - if (this->TargetTypeValue == OBJECT_LIBRARY - || this->TargetTypeValue == INTERFACE_LIBRARY) - { - return false; - } - return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; -} - -//---------------------------------------------------------------------------- void cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const { @@ -5725,39 +5670,6 @@ cmTarget::GetLinkImplementationClosure(const std::string& config) const } //---------------------------------------------------------------------------- -cmTarget::CompatibleInterfaces const& -cmTarget::GetCompatibleInterfaces(std::string const& config) const -{ - cmTargetInternals::CompatibleInterfaces& compat = - this->Internal->CompatibleInterfacesMap[config]; - if(!compat.Done) - { - compat.Done = true; - compat.PropsBool.insert("POSITION_INDEPENDENT_CODE"); - compat.PropsString.insert("AUTOUIC_OPTIONS"); - std::vector const& deps = - this->GetLinkImplementationClosure(config); - for(std::vector::const_iterator li = deps.begin(); - li != deps.end(); ++li) - { -#define CM_READ_COMPATIBLE_INTERFACE(X, x) \ - if(const char* prop = (*li)->GetProperty("COMPATIBLE_INTERFACE_" #X)) \ - { \ - std::vector props; \ - cmSystemTools::ExpandListArgument(prop, props); \ - compat.Props##x.insert(props.begin(), props.end()); \ - } - CM_READ_COMPATIBLE_INTERFACE(BOOL, Bool) - CM_READ_COMPATIBLE_INTERFACE(STRING, String) - CM_READ_COMPATIBLE_INTERFACE(NUMBER_MIN, NumberMin) - CM_READ_COMPATIBLE_INTERFACE(NUMBER_MAX, NumberMax) -#undef CM_READ_COMPATIBLE_INTERFACE - } - } - return compat; -} - -//---------------------------------------------------------------------------- void cmTargetInternals::ComputeLinkInterfaceLibraries( cmTarget const* thisTarget, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d5374a6..df8cdc1 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -305,16 +305,6 @@ public: std::vector const& GetLinkImplementationClosure(const std::string& config) const; - struct CompatibleInterfaces - { - std::set PropsBool; - std::set PropsString; - std::set PropsNumberMax; - std::set PropsNumberMin; - }; - CompatibleInterfaces const& - GetCompatibleInterfaces(std::string const& config) const; - /** The link implementation specifies the direct library dependencies needed by the object files of the target. */ struct LinkImplementationLibraries @@ -575,15 +565,6 @@ public: const std::string& config) const; bool IsNullImpliedByLinkLibraries(const std::string &p) const; - bool IsLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const; - bool IsLinkInterfaceDependentStringProperty(const std::string &p, - const std::string& config) const; - bool IsLinkInterfaceDependentNumberMinProperty(const std::string &p, - const std::string& config) const; - bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const std::string& config) const; - bool GetLinkInterfaceDependentBoolProperty(const std::string &p, const std::string& config) const; -- cgit v0.12 From c971338416d7376d8b710b5c18957f6a800b3de0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:42 +0200 Subject: Export: Port more API to cmGeneratorTarget. --- Source/cmExportBuildFileGenerator.cxx | 6 ++++-- Source/cmExportFileGenerator.cxx | 13 +++++++------ Source/cmExportFileGenerator.h | 2 +- Source/cmExportInstallFileGenerator.cxx | 6 +++++- 4 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 355fc00..6274c3f 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -27,6 +27,7 @@ cmExportBuildFileGenerator::cmExportBuildFileGenerator() //---------------------------------------------------------------------------- bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) { + std::vector allTargets; { std::string expectedTargets; std::string sep; @@ -68,7 +69,8 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) tei = this->Exports.begin(); tei != this->Exports.end(); ++tei) { - cmTarget* te = (*tei)->Target; + cmGeneratorTarget* gte = *tei; + cmTarget* te = gte->Target; this->GenerateImportTargetCode(os, te); te->AppendBuildInterfaceIncludes(); @@ -104,7 +106,7 @@ bool cmExportBuildFileGenerator::GenerateMainFile(std::ostream& os) cmGeneratorExpression::BuildInterface, properties, missingTargets); } - this->PopulateCompatibleInterfaceProperties(te, properties); + this->PopulateCompatibleInterfaceProperties(gte, properties); this->GenerateInterfaceProperties(te, os, properties); } diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 3aa2b65..a5050ff 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -525,15 +525,15 @@ void getPropertyContents(cmTarget const* tgt, const std::string& prop, } //---------------------------------------------------------------------------- -void getCompatibleInterfaceProperties(cmTarget *target, +void getCompatibleInterfaceProperties(cmGeneratorTarget *target, std::set &ifaceProperties, const std::string& config) { - cmComputeLinkInformation *info = target->GetLinkInformation(config); + cmComputeLinkInformation *info = target->Target->GetLinkInformation(config); if (!info) { - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); std::ostringstream e; e << "Exporting the target \"" << target->GetName() << "\" is not " "allowed since its linker language cannot be determined"; @@ -568,9 +568,10 @@ void getCompatibleInterfaceProperties(cmTarget *target, //---------------------------------------------------------------------------- void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( - cmTarget *target, + cmGeneratorTarget *gtarget, ImportPropertyMap &properties) { + cmTarget *target = gtarget->Target; this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_BOOL", target, properties); this->PopulateInterfaceProperty("COMPATIBLE_INTERFACE_STRING", @@ -591,7 +592,7 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( if (target->GetType() != cmTarget::INTERFACE_LIBRARY) { - getCompatibleInterfaceProperties(target, ifaceProperties, ""); + getCompatibleInterfaceProperties(gtarget, ifaceProperties, ""); std::vector configNames; target->GetMakefile()->GetConfigurations(configNames); @@ -599,7 +600,7 @@ void cmExportFileGenerator::PopulateCompatibleInterfaceProperties( for (std::vector::const_iterator ci = configNames.begin(); ci != configNames.end(); ++ci) { - getCompatibleInterfaceProperties(target, ifaceProperties, *ci); + getCompatibleInterfaceProperties(gtarget, ifaceProperties, *ci); } } diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 2f33200..4e54740 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -132,7 +132,7 @@ protected: std::vector &missingTargets); void PopulateInterfaceProperty(const std::string& propName, cmTarget *target, ImportPropertyMap &properties); - void PopulateCompatibleInterfaceProperties(cmTarget *target, + void PopulateCompatibleInterfaceProperties(cmGeneratorTarget *target, ImportPropertyMap &properties); void GenerateInterfaceProperties(cmTarget const* target, std::ostream& os, const ImportPropertyMap &properties); diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index c88b7b2..b0bc686 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -193,7 +193,11 @@ bool cmExportInstallFileGenerator::GenerateMainFile(std::ostream& os) this->PopulateInterfaceProperty("INTERFACE_POSITION_INDEPENDENT_CODE", te, properties); - this->PopulateCompatibleInterfaceProperties(te, properties); + cmGeneratorTarget *gtgt = te->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(te); + + this->PopulateCompatibleInterfaceProperties(gtgt, properties); this->GenerateInterfaceProperties(te, os, properties); } -- cgit v0.12 From 803a7982b4403c690d7b7fa8c49d00a5abae3471 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:42 +0200 Subject: cmGeneratorTarget: Move GetLinkInformation from cmTarget --- Source/cmCommonTargetGenerator.cxx | 5 +-- Source/cmExportFileGenerator.cxx | 2 +- Source/cmGeneratorTarget.cxx | 38 +++++++++++++++++++++ Source/cmGeneratorTarget.h | 9 +++++ Source/cmGlobalXCodeGenerator.cxx | 7 ++-- Source/cmInstallTargetGenerator.cxx | 10 +++--- Source/cmLocalGenerator.cxx | 2 +- Source/cmLocalVisualStudio6Generator.cxx | 4 ++- Source/cmLocalVisualStudio7Generator.cxx | 7 ++-- Source/cmMakefileTargetGenerator.cxx | 3 +- Source/cmNinjaTargetGenerator.cxx | 2 +- Source/cmTarget.cxx | 53 ------------------------------ Source/cmTarget.h | 13 -------- Source/cmVisualStudio10TargetGenerator.cxx | 2 +- 14 files changed, 72 insertions(+), 85 deletions(-) diff --git a/Source/cmCommonTargetGenerator.cxx b/Source/cmCommonTargetGenerator.cxx index 26ca375..4840e89 100644 --- a/Source/cmCommonTargetGenerator.cxx +++ b/Source/cmCommonTargetGenerator.cxx @@ -276,7 +276,8 @@ std::string cmCommonTargetGenerator::GetFrameworkFlags(std::string const& l) std::string flags; const char* cfg = this->LocalGenerator->GetConfigName().c_str(); - if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) + if(cmComputeLinkInformation* cli = + this->GeneratorTarget->GetLinkInformation(cfg)) { std::vector const& frameworks = cli->GetFrameworkPaths(); for(std::vector::const_iterator i = frameworks.begin(); @@ -384,7 +385,7 @@ cmCommonTargetGenerator::GetLinkedTargetDirectories() const std::vector dirs; std::set emitted; if (cmComputeLinkInformation* cli = - this->Target->GetLinkInformation(this->ConfigName)) + this->GeneratorTarget->GetLinkInformation(this->ConfigName)) { cmComputeLinkInformation::ItemVector const& items = cli->GetItems(); for(cmComputeLinkInformation::ItemVector::const_iterator diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index a5050ff..8a2cf4b 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -529,7 +529,7 @@ void getCompatibleInterfaceProperties(cmGeneratorTarget *target, std::set &ifaceProperties, const std::string& config) { - cmComputeLinkInformation *info = target->Target->GetLinkInformation(config); + cmComputeLinkInformation *info = target->GetLinkInformation(config); if (!info) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 3dbeff2..845c052 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -229,6 +229,12 @@ cmGeneratorTarget::cmGeneratorTarget(cmTarget* t, cmLocalGenerator* lg) this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); } +cmGeneratorTarget::~cmGeneratorTarget() +{ + cmDeleteAll(this->LinkInformation); + this->LinkInformation.clear(); +} + cmLocalGenerator* cmGeneratorTarget::GetLocalGenerator() const { return this->LocalGenerator; @@ -1517,3 +1523,35 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( } return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; } + + +//---------------------------------------------------------------------------- +cmComputeLinkInformation* +cmGeneratorTarget::GetLinkInformation(const std::string& config) const +{ + // Lookup any existing information for this configuration. + std::string key(cmSystemTools::UpperCase(config)); + cmTargetLinkInformationMap::iterator + i = this->LinkInformation.find(key); + if(i == this->LinkInformation.end()) + { + // Compute information for this configuration. + cmComputeLinkInformation* info = + new cmComputeLinkInformation(this->Target, config); + if(!info || !info->Compute()) + { + delete info; + info = 0; + } + + // Store the information for this configuration. + cmTargetLinkInformationMap::value_type entry(key, info); + i = this->LinkInformation.insert(entry).first; + + if (info) + { + this->Target->CheckPropertyCompatibility(info, config); + } + } + return i->second; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 3b32bf5..e53f098 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -20,11 +20,13 @@ class cmLocalGenerator; class cmMakefile; class cmSourceFile; class cmTarget; +class cmComputeLinkInformation; class cmGeneratorTarget { public: cmGeneratorTarget(cmTarget*, cmLocalGenerator* lg); + ~cmGeneratorTarget(); cmLocalGenerator* GetLocalGenerator() const; @@ -36,6 +38,9 @@ public: location is suitable for use as the LOCATION target property. */ const char* GetLocationForBuild() const; + cmComputeLinkInformation* + GetLinkInformation(const std::string& config) const; + int GetType() const; std::string GetName() const; const char *GetProperty(const std::string& prop) const; @@ -213,6 +218,10 @@ private: }; mutable std::map CompatibleInterfacesMap; + typedef std::map + cmTargetLinkInformationMap; + mutable cmTargetLinkInformationMap LinkInformation; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 8cb59f8..b44848c 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2202,7 +2202,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, } } // Add framework search paths needed for linking. - if(cmComputeLinkInformation* cli = target.GetLinkInformation(configName)) + if(cmComputeLinkInformation* cli = gtgt->GetLinkInformation(configName)) { std::vector const& fwDirs = cli->GetFrameworkPaths(); for(std::vector::const_iterator fdi = fwDirs.begin(); @@ -2358,7 +2358,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, this->CreateString(install_name_dir.c_str())); // Create the LD_RUNPATH_SEARCH_PATHS - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName); if(pcli) { std::string search_paths; @@ -2964,7 +2964,8 @@ void cmGlobalXCodeGenerator } // Compute the link library and directory information. - cmComputeLinkInformation* pcli = cmtarget->GetLinkInformation(configName); + cmGeneratorTarget* gtgt = this->GetGeneratorTarget(cmtarget); + cmComputeLinkInformation* pcli = gtgt->GetLinkInformation(configName); if(!pcli) { continue; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 01d4b77..c64f9a3 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -18,6 +18,7 @@ #include "cmMakefile.h" #include "cmGeneratorTarget.h" #include "cmake.h" +#include "cmGeneratorTarget.h" #include @@ -557,8 +558,7 @@ cmInstallTargetGenerator // Build a map of build-tree install_name to install-tree install_name for // shared libraries linked to this target. std::map install_name_remap; - if(cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config)) + if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config)) { std::set const& sharedLibs = cli->GetSharedLibrariesLinked(); @@ -667,8 +667,7 @@ cmInstallTargetGenerator // Get the link information for this target. // It can provide the RPATH. - cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config); + cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); if(!cli) { return; @@ -700,8 +699,7 @@ cmInstallTargetGenerator // Get the link information for this target. // It can provide the RPATH. - cmComputeLinkInformation* cli = - this->Target->Target->GetLinkInformation(config); + cmComputeLinkInformation* cli = this->Target->GetLinkInformation(config); if(!cli) { return; diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 6b48a44..eaf812f 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1468,7 +1468,7 @@ void cmLocalGenerator::OutputLinkLibraries(std::string& linkLibraries, bool escapeAllowMakeVars = !forResponseFile; std::ostringstream fout; std::string config = this->Makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"); - cmComputeLinkInformation* pcli = tgt.Target->GetLinkInformation(config); + cmComputeLinkInformation* pcli = tgt.GetLinkInformation(config); if(!pcli) { return; diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index cab5a47..61d7847 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1846,8 +1846,10 @@ void cmLocalVisualStudio6Generator const std::string extraOptions, std::string& options) { + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); // Compute the link information for this configuration. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 572dbde..37e08dd 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1074,6 +1074,9 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, this->ConvertToOutputFormat(this->ModuleDefinitionFile, SHELL); linkOptions.AddFlag("ModuleDefinitionFile", defFile.c_str()); } + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + if (target.GetType() == cmTarget::SHARED_LIBRARY && this->Makefile->IsOn("CMAKE_SUPPORT_WINDOWS_EXPORT_ALL_SYMBOLS")) { @@ -1148,7 +1151,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; @@ -1245,7 +1248,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. - cmComputeLinkInformation* pcli = target.GetLinkInformation(configName); + cmComputeLinkInformation* pcli = gt->GetLinkInformation(configName); if(!pcli) { return; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 5edc0f5..ac8cd29 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1446,7 +1446,8 @@ void cmMakefileTargetGenerator // Loop over all library dependencies. const char* cfg = this->LocalGenerator->GetConfigName().c_str(); - if(cmComputeLinkInformation* cli = this->Target->GetLinkInformation(cfg)) + if(cmComputeLinkInformation* cli = + this->GeneratorTarget->GetLinkInformation(cfg)) { std::vector const& libDeps = cli->GetDepends(); depends.insert(depends.end(), libDeps.begin(), libDeps.end()); diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 4e4dc3f..cf80424 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -195,7 +195,7 @@ cmNinjaDeps cmNinjaTargetGenerator::ComputeLinkDeps() const return cmNinjaDeps(); cmComputeLinkInformation* cli = - this->Target->GetLinkInformation(this->GetConfigName()); + this->GeneratorTarget->GetLinkInformation(this->GetConfigName()); if(!cli) return cmNinjaDeps(); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9c7e46a..d8904ea 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -520,8 +520,6 @@ void cmTarget::ClearLinkMaps() this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); this->Internal->LinkClosureMap.clear(); this->Internal->SourceFilesMap.clear(); - cmDeleteAll(this->LinkInformation); - this->LinkInformation.clear(); } //---------------------------------------------------------------------------- @@ -6461,37 +6459,6 @@ void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, } //---------------------------------------------------------------------------- -cmComputeLinkInformation* -cmTarget::GetLinkInformation(const std::string& config) const -{ - // Lookup any existing information for this configuration. - std::string key(cmSystemTools::UpperCase(config)); - cmTargetLinkInformationMap::iterator - i = this->LinkInformation.find(key); - if(i == this->LinkInformation.end()) - { - // Compute information for this configuration. - cmComputeLinkInformation* info = - new cmComputeLinkInformation(this, config); - if(!info || !info->Compute()) - { - delete info; - info = 0; - } - - // Store the information for this configuration. - cmTargetLinkInformationMap::value_type entry(key, info); - i = this->LinkInformation.insert(entry).first; - - if (info) - { - this->CheckPropertyCompatibility(info, config); - } - } - return i->second; -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const { @@ -6583,26 +6550,6 @@ std::string cmTarget::GetMacContentDirectory(const std::string& config, } //---------------------------------------------------------------------------- -cmTargetLinkInformationMap -::cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r): derived() -{ - // Ideally cmTarget instances should never be copied. However until - // we can make a sweep to remove that, this copy constructor avoids - // allowing the resources (LinkInformation) from getting copied. In - // the worst case this will lead to extra cmComputeLinkInformation - // instances. We also enforce in debug mode that the map be emptied - // when copied. - static_cast(r); - assert(r.empty()); -} - -//---------------------------------------------------------------------------- -cmTargetLinkInformationMap::~cmTargetLinkInformationMap() -{ - cmDeleteAll(*this); -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index df8cdc1..e3410aa 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -78,15 +78,6 @@ public: bool FromGenex; }; -struct cmTargetLinkInformationMap: - public std::map -{ - typedef std::map derived; - cmTargetLinkInformationMap() {} - cmTargetLinkInformationMap(cmTargetLinkInformationMap const& r); - ~cmTargetLinkInformationMap(); -}; - class cmTargetInternals; class cmTargetInternalPointer { @@ -454,9 +445,6 @@ public: * install tree. For example: "\@rpath/" or "\@loader_path/". */ std::string GetInstallNameDirForInstallTree() const; - cmComputeLinkInformation* - GetLinkInformation(const std::string& config) const; - // Get the properties cmPropertyMap &GetProperties() const { return this->Properties; } @@ -766,7 +754,6 @@ private: struct CompileInfo; CompileInfo const* GetCompileInfo(const std::string& config) const; - mutable cmTargetLinkInformationMap LinkInformation; void CheckPropertyCompatibility(cmComputeLinkInformation *info, const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 71785e9..f3f291a 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2438,7 +2438,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) cmSystemTools::ExpandListArgument(libs, libVec); cmComputeLinkInformation* pcli = - this->Target->GetLinkInformation(config.c_str()); + this->GeneratorTarget->GetLinkInformation(config.c_str()); if(!pcli) { cmSystemTools::Error -- cgit v0.12 From 90bad039c44195b742740613a34b90697254fdd2 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:43 +0200 Subject: cmGeneratorTarget: Move CheckPropertyCompatibility from cmTarget. --- Source/cmGeneratorTarget.cxx | 236 ++++++++++++++++++++++++++++++++++- Source/cmGeneratorTarget.h | 3 + Source/cmTarget.cxx | 285 ++++--------------------------------------- Source/cmTarget.h | 11 +- 4 files changed, 268 insertions(+), 267 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 845c052..1f3effb 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1524,6 +1524,240 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; } +template +PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string& prop, + const std::string& config, + cmTarget::CompatibleType, + PropertyType *); + +template<> +bool getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string& prop, + const std::string& config, + cmTarget::CompatibleType, bool *) +{ + return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); +} + +template<> +const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, + const std::string& prop, + const std::string& config, + cmTarget::CompatibleType t, + const char **) +{ + switch(t) + { + case cmTarget::BoolType: + assert(0 && "String compatibility check function called for boolean"); + return 0; + case cmTarget::StringType: + return tgt->GetLinkInterfaceDependentStringProperty(prop, config); + case cmTarget::NumberMinType: + return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); + case cmTarget::NumberMaxType: + return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + } + assert(0 && "Unreachable!"); + return 0; +} + +//---------------------------------------------------------------------------- +template +void checkPropertyConsistency(cmTarget const* depender, + cmTarget const* dependee, + const std::string& propName, + std::set &emitted, + const std::string& config, + cmTarget::CompatibleType t, + PropertyType *) +{ + const char *prop = dependee->GetProperty(propName); + if (!prop) + { + return; + } + + std::vector props; + cmSystemTools::ExpandListArgument(prop, props); + std::string pdir = + dependee->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT"); + pdir += "/Help/prop_tgt/"; + + for(std::vector::iterator pi = props.begin(); + pi != props.end(); ++pi) + { + std::string pname = cmSystemTools::HelpFileName(*pi); + std::string pfile = pdir + pname + ".rst"; + if(cmSystemTools::FileExists(pfile.c_str(), true)) + { + std::ostringstream e; + e << "Target \"" << dependee->GetName() << "\" has property \"" + << *pi << "\" listed in its " << propName << " property. " + "This is not allowed. Only user-defined properties may appear " + "listed in the " << propName << " property."; + depender->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); + return; + } + if(emitted.insert(*pi).second) + { + getLinkInterfaceDependentProperty(depender, *pi, config, + t, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + } + } +} + +static std::string intersect(const std::set &s1, + const std::set &s2) +{ + std::set intersect; + std::set_intersection(s1.begin(),s1.end(), + s2.begin(),s2.end(), + std::inserter(intersect,intersect.begin())); + if (!intersect.empty()) + { + return *intersect.begin(); + } + return ""; +} + +static std::string intersect(const std::set &s1, + const std::set &s2, + const std::set &s3) +{ + std::string result; + result = intersect(s1, s2); + if (!result.empty()) + return result; + result = intersect(s1, s3); + if (!result.empty()) + return result; + return intersect(s2, s3); +} + +static std::string intersect(const std::set &s1, + const std::set &s2, + const std::set &s3, + const std::set &s4) +{ + std::string result; + result = intersect(s1, s2); + if (!result.empty()) + return result; + result = intersect(s1, s3); + if (!result.empty()) + return result; + result = intersect(s1, s4); + if (!result.empty()) + return result; + return intersect(s2, s3, s4); +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::CheckPropertyCompatibility( + cmComputeLinkInformation *info, const std::string& config) const +{ + const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); + + std::set emittedBools; + static std::string strBool = "COMPATIBLE_INTERFACE_BOOL"; + std::set emittedStrings; + static std::string strString = "COMPATIBLE_INTERFACE_STRING"; + std::set emittedMinNumbers; + static std::string strNumMin = "COMPATIBLE_INTERFACE_NUMBER_MIN"; + std::set emittedMaxNumbers; + static std::string strNumMax = "COMPATIBLE_INTERFACE_NUMBER_MAX"; + + for(cmComputeLinkInformation::ItemVector::const_iterator li = + deps.begin(); li != deps.end(); ++li) + { + if (!li->Target) + { + continue; + } + + checkPropertyConsistency(this->Target, li->Target, + strBool, + emittedBools, config, cmTarget::BoolType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency(this->Target, li->Target, + strString, + emittedStrings, config, + cmTarget::StringType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency(this->Target, li->Target, + strNumMin, + emittedMinNumbers, config, + cmTarget::NumberMinType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + checkPropertyConsistency(this->Target, li->Target, + strNumMax, + emittedMaxNumbers, config, + cmTarget::NumberMaxType, 0); + if (cmSystemTools::GetErrorOccuredFlag()) + { + return; + } + } + + std::string prop = intersect(emittedBools, + emittedStrings, + emittedMinNumbers, + emittedMaxNumbers); + + if (!prop.empty()) + { + // Use a sorted std::vector to keep the error message sorted. + std::vector props; + std::set::const_iterator i = emittedBools.find(prop); + if (i != emittedBools.end()) + { + props.push_back(strBool); + } + i = emittedStrings.find(prop); + if (i != emittedStrings.end()) + { + props.push_back(strString); + } + i = emittedMinNumbers.find(prop); + if (i != emittedMinNumbers.end()) + { + props.push_back(strNumMin); + } + i = emittedMaxNumbers.find(prop); + if (i != emittedMaxNumbers.end()) + { + props.push_back(strNumMax); + } + std::sort(props.begin(), props.end()); + + std::string propsString = cmJoin(cmMakeRange(props).retreat(1), ", "); + propsString += " and the " + props.back(); + + std::ostringstream e; + e << "Property \"" << prop << "\" appears in both the " + << propsString << + " property in the dependencies of target \"" << this->GetName() << + "\". This is not allowed. A property may only require compatibility " + "in a boolean interpretation, a numeric minimum, a numeric maximum or a " + "string interpretation, but not a mixture."; + this->LocalGenerator->IssueMessage(cmake::FATAL_ERROR, e.str()); + } +} //---------------------------------------------------------------------------- cmComputeLinkInformation* @@ -1550,7 +1784,7 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const if (info) { - this->Target->CheckPropertyCompatibility(info, config); + this->CheckPropertyCompatibility(info, config); } } return i->second; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index e53f098..ae86e19 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -222,6 +222,9 @@ private: cmTargetLinkInformationMap; mutable cmTargetLinkInformationMap LinkInformation; + void CheckPropertyCompatibility(cmComputeLinkInformation *info, + const std::string& config) const; + cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); }; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d8904ea..b165545 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4554,23 +4554,16 @@ const char *getTypedProperty(cmTarget const* tgt, return tgt->GetProperty(prop); } -enum CompatibleType -{ - BoolType, - StringType, - NumberMinType, - NumberMaxType -}; - //---------------------------------------------------------------------------- template std::pair consistentProperty(PropertyType lhs, PropertyType rhs, - CompatibleType t); + cmTarget::CompatibleType t); //---------------------------------------------------------------------------- template<> -std::pair consistentProperty(bool lhs, bool rhs, CompatibleType) +std::pair consistentProperty(bool lhs, bool rhs, + cmTarget::CompatibleType) { return std::make_pair(lhs == rhs, lhs); } @@ -4585,8 +4578,8 @@ std::pair consistentStringProperty(const char *lhs, //---------------------------------------------------------------------------- std::pair consistentNumberProperty(const char *lhs, - const char *rhs, - CompatibleType t) + const char *rhs, + cmTarget::CompatibleType t) { char *pEnd; @@ -4604,7 +4597,7 @@ std::pair consistentNumberProperty(const char *lhs, return std::pair(false, null_ptr); } - if (t == NumberMaxType) + if (t == cmTarget::NumberMaxType) { return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); } @@ -4618,7 +4611,7 @@ std::pair consistentNumberProperty(const char *lhs, template<> std::pair consistentProperty(const char *lhs, const char *rhs, - CompatibleType t) + cmTarget::CompatibleType t) { if (!lhs && !rhs) { @@ -4637,13 +4630,13 @@ std::pair consistentProperty(const char *lhs, switch(t) { - case BoolType: + case cmTarget::BoolType: assert(0 && "consistentProperty for strings called with BoolType"); return std::pair(false, null_ptr); - case StringType: + case cmTarget::StringType: return consistentStringProperty(lhs, rhs); - case NumberMinType: - case NumberMaxType: + case cmTarget::NumberMinType: + case cmTarget::NumberMaxType: return consistentNumberProperty(lhs, rhs, t); } assert(0 && "Unreachable!"); @@ -4718,17 +4711,17 @@ cmTarget::ReportPropertyOrigin(const std::string &p, } //---------------------------------------------------------------------------- -std::string compatibilityType(CompatibleType t) +std::string compatibilityType(cmTarget::CompatibleType t) { switch(t) { - case BoolType: + case cmTarget::BoolType: return "Boolean compatibility"; - case StringType: + case cmTarget::StringType: return "String compatibility"; - case NumberMaxType: + case cmTarget::NumberMaxType: return "Numeric maximum compatibility"; - case NumberMinType: + case cmTarget::NumberMinType: return "Numeric minimum compatibility"; } assert(0 && "Unreachable!"); @@ -4736,15 +4729,15 @@ std::string compatibilityType(CompatibleType t) } //---------------------------------------------------------------------------- -std::string compatibilityAgree(CompatibleType t, bool dominant) +std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) { switch(t) { - case BoolType: - case StringType: + case cmTarget::BoolType: + case cmTarget::StringType: return dominant ? "(Disagree)\n" : "(Agree)\n"; - case NumberMaxType: - case NumberMinType: + case cmTarget::NumberMaxType: + case cmTarget::NumberMinType: return dominant ? "(Dominant)\n" : "(Ignored)\n"; } assert(0 && "Unreachable!"); @@ -4757,7 +4750,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, const std::string &p, const std::string& config, const char *defaultValue, - CompatibleType t, + cmTarget::CompatibleType t, PropertyType *) { PropertyType propContent = getTypedProperty(tgt, p); @@ -6224,240 +6217,6 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const return lib; } -template -PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string& prop, - const std::string& config, - CompatibleType, - PropertyType *); - -template<> -bool getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string& prop, - const std::string& config, - CompatibleType, bool *) -{ - return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); -} - -template<> -const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, - const std::string& prop, - const std::string& config, - CompatibleType t, - const char **) -{ - switch(t) - { - case BoolType: - assert(0 && "String compatibility check function called for boolean"); - return 0; - case StringType: - return tgt->GetLinkInterfaceDependentStringProperty(prop, config); - case NumberMinType: - return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); - case NumberMaxType: - return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); - } - assert(0 && "Unreachable!"); - return 0; -} - -//---------------------------------------------------------------------------- -template -void checkPropertyConsistency(cmTarget const* depender, - cmTarget const* dependee, - const std::string& propName, - std::set &emitted, - const std::string& config, - CompatibleType t, - PropertyType *) -{ - const char *prop = dependee->GetProperty(propName); - if (!prop) - { - return; - } - - std::vector props; - cmSystemTools::ExpandListArgument(prop, props); - std::string pdir = - dependee->GetMakefile()->GetRequiredDefinition("CMAKE_ROOT"); - pdir += "/Help/prop_tgt/"; - - for(std::vector::iterator pi = props.begin(); - pi != props.end(); ++pi) - { - std::string pname = cmSystemTools::HelpFileName(*pi); - std::string pfile = pdir + pname + ".rst"; - if(cmSystemTools::FileExists(pfile.c_str(), true)) - { - std::ostringstream e; - e << "Target \"" << dependee->GetName() << "\" has property \"" - << *pi << "\" listed in its " << propName << " property. " - "This is not allowed. Only user-defined properties may appear " - "listed in the " << propName << " property."; - depender->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); - return; - } - if(emitted.insert(*pi).second) - { - getLinkInterfaceDependentProperty(depender, *pi, config, - t, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - } - } -} - -static std::string intersect(const std::set &s1, - const std::set &s2) -{ - std::set intersect; - std::set_intersection(s1.begin(),s1.end(), - s2.begin(),s2.end(), - std::inserter(intersect,intersect.begin())); - if (!intersect.empty()) - { - return *intersect.begin(); - } - return ""; -} -static std::string intersect(const std::set &s1, - const std::set &s2, - const std::set &s3) -{ - std::string result; - result = intersect(s1, s2); - if (!result.empty()) - return result; - result = intersect(s1, s3); - if (!result.empty()) - return result; - return intersect(s2, s3); -} -static std::string intersect(const std::set &s1, - const std::set &s2, - const std::set &s3, - const std::set &s4) -{ - std::string result; - result = intersect(s1, s2); - if (!result.empty()) - return result; - result = intersect(s1, s3); - if (!result.empty()) - return result; - result = intersect(s1, s4); - if (!result.empty()) - return result; - return intersect(s2, s3, s4); -} - -//---------------------------------------------------------------------------- -void cmTarget::CheckPropertyCompatibility(cmComputeLinkInformation *info, - const std::string& config) const -{ - const cmComputeLinkInformation::ItemVector &deps = info->GetItems(); - - std::set emittedBools; - static std::string strBool = "COMPATIBLE_INTERFACE_BOOL"; - std::set emittedStrings; - static std::string strString = "COMPATIBLE_INTERFACE_STRING"; - std::set emittedMinNumbers; - static std::string strNumMin = "COMPATIBLE_INTERFACE_NUMBER_MIN"; - std::set emittedMaxNumbers; - static std::string strNumMax = "COMPATIBLE_INTERFACE_NUMBER_MAX"; - - for(cmComputeLinkInformation::ItemVector::const_iterator li = - deps.begin(); - li != deps.end(); ++li) - { - if (!li->Target) - { - continue; - } - - checkPropertyConsistency(this, li->Target, - strBool, - emittedBools, config, BoolType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - checkPropertyConsistency(this, li->Target, - strString, - emittedStrings, config, - StringType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - checkPropertyConsistency(this, li->Target, - strNumMin, - emittedMinNumbers, config, - NumberMinType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - checkPropertyConsistency(this, li->Target, - strNumMax, - emittedMaxNumbers, config, - NumberMaxType, 0); - if (cmSystemTools::GetErrorOccuredFlag()) - { - return; - } - } - - std::string prop = intersect(emittedBools, - emittedStrings, - emittedMinNumbers, - emittedMaxNumbers); - - if (!prop.empty()) - { - // Use a sorted std::vector to keep the error message sorted. - std::vector props; - std::set::const_iterator i = emittedBools.find(prop); - if (i != emittedBools.end()) - { - props.push_back(strBool); - } - i = emittedStrings.find(prop); - if (i != emittedStrings.end()) - { - props.push_back(strString); - } - i = emittedMinNumbers.find(prop); - if (i != emittedMinNumbers.end()) - { - props.push_back(strNumMin); - } - i = emittedMaxNumbers.find(prop); - if (i != emittedMaxNumbers.end()) - { - props.push_back(strNumMax); - } - std::sort(props.begin(), props.end()); - - std::string propsString = cmJoin(cmMakeRange(props).retreat(1), ", "); - propsString += " and the " + props.back(); - - std::ostringstream e; - e << "Property \"" << prop << "\" appears in both the " - << propsString << - " property in the dependencies of target \"" << this->GetName() << - "\". This is not allowed. A property may only require compatibility " - "in a boolean interpretation, a numeric minimum, a numeric maximum or a " - "string interpretation, but not a mixture."; - this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str()); - } -} - //---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e3410aa..8af74ef 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -590,6 +590,14 @@ public: return this->LinkLibrariesForVS6;} #endif + enum CompatibleType + { + BoolType, + StringType, + NumberMinType, + NumberMaxType + }; + private: bool HandleLocationPropertyPolicy(cmMakefile* context) const; @@ -754,9 +762,6 @@ private: struct CompileInfo; CompileInfo const* GetCompileInfo(const std::string& config) const; - void CheckPropertyCompatibility(cmComputeLinkInformation *info, - const std::string& config) const; - LinkInterface const* GetImportLinkInterface(const std::string& config, cmTarget const* head, bool usage_requirements_only) const; -- cgit v0.12 From 38d4ba3564b9a37f8042888ffd63bf736852b6b8 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:43 +0200 Subject: cmGeneratorTarget: Port internal API to cmGeneratorTarget. --- Source/cmGeneratorTarget.cxx | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 1f3effb..a7b0349 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1525,23 +1525,23 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( } template -PropertyType getLinkInterfaceDependentProperty(cmTarget const* tgt, +PropertyType getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, cmTarget::CompatibleType, PropertyType *); template<> -bool getLinkInterfaceDependentProperty(cmTarget const* tgt, +bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, cmTarget::CompatibleType, bool *) { - return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); + return tgt->Target->GetLinkInterfaceDependentBoolProperty(prop, config); } template<> -const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, +const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, cmTarget::CompatibleType t, @@ -1553,11 +1553,13 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, assert(0 && "String compatibility check function called for boolean"); return 0; case cmTarget::StringType: - return tgt->GetLinkInterfaceDependentStringProperty(prop, config); + return tgt->Target->GetLinkInterfaceDependentStringProperty(prop, config); case cmTarget::NumberMinType: - return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); + return tgt->Target + ->GetLinkInterfaceDependentNumberMinProperty(prop, config); case cmTarget::NumberMaxType: - return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + return tgt->Target + ->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } assert(0 && "Unreachable!"); return 0; @@ -1565,7 +1567,7 @@ const char * getLinkInterfaceDependentProperty(cmTarget const* tgt, //---------------------------------------------------------------------------- template -void checkPropertyConsistency(cmTarget const* depender, +void checkPropertyConsistency(cmGeneratorTarget const* depender, cmTarget const* dependee, const std::string& propName, std::set &emitted, @@ -1597,7 +1599,7 @@ void checkPropertyConsistency(cmTarget const* depender, << *pi << "\" listed in its " << propName << " property. " "This is not allowed. Only user-defined properties may appear " "listed in the " << propName << " property."; - depender->GetMakefile()->IssueMessage(cmake::FATAL_ERROR, e.str()); + depender->GetLocalGenerator()->IssueMessage(cmake::FATAL_ERROR, e.str()); return; } if(emitted.insert(*pi).second) @@ -1681,14 +1683,14 @@ void cmGeneratorTarget::CheckPropertyCompatibility( continue; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strBool, emittedBools, config, cmTarget::BoolType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strString, emittedStrings, config, cmTarget::StringType, 0); @@ -1696,7 +1698,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( { return; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strNumMin, emittedMinNumbers, config, cmTarget::NumberMinType, 0); @@ -1704,7 +1706,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( { return; } - checkPropertyConsistency(this->Target, li->Target, + checkPropertyConsistency(this, li->Target, strNumMax, emittedMaxNumbers, config, cmTarget::NumberMaxType, 0); -- cgit v0.12 From 5ff813c7a62d6c37b86bbf9a988a91baa4d5b9e6 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:43 +0200 Subject: cmGeneratorTarget: Move LinkInterfaceDependent methods from cmTarget. --- Source/cmGeneratorExpressionNode.cxx | 12 +- Source/cmGeneratorTarget.cxx | 413 ++++++++++++++++++++++++++++++++++- Source/cmGeneratorTarget.h | 11 + Source/cmLocalGenerator.cxx | 4 +- Source/cmQtAutoGenerators.cxx | 11 +- Source/cmTarget.cxx | 399 --------------------------------- Source/cmTarget.h | 9 - 7 files changed, 433 insertions(+), 426 deletions(-) diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index c1641cc..a20579b 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1142,7 +1142,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode context->Config)) { context->HadContextSensitiveCondition = true; - return target->GetLinkInterfaceDependentBoolProperty( + return gtgt->GetLinkInterfaceDependentBoolProperty( propertyName, context->Config) ? "1" : "0"; } @@ -1151,7 +1151,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentStringProperty( + gtgt->GetLinkInterfaceDependentStringProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1161,7 +1161,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMinProperty( + gtgt->GetLinkInterfaceDependentNumberMinProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1171,7 +1171,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMaxProperty( + gtgt->GetLinkInterfaceDependentNumberMaxProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1188,7 +1188,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMinProperty( + gtgt->GetLinkInterfaceDependentNumberMinProperty( propertyName, context->Config); return propContent ? propContent : ""; @@ -1198,7 +1198,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode { context->HadContextSensitiveCondition = true; const char *propContent = - target->GetLinkInterfaceDependentNumberMaxProperty( + gtgt->GetLinkInterfaceDependentNumberMaxProperty( propertyName, context->Config); return propContent ? propContent : ""; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a7b0349..a9245c0 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -24,6 +24,7 @@ #include +#include #include "assert.h" //---------------------------------------------------------------------------- @@ -753,8 +754,7 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, const std::string& config) const { const char *prop - = this->Target-> - GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", + = this->GetLinkInterfaceDependentStringProperty("AUTOUIC_OPTIONS", config); if (!prop) { @@ -1537,7 +1537,7 @@ bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& config, cmTarget::CompatibleType, bool *) { - return tgt->Target->GetLinkInterfaceDependentBoolProperty(prop, config); + return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); } template<> @@ -1553,13 +1553,11 @@ const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, assert(0 && "String compatibility check function called for boolean"); return 0; case cmTarget::StringType: - return tgt->Target->GetLinkInterfaceDependentStringProperty(prop, config); + return tgt->GetLinkInterfaceDependentStringProperty(prop, config); case cmTarget::NumberMinType: - return tgt->Target - ->GetLinkInterfaceDependentNumberMinProperty(prop, config); + return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); case cmTarget::NumberMaxType: - return tgt->Target - ->GetLinkInterfaceDependentNumberMaxProperty(prop, config); + return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } assert(0 && "Unreachable!"); return 0; @@ -1762,6 +1760,405 @@ void cmGeneratorTarget::CheckPropertyCompatibility( } //---------------------------------------------------------------------------- +std::string compatibilityType(cmTarget::CompatibleType t) +{ + switch(t) + { + case cmTarget::BoolType: + return "Boolean compatibility"; + case cmTarget::StringType: + return "String compatibility"; + case cmTarget::NumberMaxType: + return "Numeric maximum compatibility"; + case cmTarget::NumberMinType: + return "Numeric minimum compatibility"; + } + assert(0 && "Unreachable!"); + return ""; +} + +//---------------------------------------------------------------------------- +std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) +{ + switch(t) + { + case cmTarget::BoolType: + case cmTarget::StringType: + return dominant ? "(Disagree)\n" : "(Agree)\n"; + case cmTarget::NumberMaxType: + case cmTarget::NumberMinType: + return dominant ? "(Dominant)\n" : "(Ignored)\n"; + } + assert(0 && "Unreachable!"); + return ""; +} + +//---------------------------------------------------------------------------- +template +PropertyType getTypedProperty(cmTarget const* tgt, const std::string& prop); + +//---------------------------------------------------------------------------- +template<> +bool getTypedProperty(cmTarget const* tgt, const std::string& prop) +{ + return tgt->GetPropertyAsBool(prop); +} + +//---------------------------------------------------------------------------- +template<> +const char *getTypedProperty(cmTarget const* tgt, + const std::string& prop) +{ + return tgt->GetProperty(prop); +} + +template +std::string valueAsString(PropertyType); +template<> +std::string valueAsString(bool value) +{ + return value ? "TRUE" : "FALSE"; +} +template<> +std::string valueAsString(const char* value) +{ + return value ? value : "(unset)"; +} + +template +PropertyType impliedValue(PropertyType); +template<> +bool impliedValue(bool) +{ + return false; +} +template<> +const char* impliedValue(const char*) +{ + return ""; +} + +//---------------------------------------------------------------------------- +template +std::pair consistentProperty(PropertyType lhs, + PropertyType rhs, + cmTarget::CompatibleType t); + +//---------------------------------------------------------------------------- +template<> +std::pair consistentProperty(bool lhs, bool rhs, + cmTarget::CompatibleType) +{ + return std::make_pair(lhs == rhs, lhs); +} + +//---------------------------------------------------------------------------- +std::pair consistentStringProperty(const char *lhs, + const char *rhs) +{ + const bool b = strcmp(lhs, rhs) == 0; + return std::make_pair(b, b ? lhs : 0); +} + +//---------------------------------------------------------------------------- +std::pair consistentNumberProperty(const char *lhs, + const char *rhs, + cmTarget::CompatibleType t) +{ + char *pEnd; + + const char* const null_ptr = 0; + + long lnum = strtol(lhs, &pEnd, 0); + if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) + { + return std::pair(false, null_ptr); + } + + long rnum = strtol(rhs, &pEnd, 0); + if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) + { + return std::pair(false, null_ptr); + } + + if (t == cmTarget::NumberMaxType) + { + return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); + } + else + { + return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs); + } +} + +//---------------------------------------------------------------------------- +template<> +std::pair consistentProperty(const char *lhs, + const char *rhs, + cmTarget::CompatibleType t) +{ + if (!lhs && !rhs) + { + return std::make_pair(true, lhs); + } + if (!lhs) + { + return std::make_pair(true, rhs); + } + if (!rhs) + { + return std::make_pair(true, lhs); + } + + const char* const null_ptr = 0; + + switch(t) + { + case cmTarget::BoolType: + assert(0 && "consistentProperty for strings called with BoolType"); + return std::pair(false, null_ptr); + case cmTarget::StringType: + return consistentStringProperty(lhs, rhs); + case cmTarget::NumberMinType: + case cmTarget::NumberMaxType: + return consistentNumberProperty(lhs, rhs, t); + } + assert(0 && "Unreachable!"); + return std::pair(false, null_ptr); +} + +//---------------------------------------------------------------------------- +template +PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, + const std::string &p, + const std::string& config, + const char *defaultValue, + cmTarget::CompatibleType t, + PropertyType *) +{ + PropertyType propContent = getTypedProperty(tgt, p); + const bool explicitlySet = tgt->GetProperties() + .find(p) + != tgt->GetProperties().end(); + const bool impliedByUse = + tgt->IsNullImpliedByLinkLibraries(p); + assert((impliedByUse ^ explicitlySet) + || (!impliedByUse && !explicitlySet)); + + std::vector const& deps = + tgt->GetLinkImplementationClosure(config); + + if(deps.empty()) + { + return propContent; + } + bool propInitialized = explicitlySet; + + std::string report = " * Target \""; + report += tgt->GetName(); + if (explicitlySet) + { + report += "\" has property content \""; + report += valueAsString(propContent); + report += "\"\n"; + } + else if (impliedByUse) + { + report += "\" property is implied by use.\n"; + } + else + { + report += "\" property not set.\n"; + } + + std::string interfaceProperty = "INTERFACE_" + p; + for(std::vector::const_iterator li = + deps.begin(); + li != deps.end(); ++li) + { + // An error should be reported if one dependency + // has INTERFACE_POSITION_INDEPENDENT_CODE ON and the other + // has INTERFACE_POSITION_INDEPENDENT_CODE OFF, or if the + // target itself has a POSITION_INDEPENDENT_CODE which disagrees + // with a dependency. + + cmTarget const* theTarget = *li; + + const bool ifaceIsSet = theTarget->GetProperties() + .find(interfaceProperty) + != theTarget->GetProperties().end(); + PropertyType ifacePropContent = + getTypedProperty(theTarget, + interfaceProperty); + + std::string reportEntry; + if (ifaceIsSet) + { + reportEntry += " * Target \""; + reportEntry += theTarget->GetName(); + reportEntry += "\" property value \""; + reportEntry += valueAsString(ifacePropContent); + reportEntry += "\" "; + } + + if (explicitlySet) + { + if (ifaceIsSet) + { + std::pair consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) + { + std::ostringstream e; + e << "Property " << p << " on target \"" + << tgt->GetName() << "\" does\nnot match the " + "INTERFACE_" << p << " property requirement\nof " + "dependency \"" << theTarget->GetName() << "\".\n"; + cmSystemTools::Error(e.str().c_str()); + break; + } + else + { + propContent = consistent.second; + continue; + } + } + else + { + // Explicitly set on target and not set in iface. Can't disagree. + continue; + } + } + else if (impliedByUse) + { + propContent = impliedValue(propContent); + + if (ifaceIsSet) + { + std::pair consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) + { + std::ostringstream e; + e << "Property " << p << " on target \"" + << tgt->GetName() << "\" is\nimplied to be " << defaultValue + << " because it was used to determine the link libraries\n" + "already. The INTERFACE_" << p << " property on\ndependency \"" + << theTarget->GetName() << "\" is in conflict.\n"; + cmSystemTools::Error(e.str().c_str()); + break; + } + else + { + propContent = consistent.second; + continue; + } + } + else + { + // Implicitly set on target and not set in iface. Can't disagree. + continue; + } + } + else + { + if (ifaceIsSet) + { + if (propInitialized) + { + std::pair consistent = + consistentProperty(propContent, + ifacePropContent, t); + report += reportEntry; + report += compatibilityAgree(t, propContent != consistent.second); + if (!consistent.first) + { + std::ostringstream e; + e << "The INTERFACE_" << p << " property of \"" + << theTarget->GetName() << "\" does\nnot agree with the value " + "of " << p << " already determined\nfor \"" + << tgt->GetName() << "\".\n"; + cmSystemTools::Error(e.str().c_str()); + break; + } + else + { + propContent = consistent.second; + continue; + } + } + else + { + report += reportEntry + "(Interface set)\n"; + propContent = ifacePropContent; + propInitialized = true; + } + } + else + { + // Not set. Nothing to agree on. + continue; + } + } + } + + tgt->ReportPropertyOrigin(p, valueAsString(propContent), + report, compatibilityType(t)); + return propContent; +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty( + const std::string &p, const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, p, config, + "FALSE", + cmTarget::BoolType, 0); +} + +//---------------------------------------------------------------------------- +const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty( + const std::string &p, + const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, + p, + config, + "empty", + cmTarget::StringType, 0); +} + +//---------------------------------------------------------------------------- +const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty( + const std::string &p, + const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, + p, + config, + "empty", + cmTarget::NumberMinType, 0); +} + +//---------------------------------------------------------------------------- +const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty( + const std::string &p, + const std::string& config) const +{ + return checkInterfacePropertyCompatibility(this->Target, + p, + config, + "empty", + cmTarget::NumberMaxType, 0); +} + +//---------------------------------------------------------------------------- cmComputeLinkInformation* cmGeneratorTarget::GetLinkInformation(const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index ae86e19..d65b1ef 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -96,6 +96,17 @@ public: bool IsLinkInterfaceDependentNumberMaxProperty(const std::string &p, const std::string& config) const; + bool GetLinkInterfaceDependentBoolProperty(const std::string &p, + const std::string& config) const; + + const char *GetLinkInterfaceDependentStringProperty(const std::string &p, + const std::string& config) const; + const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p, + const std::string& config) const; + const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, + const std::string& config) const; + + /** Get the full path to the target according to the settings in its makefile and the configuration type. */ std::string GetFullPath(const std::string& config="", bool implib = false, diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index eaf812f..3ab501d 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -2059,7 +2059,9 @@ void cmLocalGenerator::AddCMP0018Flags(std::string &flags, return; } - if (target->GetLinkInterfaceDependentBoolProperty( + cmGeneratorTarget* gtgt = + this->GlobalGenerator->GetGeneratorTarget(target); + if (gtgt->GetLinkInterfaceDependentBoolProperty( "POSITION_INDEPENDENT_CODE", config)) { diff --git a/Source/cmQtAutoGenerators.cxx b/Source/cmQtAutoGenerators.cxx index a72b176..f1ba2f4 100644 --- a/Source/cmQtAutoGenerators.cxx +++ b/Source/cmQtAutoGenerators.cxx @@ -547,8 +547,11 @@ void cmQtAutoGenerators::SetupAutoGenerateTarget(cmTarget const* target) { qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); } + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); if (const char *targetQtVersion = - target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) + gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) { qtVersion = targetQtVersion; } @@ -1150,6 +1153,9 @@ void cmQtAutoGenerators::SetupAutoRccTarget(cmTarget const* target) std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target) { + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); cmMakefile *makefile = target->GetMakefile(); const char *qtVersion = makefile->GetDefinition("_target_qt_version"); if (!qtVersion) @@ -1160,8 +1166,7 @@ std::string cmQtAutoGenerators::GetRccExecutable(cmTarget const* target) qtVersion = makefile->GetDefinition("QT_VERSION_MAJOR"); } if (const char *targetQtVersion = - target->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", - "")) + gtgt->GetLinkInterfaceDependentStringProperty("QT_MAJOR_VERSION", "")) { qtVersion = targetQtVersion; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b165545..1fa62e7 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4536,141 +4536,6 @@ bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) const } //---------------------------------------------------------------------------- -template -PropertyType getTypedProperty(cmTarget const* tgt, const std::string& prop); - -//---------------------------------------------------------------------------- -template<> -bool getTypedProperty(cmTarget const* tgt, const std::string& prop) -{ - return tgt->GetPropertyAsBool(prop); -} - -//---------------------------------------------------------------------------- -template<> -const char *getTypedProperty(cmTarget const* tgt, - const std::string& prop) -{ - return tgt->GetProperty(prop); -} - -//---------------------------------------------------------------------------- -template -std::pair consistentProperty(PropertyType lhs, - PropertyType rhs, - cmTarget::CompatibleType t); - -//---------------------------------------------------------------------------- -template<> -std::pair consistentProperty(bool lhs, bool rhs, - cmTarget::CompatibleType) -{ - return std::make_pair(lhs == rhs, lhs); -} - -//---------------------------------------------------------------------------- -std::pair consistentStringProperty(const char *lhs, - const char *rhs) -{ - const bool b = strcmp(lhs, rhs) == 0; - return std::make_pair(b, b ? lhs : 0); -} - -//---------------------------------------------------------------------------- -std::pair consistentNumberProperty(const char *lhs, - const char *rhs, - cmTarget::CompatibleType t) -{ - char *pEnd; - - const char* const null_ptr = 0; - - long lnum = strtol(lhs, &pEnd, 0); - if (pEnd == lhs || *pEnd != '\0' || errno == ERANGE) - { - return std::pair(false, null_ptr); - } - - long rnum = strtol(rhs, &pEnd, 0); - if (pEnd == rhs || *pEnd != '\0' || errno == ERANGE) - { - return std::pair(false, null_ptr); - } - - if (t == cmTarget::NumberMaxType) - { - return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); - } - else - { - return std::make_pair(true, std::min(lnum, rnum) == lnum ? lhs : rhs); - } -} - -//---------------------------------------------------------------------------- -template<> -std::pair consistentProperty(const char *lhs, - const char *rhs, - cmTarget::CompatibleType t) -{ - if (!lhs && !rhs) - { - return std::make_pair(true, lhs); - } - if (!lhs) - { - return std::make_pair(true, rhs); - } - if (!rhs) - { - return std::make_pair(true, lhs); - } - - const char* const null_ptr = 0; - - switch(t) - { - case cmTarget::BoolType: - assert(0 && "consistentProperty for strings called with BoolType"); - return std::pair(false, null_ptr); - case cmTarget::StringType: - return consistentStringProperty(lhs, rhs); - case cmTarget::NumberMinType: - case cmTarget::NumberMaxType: - return consistentNumberProperty(lhs, rhs, t); - } - assert(0 && "Unreachable!"); - return std::pair(false, null_ptr); -} - -template -PropertyType impliedValue(PropertyType); -template<> -bool impliedValue(bool) -{ - return false; -} -template<> -const char* impliedValue(const char*) -{ - return ""; -} - - -template -std::string valueAsString(PropertyType); -template<> -std::string valueAsString(bool value) -{ - return value ? "TRUE" : "FALSE"; -} -template<> -std::string valueAsString(const char* value) -{ - return value ? value : "(unset)"; -} - -//---------------------------------------------------------------------------- void cmTarget::ReportPropertyOrigin(const std::string &p, const std::string &result, @@ -4711,270 +4576,6 @@ cmTarget::ReportPropertyOrigin(const std::string &p, } //---------------------------------------------------------------------------- -std::string compatibilityType(cmTarget::CompatibleType t) -{ - switch(t) - { - case cmTarget::BoolType: - return "Boolean compatibility"; - case cmTarget::StringType: - return "String compatibility"; - case cmTarget::NumberMaxType: - return "Numeric maximum compatibility"; - case cmTarget::NumberMinType: - return "Numeric minimum compatibility"; - } - assert(0 && "Unreachable!"); - return ""; -} - -//---------------------------------------------------------------------------- -std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) -{ - switch(t) - { - case cmTarget::BoolType: - case cmTarget::StringType: - return dominant ? "(Disagree)\n" : "(Agree)\n"; - case cmTarget::NumberMaxType: - case cmTarget::NumberMinType: - return dominant ? "(Dominant)\n" : "(Ignored)\n"; - } - assert(0 && "Unreachable!"); - return ""; -} - -//---------------------------------------------------------------------------- -template -PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, - const std::string &p, - const std::string& config, - const char *defaultValue, - cmTarget::CompatibleType t, - PropertyType *) -{ - PropertyType propContent = getTypedProperty(tgt, p); - const bool explicitlySet = tgt->GetProperties() - .find(p) - != tgt->GetProperties().end(); - const bool impliedByUse = - tgt->IsNullImpliedByLinkLibraries(p); - assert((impliedByUse ^ explicitlySet) - || (!impliedByUse && !explicitlySet)); - - std::vector const& deps = - tgt->GetLinkImplementationClosure(config); - - if(deps.empty()) - { - return propContent; - } - bool propInitialized = explicitlySet; - - std::string report = " * Target \""; - report += tgt->GetName(); - if (explicitlySet) - { - report += "\" has property content \""; - report += valueAsString(propContent); - report += "\"\n"; - } - else if (impliedByUse) - { - report += "\" property is implied by use.\n"; - } - else - { - report += "\" property not set.\n"; - } - - std::string interfaceProperty = "INTERFACE_" + p; - for(std::vector::const_iterator li = - deps.begin(); - li != deps.end(); ++li) - { - // An error should be reported if one dependency - // has INTERFACE_POSITION_INDEPENDENT_CODE ON and the other - // has INTERFACE_POSITION_INDEPENDENT_CODE OFF, or if the - // target itself has a POSITION_INDEPENDENT_CODE which disagrees - // with a dependency. - - cmTarget const* theTarget = *li; - - const bool ifaceIsSet = theTarget->GetProperties() - .find(interfaceProperty) - != theTarget->GetProperties().end(); - PropertyType ifacePropContent = - getTypedProperty(theTarget, - interfaceProperty); - - std::string reportEntry; - if (ifaceIsSet) - { - reportEntry += " * Target \""; - reportEntry += theTarget->GetName(); - reportEntry += "\" property value \""; - reportEntry += valueAsString(ifacePropContent); - reportEntry += "\" "; - } - - if (explicitlySet) - { - if (ifaceIsSet) - { - std::pair consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "Property " << p << " on target \"" - << tgt->GetName() << "\" does\nnot match the " - "INTERFACE_" << p << " property requirement\nof " - "dependency \"" << theTarget->GetName() << "\".\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - // Explicitly set on target and not set in iface. Can't disagree. - continue; - } - } - else if (impliedByUse) - { - propContent = impliedValue(propContent); - - if (ifaceIsSet) - { - std::pair consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "Property " << p << " on target \"" - << tgt->GetName() << "\" is\nimplied to be " << defaultValue - << " because it was used to determine the link libraries\n" - "already. The INTERFACE_" << p << " property on\ndependency \"" - << theTarget->GetName() << "\" is in conflict.\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - // Implicitly set on target and not set in iface. Can't disagree. - continue; - } - } - else - { - if (ifaceIsSet) - { - if (propInitialized) - { - std::pair consistent = - consistentProperty(propContent, - ifacePropContent, t); - report += reportEntry; - report += compatibilityAgree(t, propContent != consistent.second); - if (!consistent.first) - { - std::ostringstream e; - e << "The INTERFACE_" << p << " property of \"" - << theTarget->GetName() << "\" does\nnot agree with the value " - "of " << p << " already determined\nfor \"" - << tgt->GetName() << "\".\n"; - cmSystemTools::Error(e.str().c_str()); - break; - } - else - { - propContent = consistent.second; - continue; - } - } - else - { - report += reportEntry + "(Interface set)\n"; - propContent = ifacePropContent; - propInitialized = true; - } - } - else - { - // Not set. Nothing to agree on. - continue; - } - } - } - - tgt->ReportPropertyOrigin(p, valueAsString(propContent), - report, compatibilityType(t)); - return propContent; -} - -//---------------------------------------------------------------------------- -bool cmTarget::GetLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, p, config, "FALSE", - BoolType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentStringProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, - p, - config, - "empty", - StringType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentNumberMinProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, - p, - config, - "empty", - NumberMinType, 0); -} - -//---------------------------------------------------------------------------- -const char * cmTarget::GetLinkInterfaceDependentNumberMaxProperty( - const std::string &p, - const std::string& config) const -{ - return checkInterfacePropertyCompatibility(this, - p, - config, - "empty", - NumberMaxType, 0); -} - -//---------------------------------------------------------------------------- void cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8af74ef..b544b0b 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -553,15 +553,6 @@ public: const std::string& config) const; bool IsNullImpliedByLinkLibraries(const std::string &p) const; - bool GetLinkInterfaceDependentBoolProperty(const std::string &p, - const std::string& config) const; - - const char *GetLinkInterfaceDependentStringProperty(const std::string &p, - const std::string& config) const; - const char *GetLinkInterfaceDependentNumberMinProperty(const std::string &p, - const std::string& config) const; - const char *GetLinkInterfaceDependentNumberMaxProperty(const std::string &p, - const std::string& config) const; std::string GetDebugGeneratorExpressions(const std::string &value, cmTarget::LinkLibraryType llt) const; -- cgit v0.12 From 4b86f5edc91ba649908f5b6ab0fb7f1154e38066 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:43 +0200 Subject: cmGeneratorTarget: Make CompatibleType enum private again. --- Source/cmGeneratorTarget.cxx | 80 ++++++++++++++++++++++++-------------------- Source/cmTarget.h | 8 ----- 2 files changed, 44 insertions(+), 44 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a9245c0..fe73fee 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1524,18 +1524,26 @@ bool cmGeneratorTarget::IsLinkInterfaceDependentNumberMaxProperty( return this->GetCompatibleInterfaces(config).PropsNumberMax.count(p) > 0; } +enum CompatibleType +{ + BoolType, + StringType, + NumberMinType, + NumberMaxType +}; + template PropertyType getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, - cmTarget::CompatibleType, + CompatibleType, PropertyType *); template<> bool getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, - cmTarget::CompatibleType, bool *) + CompatibleType, bool *) { return tgt->GetLinkInterfaceDependentBoolProperty(prop, config); } @@ -1544,19 +1552,19 @@ template<> const char * getLinkInterfaceDependentProperty(cmGeneratorTarget const* tgt, const std::string& prop, const std::string& config, - cmTarget::CompatibleType t, + CompatibleType t, const char **) { switch(t) { - case cmTarget::BoolType: + case BoolType: assert(0 && "String compatibility check function called for boolean"); return 0; - case cmTarget::StringType: + case StringType: return tgt->GetLinkInterfaceDependentStringProperty(prop, config); - case cmTarget::NumberMinType: + case NumberMinType: return tgt->GetLinkInterfaceDependentNumberMinProperty(prop, config); - case cmTarget::NumberMaxType: + case NumberMaxType: return tgt->GetLinkInterfaceDependentNumberMaxProperty(prop, config); } assert(0 && "Unreachable!"); @@ -1570,7 +1578,7 @@ void checkPropertyConsistency(cmGeneratorTarget const* depender, const std::string& propName, std::set &emitted, const std::string& config, - cmTarget::CompatibleType t, + CompatibleType t, PropertyType *) { const char *prop = dependee->GetProperty(propName); @@ -1683,7 +1691,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strBool, - emittedBools, config, cmTarget::BoolType, 0); + emittedBools, config, BoolType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1691,7 +1699,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strString, emittedStrings, config, - cmTarget::StringType, 0); + StringType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1699,7 +1707,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strNumMin, emittedMinNumbers, config, - cmTarget::NumberMinType, 0); + NumberMinType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1707,7 +1715,7 @@ void cmGeneratorTarget::CheckPropertyCompatibility( checkPropertyConsistency(this, li->Target, strNumMax, emittedMaxNumbers, config, - cmTarget::NumberMaxType, 0); + NumberMaxType, 0); if (cmSystemTools::GetErrorOccuredFlag()) { return; @@ -1760,17 +1768,17 @@ void cmGeneratorTarget::CheckPropertyCompatibility( } //---------------------------------------------------------------------------- -std::string compatibilityType(cmTarget::CompatibleType t) +std::string compatibilityType(CompatibleType t) { switch(t) { - case cmTarget::BoolType: + case BoolType: return "Boolean compatibility"; - case cmTarget::StringType: + case StringType: return "String compatibility"; - case cmTarget::NumberMaxType: + case NumberMaxType: return "Numeric maximum compatibility"; - case cmTarget::NumberMinType: + case NumberMinType: return "Numeric minimum compatibility"; } assert(0 && "Unreachable!"); @@ -1778,15 +1786,15 @@ std::string compatibilityType(cmTarget::CompatibleType t) } //---------------------------------------------------------------------------- -std::string compatibilityAgree(cmTarget::CompatibleType t, bool dominant) +std::string compatibilityAgree(CompatibleType t, bool dominant) { switch(t) { - case cmTarget::BoolType: - case cmTarget::StringType: + case BoolType: + case StringType: return dominant ? "(Disagree)\n" : "(Agree)\n"; - case cmTarget::NumberMaxType: - case cmTarget::NumberMinType: + case NumberMaxType: + case NumberMinType: return dominant ? "(Dominant)\n" : "(Ignored)\n"; } assert(0 && "Unreachable!"); @@ -1842,12 +1850,12 @@ const char* impliedValue(const char*) template std::pair consistentProperty(PropertyType lhs, PropertyType rhs, - cmTarget::CompatibleType t); + CompatibleType t); //---------------------------------------------------------------------------- template<> std::pair consistentProperty(bool lhs, bool rhs, - cmTarget::CompatibleType) + CompatibleType) { return std::make_pair(lhs == rhs, lhs); } @@ -1863,7 +1871,7 @@ std::pair consistentStringProperty(const char *lhs, //---------------------------------------------------------------------------- std::pair consistentNumberProperty(const char *lhs, const char *rhs, - cmTarget::CompatibleType t) + CompatibleType t) { char *pEnd; @@ -1881,7 +1889,7 @@ std::pair consistentNumberProperty(const char *lhs, return std::pair(false, null_ptr); } - if (t == cmTarget::NumberMaxType) + if (t == NumberMaxType) { return std::make_pair(true, std::max(lnum, rnum) == lnum ? lhs : rhs); } @@ -1895,7 +1903,7 @@ std::pair consistentNumberProperty(const char *lhs, template<> std::pair consistentProperty(const char *lhs, const char *rhs, - cmTarget::CompatibleType t) + CompatibleType t) { if (!lhs && !rhs) { @@ -1914,13 +1922,13 @@ std::pair consistentProperty(const char *lhs, switch(t) { - case cmTarget::BoolType: + case BoolType: assert(0 && "consistentProperty for strings called with BoolType"); return std::pair(false, null_ptr); - case cmTarget::StringType: + case StringType: return consistentStringProperty(lhs, rhs); - case cmTarget::NumberMinType: - case cmTarget::NumberMaxType: + case NumberMinType: + case NumberMaxType: return consistentNumberProperty(lhs, rhs, t); } assert(0 && "Unreachable!"); @@ -1933,7 +1941,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, const std::string &p, const std::string& config, const char *defaultValue, - cmTarget::CompatibleType t, + CompatibleType t, PropertyType *) { PropertyType propContent = getTypedProperty(tgt, p); @@ -2119,7 +2127,7 @@ bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty( { return checkInterfacePropertyCompatibility(this->Target, p, config, "FALSE", - cmTarget::BoolType, 0); + BoolType, 0); } //---------------------------------------------------------------------------- @@ -2131,7 +2139,7 @@ const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty( p, config, "empty", - cmTarget::StringType, 0); + StringType, 0); } //---------------------------------------------------------------------------- @@ -2143,7 +2151,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty( p, config, "empty", - cmTarget::NumberMinType, 0); + NumberMinType, 0); } //---------------------------------------------------------------------------- @@ -2155,7 +2163,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty( p, config, "empty", - cmTarget::NumberMaxType, 0); + NumberMaxType, 0); } //---------------------------------------------------------------------------- diff --git a/Source/cmTarget.h b/Source/cmTarget.h index b544b0b..795753e 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -581,14 +581,6 @@ public: return this->LinkLibrariesForVS6;} #endif - enum CompatibleType - { - BoolType, - StringType, - NumberMinType, - NumberMaxType - }; - private: bool HandleLocationPropertyPolicy(cmMakefile* context) const; -- cgit v0.12 From 97f10e488a5153e45d6a27a730cc1ecbaae7d559 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:44 +0200 Subject: cmGeneratorTarget: Move ReportPropertyOrigin from cmTarget. --- Source/cmGeneratorTarget.cxx | 60 ++++++++++++++++++++++++++++++++++++-------- Source/cmGeneratorTarget.h | 7 ++++++ Source/cmTarget.cxx | 40 ----------------------------- Source/cmTarget.h | 6 ----- 4 files changed, 57 insertions(+), 56 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index fe73fee..521a5b7 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1937,24 +1937,24 @@ std::pair consistentProperty(const char *lhs, //---------------------------------------------------------------------------- template -PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, +PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, const std::string &p, const std::string& config, const char *defaultValue, CompatibleType t, PropertyType *) { - PropertyType propContent = getTypedProperty(tgt, p); - const bool explicitlySet = tgt->GetProperties() + PropertyType propContent = getTypedProperty(tgt->Target, p); + const bool explicitlySet = tgt->Target->GetProperties() .find(p) - != tgt->GetProperties().end(); + != tgt->Target->GetProperties().end(); const bool impliedByUse = - tgt->IsNullImpliedByLinkLibraries(p); + tgt->Target->IsNullImpliedByLinkLibraries(p); assert((impliedByUse ^ explicitlySet) || (!impliedByUse && !explicitlySet)); std::vector const& deps = - tgt->GetLinkImplementationClosure(config); + tgt->Target->GetLinkImplementationClosure(config); if(deps.empty()) { @@ -2125,7 +2125,7 @@ PropertyType checkInterfacePropertyCompatibility(cmTarget const* tgt, bool cmGeneratorTarget::GetLinkInterfaceDependentBoolProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, p, config, + return checkInterfacePropertyCompatibility(this, p, config, "FALSE", BoolType, 0); } @@ -2135,7 +2135,7 @@ const char* cmGeneratorTarget::GetLinkInterfaceDependentStringProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, + return checkInterfacePropertyCompatibility(this, p, config, "empty", @@ -2147,7 +2147,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMinProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, + return checkInterfacePropertyCompatibility(this, p, config, "empty", @@ -2159,7 +2159,7 @@ const char * cmGeneratorTarget::GetLinkInterfaceDependentNumberMaxProperty( const std::string &p, const std::string& config) const { - return checkInterfacePropertyCompatibility(this->Target, + return checkInterfacePropertyCompatibility(this, p, config, "empty", @@ -2196,3 +2196,43 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const } return i->second; } + +//---------------------------------------------------------------------------- +void +cmGeneratorTarget::ReportPropertyOrigin(const std::string &p, + const std::string &result, + const std::string &report, + const std::string &compatibilityType) const +{ + std::vector debugProperties; + const char *debugProp = this->Target->GetMakefile() + ->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); + if (debugProp) + { + cmSystemTools::ExpandListArgument(debugProp, debugProperties); + } + + bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] + && std::find(debugProperties.begin(), + debugProperties.end(), + p) + != debugProperties.end(); + + if (this->Target->GetMakefile()->IsConfigured()) + { + this->DebugCompatiblePropertiesDone[p] = true; + } + if (!debugOrigin) + { + return; + } + + std::string areport = compatibilityType; + areport += std::string(" of property \"") + p + "\" for target \""; + areport += std::string(this->GetName()); + areport += "\" (result: \""; + areport += result; + areport += "\"):\n" + report; + + this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index d65b1ef..8e68d39 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -199,6 +199,11 @@ public: std::vector XamlSources; }; + void ReportPropertyOrigin(const std::string &p, + const std::string &result, + const std::string &report, + const std::string &compatibilityType) const; + private: friend class cmTargetTraceDependencies; struct SourceEntry { std::vector Depends; }; @@ -212,6 +217,8 @@ private: mutable bool SourceFileFlagsConstructed; mutable std::map SourceFlagsMap; + mutable std::map DebugCompatiblePropertiesDone; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1fa62e7..968bd9d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4537,46 +4537,6 @@ bool cmTarget::IsNullImpliedByLinkLibraries(const std::string &p) const //---------------------------------------------------------------------------- void -cmTarget::ReportPropertyOrigin(const std::string &p, - const std::string &result, - const std::string &report, - const std::string &compatibilityType) const -{ - std::vector debugProperties; - const char *debugProp = - this->Makefile->GetDefinition("CMAKE_DEBUG_TARGET_PROPERTIES"); - if (debugProp) - { - cmSystemTools::ExpandListArgument(debugProp, debugProperties); - } - - bool debugOrigin = !this->DebugCompatiblePropertiesDone[p] - && std::find(debugProperties.begin(), - debugProperties.end(), - p) - != debugProperties.end(); - - if (this->Makefile->IsConfigured()) - { - this->DebugCompatiblePropertiesDone[p] = true; - } - if (!debugOrigin) - { - return; - } - - std::string areport = compatibilityType; - areport += std::string(" of property \"") + p + "\" for target \""; - areport += std::string(this->GetName()); - areport += "\" (result: \""; - areport += result; - areport += "\"):\n" + report; - - this->Makefile->GetCMakeInstance()->IssueMessage(cmake::LOG, areport); -} - -//---------------------------------------------------------------------------- -void cmTarget::GetObjectLibrariesCMP0026(std::vector& objlibs) const { // At configure-time, this method can be called as part of getting the diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 795753e..85d9964 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -565,11 +565,6 @@ public: bool LinkLanguagePropagatesToDependents() const { return this->TargetTypeValue == STATIC_LIBRARY; } - void ReportPropertyOrigin(const std::string &p, - const std::string &result, - const std::string &report, - const std::string &compatibilityType) const; - std::map const& GetMaxLanguageStandards() const { @@ -676,7 +671,6 @@ private: std::set Utilities; mutable std::set LinkImplicitNullProperties; std::map UtilityBacktraces; - mutable std::map DebugCompatiblePropertiesDone; mutable std::map MaxLanguageStandards; cmPolicies::PolicyMap PolicyMap; std::string Name; -- cgit v0.12 From 7da4c9d4edbdd6df6aa2a9467d6f32a98fc8cac4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:44 +0200 Subject: cmGeneratorTarget: Move GetLinkImplementationClosure --- Source/cmGeneratorTarget.cxx | 54 +++++++++++++++++++++++++++++++++++++++++--- Source/cmGeneratorTarget.h | 12 ++++++++++ Source/cmTarget.cxx | 54 -------------------------------------------- Source/cmTarget.h | 3 --- 4 files changed, 63 insertions(+), 60 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 521a5b7..f9f23a6 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -618,7 +618,7 @@ bool cmGeneratorTarget::IsSystemIncludeDirectory(const std::string& dir, } std::vector const& deps = - this->Target->GetLinkImplementationClosure(config); + this->GetLinkImplementationClosure(config); for(std::vector::const_iterator li = deps.begin(), le = deps.end(); li != le; ++li) { @@ -775,6 +775,54 @@ void cmGeneratorTarget::GetAutoUicOptions(std::vector &result, } //---------------------------------------------------------------------------- +void processILibs(const std::string& config, + cmTarget const* headTarget, + cmLinkItem const& item, + std::vector& tgts, + std::set& emitted) +{ + if (item.Target && emitted.insert(item.Target).second) + { + tgts.push_back(item.Target); + if(cmTarget::LinkInterfaceLibraries const* iface = + item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) + { + for(std::vector::const_iterator + it = iface->Libraries.begin(); + it != iface->Libraries.end(); ++it) + { + processILibs(config, headTarget, *it, tgts, emitted); + } + } + } +} + +//---------------------------------------------------------------------------- +const std::vector& +cmGeneratorTarget::GetLinkImplementationClosure( + const std::string& config) const +{ + LinkImplClosure& tgts = + this->LinkImplClosureMap[config]; + if(!tgts.Done) + { + tgts.Done = true; + std::set emitted; + + cmTarget::LinkImplementationLibraries const* impl + = this->Target->GetLinkImplementationLibraries(config); + + for(std::vector::const_iterator + it = impl->Libraries.begin(); + it != impl->Libraries.end(); ++it) + { + processILibs(config, this->Target, *it, tgts , emitted); + } + } + return tgts; +} + +//---------------------------------------------------------------------------- class cmTargetTraceDependencies { public: @@ -1455,7 +1503,7 @@ cmGeneratorTarget::GetCompatibleInterfaces(std::string const& config) const compat.PropsBool.insert("POSITION_INDEPENDENT_CODE"); compat.PropsString.insert("AUTOUIC_OPTIONS"); std::vector const& deps = - this->Target->GetLinkImplementationClosure(config); + this->GetLinkImplementationClosure(config); for(std::vector::const_iterator li = deps.begin(); li != deps.end(); ++li) { @@ -1954,7 +2002,7 @@ PropertyType checkInterfacePropertyCompatibility(cmGeneratorTarget const* tgt, || (!impliedByUse && !explicitlySet)); std::vector const& deps = - tgt->Target->GetLinkImplementationClosure(config); + tgt->GetLinkImplementationClosure(config); if(deps.empty()) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8e68d39..1303ee4 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -245,6 +245,18 @@ private: cmGeneratorTarget(cmGeneratorTarget const&); void operator=(cmGeneratorTarget const&); + + struct LinkImplClosure: public std::vector + { + LinkImplClosure(): Done(false) {} + bool Done; + }; + mutable std::map LinkImplClosureMap; + +public: + std::vector const& + GetLinkImplementationClosure(const std::string& config) const; + }; struct cmStrictTargetComparison { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 968bd9d..ded5363 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -163,13 +163,6 @@ public: typedef std::map LinkClosureMapType; LinkClosureMapType LinkClosureMap; - struct LinkImplClosure: public std::vector - { - LinkImplClosure(): Done(false) {} - bool Done; - }; - std::map LinkImplClosureMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -5175,53 +5168,6 @@ cmTarget::GetImportLinkInterface(const std::string& config, } //---------------------------------------------------------------------------- -void processILibs(const std::string& config, - cmTarget const* headTarget, - cmLinkItem const& item, - std::vector& tgts, - std::set& emitted) -{ - if (item.Target && emitted.insert(item.Target).second) - { - tgts.push_back(item.Target); - if(cmTarget::LinkInterfaceLibraries const* iface = - item.Target->GetLinkInterfaceLibraries(config, headTarget, true)) - { - for(std::vector::const_iterator - it = iface->Libraries.begin(); - it != iface->Libraries.end(); ++it) - { - processILibs(config, headTarget, *it, tgts, emitted); - } - } - } -} - -//---------------------------------------------------------------------------- -std::vector const& -cmTarget::GetLinkImplementationClosure(const std::string& config) const -{ - cmTargetInternals::LinkImplClosure& tgts = - this->Internal->LinkImplClosureMap[config]; - if(!tgts.Done) - { - tgts.Done = true; - std::set emitted; - - cmTarget::LinkImplementationLibraries const* impl - = this->GetLinkImplementationLibraries(config); - - for(std::vector::const_iterator - it = impl->Libraries.begin(); - it != impl->Libraries.end(); ++it) - { - processILibs(config, this, *it, tgts , emitted); - } - } - return tgts; -} - -//---------------------------------------------------------------------------- void cmTargetInternals::ComputeLinkInterfaceLibraries( cmTarget const* thisTarget, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 85d9964..925e7c6 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -293,9 +293,6 @@ public: cmTarget const* headTarget, bool usage_requirements_only) const; - std::vector const& - GetLinkImplementationClosure(const std::string& config) const; - /** The link implementation specifies the direct library dependencies needed by the object files of the target. */ struct LinkImplementationLibraries -- cgit v0.12 From 47803e6f8e98984e740acf2f7c0a217de58717cd Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:44 +0200 Subject: cmGeneratorTarget: Move GetExecutableNames from cmTarget. --- Source/cmGeneratorTarget.cxx | 68 ++++++++++++++++++++++++-- Source/cmGeneratorTarget.h | 6 +++ Source/cmInstallTargetGenerator.cxx | 7 ++- Source/cmLocalVisualStudio7Generator.cxx | 2 +- Source/cmMakefileExecutableTargetGenerator.cxx | 4 +- Source/cmNinjaNormalTargetGenerator.cxx | 2 +- Source/cmTarget.cxx | 62 ----------------------- Source/cmTarget.h | 8 --- Source/cmVisualStudio10TargetGenerator.cxx | 2 +- 9 files changed, 81 insertions(+), 80 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index f9f23a6..6a693f1 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1248,8 +1248,7 @@ void cmGeneratorTarget::GenerateTargetManifest( std::string pdbName; if(this->GetType() == cmTarget::EXECUTABLE) { - this->Target->GetExecutableNames(name, realName, impName, pdbName, - config); + this->GetExecutableNames(name, realName, impName, pdbName, config); } else if(this->GetType() == cmTarget::STATIC_LIBRARY || this->GetType() == cmTarget::SHARED_LIBRARY || @@ -1368,7 +1367,7 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const std::string realName; std::string impName; std::string pdbName; - this->Target->GetExecutableNames(name, realName, impName, pdbName, config); + this->GetExecutableNames(name, realName, impName, pdbName, config); return realName; } else @@ -1385,6 +1384,69 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const } } +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetExecutableNames(std::string& name, + std::string& realName, + std::string& impName, + std::string& pdbName, + const std::string& config) const +{ + // This should not be called for imported targets. + // TODO: Split cmTarget into a class hierarchy to get compile-time + // enforcement of the limited imported target API. + if(this->Target->IsImported()) + { + std::string msg = + "GetExecutableNames called on imported target: "; + msg += this->GetName(); + this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, msg); + } + + // This versioning is supported only for executables and then only + // when the platform supports symbolic links. +#if defined(_WIN32) && !defined(__CYGWIN__) + const char* version = 0; +#else + // Check for executable version properties. + const char* version = this->GetProperty("VERSION"); + if(this->GetType() != cmTarget::EXECUTABLE || this->Makefile->IsOn("XCODE")) + { + version = 0; + } +#endif + + // Get the components of the executable name. + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + // The executable name. + name = prefix+base+suffix; + + // The executable's real name on disk. +#if defined(__CYGWIN__) + realName = prefix+base; +#else + realName = name; +#endif + if(version) + { + realName += "-"; + realName += version; + } +#if defined(__CYGWIN__) + realName += suffix; +#endif + + // The import library name. + impName = this->Target->GetFullNameInternal(config, true); + + // The program database file name. + pdbName = this->Target->GetPDBName(config); +} + + bool cmStrictTargetComparison::operator()(cmTarget const* t1, cmTarget const* t2) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 1303ee4..49aa65b 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -184,6 +184,12 @@ public: void GetAutoUicOptions(std::vector &result, const std::string& config) const; + /** Get the names of the executable needed to generate a build rule + that takes into account executable version numbers. This should + be called only on an executable target. */ + void GetExecutableNames(std::string& name, std::string& realName, + std::string& impName, std::string& pdbName, + const std::string& config) const; struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index c64f9a3..c872859 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -125,7 +125,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->Target->GetExecutableNames(targetName, targetNameReal, + this->Target->GetExecutableNames(targetName, targetNameReal, targetNameImport, targetNamePDB, config); if(this->ImportLibrary) @@ -372,13 +372,16 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, { std::string fname; // Compute the name of the library. + cmGeneratorTarget *gtgt = target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); if(target->GetType() == cmTarget::EXECUTABLE) { std::string targetName; std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - target->GetExecutableNames(targetName, targetNameReal, + gtgt->GetExecutableNames(targetName, targetNameReal, targetNameImport, targetNamePDB, config); if(nameType == NameImplib) diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 37e08dd..daac331 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1244,7 +1244,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, std::string targetNameFull; std::string targetNameImport; std::string targetNamePDB; - target.GetExecutableNames(targetName, targetNameFull, + gt->GetExecutableNames(targetName, targetNameFull, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 416063f..31a78ad 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -25,7 +25,7 @@ cmMakefileExecutableTargetGenerator cmMakefileTargetGenerator(target) { this->CustomCommandDriver = OnDepends; - this->Target->GetExecutableNames( + this->GeneratorTarget->GetExecutableNames( this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, this->ConfigName); @@ -94,7 +94,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->GetExecutableNames + this->GeneratorTarget->GetExecutableNames (targetName, targetNameReal, targetNameImport, targetNamePDB, this->ConfigName); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index c9fa7c0..737510f 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -43,7 +43,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) this->TargetLinkLanguage = target->Target ->GetLinkerLanguage(this->GetConfigName()); if (target->GetType() == cmTarget::EXECUTABLE) - target->Target->GetExecutableNames(this->TargetNameOut, + this->GetGeneratorTarget()->GetExecutableNames(this->TargetNameOut, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index ded5363..22b76e9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3968,68 +3968,6 @@ void cmTarget::ComputeVersionedName(std::string& vName, } //---------------------------------------------------------------------------- -void cmTarget::GetExecutableNames(std::string& name, - std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const -{ - // This should not be called for imported targets. - // TODO: Split cmTarget into a class hierarchy to get compile-time - // enforcement of the limited imported target API. - if(this->IsImported()) - { - std::string msg = - "GetExecutableNames called on imported target: "; - msg += this->GetName(); - this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); - } - - // This versioning is supported only for executables and then only - // when the platform supports symbolic links. -#if defined(_WIN32) && !defined(__CYGWIN__) - const char* version = 0; -#else - // Check for executable version properties. - const char* version = this->GetProperty("VERSION"); - if(this->GetType() != cmTarget::EXECUTABLE || this->Makefile->IsOn("XCODE")) - { - version = 0; - } -#endif - - // Get the components of the executable name. - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - // The executable name. - name = prefix+base+suffix; - - // The executable's real name on disk. -#if defined(__CYGWIN__) - realName = prefix+base; -#else - realName = name; -#endif - if(version) - { - realName += "-"; - realName += version; - } -#if defined(__CYGWIN__) - realName += suffix; -#endif - - // The import library name. - impName = this->GetFullNameInternal(config, true); - - // The program database file name. - pdbName = this->GetPDBName(config); -} - -//---------------------------------------------------------------------------- bool cmTarget::HasImplibGNUtoMS() const { return this->HasImportLibrary() && this->GetPropertyAsBool("GNUtoMS"); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 925e7c6..714647c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -406,14 +406,6 @@ public: std::string& realName, std::string& impName, std::string& pdbName, const std::string& config) const; - /** Get the names of the executable needed to generate a build rule - that takes into account executable version numbers. This should - be called only on an executable target. */ - void GetExecutableNames(std::string& name, std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const; - /** Does this target have a GNU implib to convert to MS format? */ bool HasImplibGNUtoMS() const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index f3f291a..1bb21ff 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2471,7 +2471,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) std::string targetNamePDB; if(this->Target->GetType() == cmTarget::EXECUTABLE) { - this->Target->GetExecutableNames(targetName, targetNameFull, + this->GeneratorTarget->GetExecutableNames(targetName, targetNameFull, targetNameImport, targetNamePDB, config.c_str()); } -- cgit v0.12 From 766839c56da82e12b6986fb5cf7c8d86442615bc Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:45 +0200 Subject: cmGeneratorTarget: Move GetLibraryNames from cmTarget. --- Source/cmGeneratorTarget.cxx | 98 +++++++++++++++++++++++++++-- Source/cmGeneratorTarget.h | 7 +++ Source/cmInstallTargetGenerator.cxx | 4 +- Source/cmLocalVisualStudio7Generator.cxx | 2 +- Source/cmMakefileLibraryTargetGenerator.cxx | 4 +- Source/cmNinjaNormalTargetGenerator.cxx | 2 +- Source/cmTarget.cxx | 89 -------------------------- Source/cmTarget.h | 7 --- Source/cmVisualStudio10TargetGenerator.cxx | 3 +- 9 files changed, 107 insertions(+), 109 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6a693f1..31c2df1 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -693,8 +693,8 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const std::string realName; std::string impName; std::string pdbName; - this->Target->GetLibraryNames(name, soName, realName, - impName, pdbName, config); + this->GetLibraryNames(name, soName, realName, + impName, pdbName, config); return soName; } } @@ -1254,7 +1254,7 @@ void cmGeneratorTarget::GenerateTargetManifest( this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) { - this->Target->GetLibraryNames(name, soName, realName, impName, pdbName, + this->GetLibraryNames(name, soName, realName, impName, pdbName, config); } else @@ -1378,13 +1378,100 @@ cmGeneratorTarget::NormalGetRealName(const std::string& config) const std::string realName; std::string impName; std::string pdbName; - this->Target->GetLibraryNames(name, soName, realName, - impName, pdbName, config); + this->GetLibraryNames(name, soName, realName, + impName, pdbName, config); return realName; } } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetLibraryNames(std::string& name, + std::string& soName, + std::string& realName, + std::string& impName, + std::string& pdbName, + const std::string& config) const +{ + // This should not be called for imported targets. + // TODO: Split cmTarget into a class hierarchy to get compile-time + // enforcement of the limited imported target API. + if(this->Target->IsImported()) + { + std::string msg = "GetLibraryNames called on imported target: "; + msg += this->GetName(); + this->LocalGenerator->IssueMessage(cmake::INTERNAL_ERROR, + msg); + return; + } + + // Check for library version properties. + const char* version = this->GetProperty("VERSION"); + const char* soversion = this->GetProperty("SOVERSION"); + if(!this->Target->HasSOName(config) || + this->Target->IsFrameworkOnApple()) + { + // Versioning is supported only for shared libraries and modules, + // and then only when the platform supports an soname flag. + version = 0; + soversion = 0; + } + if(version && !soversion) + { + // The soversion must be set if the library version is set. Use + // the library version as the soversion. + soversion = version; + } + if(!version && soversion) + { + // Use the soversion as the library version. + version = soversion; + } + + // Get the components of the library name. + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + // The library name. + name = prefix+base+suffix; + + if(this->Target->IsFrameworkOnApple()) + { + realName = prefix; + realName += "Versions/"; + realName += this->Target->GetFrameworkVersion(); + realName += "/"; + realName += base; + soName = realName; + } + else + { + // The library's soname. + this->Target->ComputeVersionedName(soName, prefix, base, suffix, + name, soversion); + + // The library's real name on disk. + this->Target->ComputeVersionedName(realName, prefix, base, suffix, + name, version); + } + + // The import library name. + if(this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY) + { + impName = this->Target->GetFullNameInternal(config, true); + } + else + { + impName = ""; + } + + // The program database file name. + pdbName = this->Target->GetPDBName(config); +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetExecutableNames(std::string& name, std::string& realName, std::string& impName, @@ -1446,7 +1533,6 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, pdbName = this->Target->GetPDBName(config); } - bool cmStrictTargetComparison::operator()(cmTarget const* t1, cmTarget const* t2) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 49aa65b..7fb7c32 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -191,6 +191,13 @@ public: std::string& impName, std::string& pdbName, const std::string& config) const; + /** Get the names of the library needed to generate a build rule + that takes into account shared library version numbers. This + should be called only on a library target. */ + void GetLibraryNames(std::string& name, std::string& soName, + std::string& realName, std::string& impName, + std::string& pdbName, const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index c872859..deabecf 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -185,7 +185,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->Target->GetLibraryNames(targetName, targetNameSO, + this->Target->GetLibraryNames(targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, config); @@ -411,7 +411,7 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - target->GetLibraryNames(targetName, targetNameSO, targetNameReal, + gtgt->GetLibraryNames(targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, config); if(nameType == NameImplib) { diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index daac331..dd4cd33 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -1147,7 +1147,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, std::string targetNameFull; std::string targetNameImport; std::string targetNamePDB; - target.GetLibraryNames(targetName, targetNameSO, targetNameFull, + gt->GetLibraryNames(targetName, targetNameSO, targetNameFull, targetNameImport, targetNamePDB, configName); // Compute the link library and directory information. diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 696dcc4..26273ee 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -28,7 +28,7 @@ cmMakefileLibraryTargetGenerator this->CustomCommandDriver = OnDepends; if (this->Target->GetType() != cmTarget::INTERFACE_LIBRARY) { - this->Target->GetLibraryNames( + this->GeneratorTarget->GetLibraryNames( this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, this->TargetNameImport, this->TargetNamePDB, this->ConfigName); } @@ -266,7 +266,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules std::string targetNameReal; std::string targetNameImport; std::string targetNamePDB; - this->Target->GetLibraryNames( + this->GeneratorTarget->GetLibraryNames( targetName, targetNameSO, targetNameReal, targetNameImport, targetNamePDB, this->ConfigName); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 737510f..5d86091 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -49,7 +49,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) this->TargetNamePDB, GetLocalGenerator()->GetConfigName()); else - target->Target->GetLibraryNames(this->TargetNameOut, + this->GetGeneratorTarget()->GetLibraryNames(this->TargetNameOut, this->TargetNameSO, this->TargetNameReal, this->TargetNameImport, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 22b76e9..60fe7e4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3862,95 +3862,6 @@ void cmTarget::GetFullNameInternal(const std::string& config, } //---------------------------------------------------------------------------- -void cmTarget::GetLibraryNames(std::string& name, - std::string& soName, - std::string& realName, - std::string& impName, - std::string& pdbName, - const std::string& config) const -{ - // This should not be called for imported targets. - // TODO: Split cmTarget into a class hierarchy to get compile-time - // enforcement of the limited imported target API. - if(this->IsImported()) - { - std::string msg = "GetLibraryNames called on imported target: "; - msg += this->GetName(); - this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, - msg); - return; - } - - assert(this->GetType() != INTERFACE_LIBRARY); - - // Check for library version properties. - const char* version = this->GetProperty("VERSION"); - const char* soversion = this->GetProperty("SOVERSION"); - if(!this->HasSOName(config) || - this->Makefile->IsOn("CMAKE_PLATFORM_NO_VERSIONED_SONAME") || - this->IsFrameworkOnApple()) - { - // Versioning is supported only for shared libraries and modules, - // and then only when the platform supports an soname flag. - version = 0; - soversion = 0; - } - if(version && !soversion) - { - // The soversion must be set if the library version is set. Use - // the library version as the soversion. - soversion = version; - } - if(!version && soversion) - { - // Use the soversion as the library version. - version = soversion; - } - - // Get the components of the library name. - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - // The library name. - name = prefix+base+suffix; - - if(this->IsFrameworkOnApple()) - { - realName = prefix; - realName += "Versions/"; - realName += this->GetFrameworkVersion(); - realName += "/"; - realName += base; - soName = realName; - } - else - { - // The library's soname. - this->ComputeVersionedName(soName, prefix, base, suffix, - name, soversion); - // The library's real name on disk. - this->ComputeVersionedName(realName, prefix, base, suffix, - name, version); - } - - // The import library name. - if(this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY) - { - impName = this->GetFullNameInternal(config, true); - } - else - { - impName = ""; - } - - // The program database file name. - pdbName = this->GetPDBName(config); -} - -//---------------------------------------------------------------------------- void cmTarget::ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 714647c..15dfb4a 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -399,13 +399,6 @@ public: no soname at all. */ bool IsImportedSharedLibWithoutSOName(const std::string& config) const; - /** Get the names of the library needed to generate a build rule - that takes into account shared library version numbers. This - should be called only on a library target. */ - void GetLibraryNames(std::string& name, std::string& soName, - std::string& realName, std::string& impName, - std::string& pdbName, const std::string& config) const; - /** Does this target have a GNU implib to convert to MS format? */ bool HasImplibGNUtoMS() const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 1bb21ff..83775a5 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2477,7 +2477,8 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) } else { - this->Target->GetLibraryNames(targetName, targetNameSO, targetNameFull, + this->GeneratorTarget->GetLibraryNames(targetName, targetNameSO, + targetNameFull, targetNameImport, targetNamePDB, config.c_str()); } -- cgit v0.12 From f0aa660772565545cbcda9ed8ae946b8d5097416 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:45 +0200 Subject: cmGeneratorTarget: Move HasSOName from cmTarget. --- Source/cmExportFileGenerator.cxx | 2 +- Source/cmGeneratorTarget.cxx | 14 +++++++++++++- Source/cmGeneratorTarget.h | 3 +++ Source/cmGlobalXCodeGenerator.cxx | 2 +- Source/cmMakefileLibraryTargetGenerator.cxx | 2 +- Source/cmNinjaNormalTargetGenerator.cxx | 2 +- Source/cmTarget.cxx | 11 ----------- Source/cmTarget.h | 3 --- 8 files changed, 20 insertions(+), 19 deletions(-) diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index 8a2cf4b..e3652c5 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -889,7 +889,7 @@ cmExportFileGenerator { std::string prop; std::string value; - if(target->Target->HasSOName(config)) + if(target->HasSOName(config)) { if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 31c2df1..2b3ebee 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -657,6 +657,18 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::HasSOName(const std::string& config) const +{ + // soname is supported only for shared libraries and modules, + // and then only when the platform supports an soname flag. + return ((this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY) && + !this->GetPropertyAsBool("NO_SONAME") && + this->Makefile->GetSONameFlag( + this->Target->GetLinkerLanguage(config))); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const { if(this->Target->IsImported()) @@ -1407,7 +1419,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, // Check for library version properties. const char* version = this->GetProperty("VERSION"); const char* soversion = this->GetProperty("SOVERSION"); - if(!this->Target->HasSOName(config) || + if(!this->HasSOName(config) || this->Target->IsFrameworkOnApple()) { // Versioning is supported only for shared libraries and modules, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 7fb7c32..9254265 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -160,6 +160,9 @@ public: std::vector const* GetSourceDepends(cmSourceFile const* sf) const; + /** Whether this library has soname enabled and platform supports it. */ + bool HasSOName(const std::string& config) const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index b44848c..d7ae36d 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1944,7 +1944,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, const char* version = target.GetProperty("VERSION"); const char* soversion = target.GetProperty("SOVERSION"); - if(!target.HasSOName(configName) || target.IsFrameworkOnApple()) + if(!gtgt->HasSOName(configName) || target.IsFrameworkOnApple()) { version = 0; soversion = 0; diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 26273ee..7d0dc49 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -653,7 +653,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules vars.Target = target.c_str(); vars.LinkLibraries = linkLibs.c_str(); vars.ObjectsQuoted = buildObjs.c_str(); - if (this->Target->HasSOName(this->ConfigName)) + if (this->GeneratorTarget->HasSOName(this->ConfigName)) { vars.SONameFlag = this->Makefile->GetSONameFlag(linkLanguage); vars.TargetSOName= targetNameSO.c_str(); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 5d86091..2586b31 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -531,7 +531,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() vars["LANGUAGE_COMPILE_FLAGS"] = t; } - if (target.HasSOName(cfgName)) + if (this->GetGeneratorTarget()->HasSOName(cfgName)) { vars["SONAME_FLAG"] = mf->GetSONameFlag(this->TargetLinkLanguage); vars["SONAME"] = this->TargetNameSO; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 60fe7e4..e1b3e94 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3535,17 +3535,6 @@ std::string cmTarget::GetCompilePDBPath(const std::string& config) const } //---------------------------------------------------------------------------- -bool cmTarget::HasSOName(const std::string& config) const -{ - // soname is supported only for shared libraries and modules, - // and then only when the platform supports an soname flag. - return ((this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY) && - !this->GetPropertyAsBool("NO_SONAME") && - this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config))); -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 15dfb4a..e89a212 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -386,9 +386,6 @@ public: /** Get the path for the MSVC /Fd option for this target. */ std::string GetCompilePDBPath(const std::string& config="") const; - /** Whether this library has soname enabled and platform supports it. */ - bool HasSOName(const std::string& config) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; -- cgit v0.12 From a45fed81e5fd5d9b280c8dd70d50c9606a982a0b Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:45 +0200 Subject: cmGeneratorTarget: Move GetCompilePDBPath from cmTarget. --- Source/cmGeneratorTarget.cxx | 45 ++++++++++++++++++++++++++++++ Source/cmGeneratorTarget.h | 6 ++++ Source/cmLocalVisualStudio7Generator.cxx | 2 +- Source/cmMakefileTargetGenerator.cxx | 2 +- Source/cmNinjaTargetGenerator.cxx | 3 +- Source/cmTarget.cxx | 43 ---------------------------- Source/cmTarget.h | 6 ---- Source/cmVisualStudio10TargetGenerator.cxx | 3 +- 8 files changed, 57 insertions(+), 53 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2b3ebee..a125e47 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -657,6 +657,51 @@ void cmGeneratorTarget::GetSourceFiles(std::vector &files, } //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetCompilePDBName(const std::string& config) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + // Check for a per-configuration output directory target property. + std::string configUpper = cmSystemTools::UpperCase(config); + std::string configProp = "COMPILE_PDB_NAME_"; + configProp += configUpper; + const char* config_name = this->Target->GetProperty(configProp); + if(config_name && *config_name) + { + return prefix + config_name + ".pdb"; + } + + const char* name = this->Target->GetProperty("COMPILE_PDB_NAME"); + if(name && *name) + { + return prefix + name + ".pdb"; + } + + return ""; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetCompilePDBPath(const std::string& config) const +{ + std::string dir = this->Target->GetCompilePDBDirectory(config); + std::string name = this->GetCompilePDBName(config); + if(dir.empty() && !name.empty()) + { + dir = this->Target->GetPDBDirectory(config); + } + if(!dir.empty()) + { + dir += "/"; + } + return dir + name; +} + +//---------------------------------------------------------------------------- bool cmGeneratorTarget::HasSOName(const std::string& config) const { // soname is supported only for shared libraries and modules, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9254265..9cdfd00 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -163,6 +163,12 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; + /** Get the name of the compiler pdb file for the target. */ + std::string GetCompilePDBName(const std::string& config="") const; + + /** Get the path for the MSVC /Fd option for this target. */ + std::string GetCompilePDBPath(const std::string& config="") const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index dd4cd33..799bac6 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -881,7 +881,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, if(target.GetType() <= cmTarget::OBJECT_LIBRARY) { // Specify the compiler program database file if configured. - std::string pdb = target.GetCompilePDBPath(configName); + std::string pdb = gt->GetCompilePDBPath(configName); if(!pdb.empty()) { fout << "\t\t\t\tProgramDataBaseFileName=\"" diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index ac8cd29..f9125fc 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -553,7 +553,7 @@ cmMakefileTargetGenerator if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { targetFullPathCompilePDB = - this->Target->GetCompilePDBPath(this->ConfigName); + this->GeneratorTarget->GetCompilePDBPath(this->ConfigName); if(targetFullPathCompilePDB.empty()) { targetFullPathCompilePDB = this->Target->GetSupportDirectory() + "/"; diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index cf80424..e61ba6f 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -277,7 +277,8 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const } if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { - compilePdbPath = this->Target->GetCompilePDBPath(this->GetConfigName()); + compilePdbPath = + this->GeneratorTarget->GetCompilePDBPath(this->GetConfigName()); if(compilePdbPath.empty()) { compilePdbPath = this->Target->GetSupportDirectory() + "/"; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e1b3e94..188ad0f 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3492,49 +3492,6 @@ std::string cmTarget::GetPDBName(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBName(const std::string& config) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - // Check for a per-configuration output directory target property. - std::string configUpper = cmSystemTools::UpperCase(config); - std::string configProp = "COMPILE_PDB_NAME_"; - configProp += configUpper; - const char* config_name = this->GetProperty(configProp); - if(config_name && *config_name) - { - return prefix + config_name + ".pdb"; - } - - const char* name = this->GetProperty("COMPILE_PDB_NAME"); - if(name && *name) - { - return prefix + name + ".pdb"; - } - - return ""; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBPath(const std::string& config) const -{ - std::string dir = this->GetCompilePDBDirectory(config); - std::string name = this->GetCompilePDBName(config); - if(dir.empty() && !name.empty()) - { - dir = this->GetPDBDirectory(config); - } - if(!dir.empty()) - { - dir += "/"; - } - return dir + name; -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e89a212..162033c 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -380,12 +380,6 @@ public: /** Get the name of the pdb file for the target. */ std::string GetPDBName(const std::string& config) const; - /** Get the name of the compiler pdb file for the target. */ - std::string GetCompilePDBName(const std::string& config="") const; - - /** Get the path for the MSVC /Fd option for this target. */ - std::string GetCompilePDBPath(const std::string& config="") const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 83775a5..16edf3c 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -2026,7 +2026,8 @@ void cmVisualStudio10TargetGenerator::WriteClOptions( } // Specify the compiler program database file if configured. - std::string pdb = this->Target->GetCompilePDBPath(configName.c_str()); + std::string pdb = + this->GeneratorTarget->GetCompilePDBPath(configName.c_str()); if(!pdb.empty()) { this->ConvertToWindowsSlash(pdb); -- cgit v0.12 From 3df705681be123d93146156fec3166b41b19465a Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:46 +0200 Subject: cmGeneratorTarget: Move GetPDBName from cmTarget. --- Source/cmGeneratorExpressionNode.cxx | 2 +- Source/cmGeneratorTarget.cxx | 36 ++++++++++++++++++++++++++++++++++-- Source/cmGeneratorTarget.h | 3 +++ Source/cmMakefileTargetGenerator.cxx | 2 +- Source/cmNinjaTargetGenerator.cxx | 2 +- Source/cmTarget.cxx | 31 ------------------------------- Source/cmTarget.h | 3 --- 7 files changed, 40 insertions(+), 39 deletions(-) diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index a20579b..49fc96b 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1625,7 +1625,7 @@ struct TargetFilesystemArtifactResultCreator std::string result = target->Target->GetPDBDirectory(context->Config); result += "/"; - result += target->Target->GetPDBName(context->Config); + result += target->GetPDBName(context->Config); return result; } }; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a125e47..a29f4c9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1525,7 +1525,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, } // The program database file name. - pdbName = this->Target->GetPDBName(config); + pdbName = this->GetPDBName(config); } //---------------------------------------------------------------------------- @@ -1587,7 +1587,39 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, impName = this->Target->GetFullNameInternal(config, true); // The program database file name. - pdbName = this->Target->GetPDBName(config); + pdbName = this->GetPDBName(config); +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetPDBName(const std::string& config) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + + std::vector props; + std::string configUpper = + cmSystemTools::UpperCase(config); + if(!configUpper.empty()) + { + // PDB_NAME_ + props.push_back("PDB_NAME_" + configUpper); + } + + // PDB_NAME + props.push_back("PDB_NAME"); + + for(std::vector::const_iterator i = props.begin(); + i != props.end(); ++i) + { + if(const char* outName = this->GetProperty(*i)) + { + base = outName; + break; + } + } + return prefix+base+".pdb"; } bool cmStrictTargetComparison::operator()(cmTarget const* t1, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9cdfd00..441bbcf 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -160,6 +160,9 @@ public: std::vector const* GetSourceDepends(cmSourceFile const* sf) const; + /** Get the name of the pdb file for the target. */ + std::string GetPDBName(const std::string& config="") const; + /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index f9125fc..b94e151 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -548,7 +548,7 @@ cmMakefileTargetGenerator this->GeneratorTarget->GetFullPath(this->ConfigName, false, true); targetFullPathPDB = this->Target->GetPDBDirectory(this->ConfigName); targetFullPathPDB += "/"; - targetFullPathPDB += this->Target->GetPDBName(this->ConfigName); + targetFullPathPDB += this->GeneratorTarget->GetPDBName(this->ConfigName); } if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index e61ba6f..16e1f48 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -273,7 +273,7 @@ bool cmNinjaTargetGenerator::SetMsvcTargetPdbVariable(cmNinjaVars& vars) const { pdbPath = this->Target->GetPDBDirectory(this->GetConfigName()); pdbPath += "/"; - pdbPath += this->Target->GetPDBName(this->GetConfigName()); + pdbPath += this->GeneratorTarget->GetPDBName(this->GetConfigName()); } if(this->Target->GetType() <= cmTarget::OBJECT_LIBRARY) { diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 188ad0f..1e7fb5a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3461,37 +3461,6 @@ const char* cmTarget::GetPrefixVariableInternal(bool implib) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetPDBName(const std::string& config) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, false, prefix, base, suffix); - - std::vector props; - std::string configUpper = cmSystemTools::UpperCase(config); - if(!configUpper.empty()) - { - // PDB_NAME_ - props.push_back("PDB_NAME_" + configUpper); - } - - // PDB_NAME - props.push_back("PDB_NAME"); - - for(std::vector::const_iterator i = props.begin(); - i != props.end(); ++i) - { - if(const char* outName = this->GetProperty(*i)) - { - base = outName; - break; - } - } - return prefix+base+".pdb"; -} - -//---------------------------------------------------------------------------- bool cmTarget::HasMacOSXRpathInstallNameDir(const std::string& config) const { bool install_name_is_rpath = false; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 162033c..8c23372 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -377,9 +377,6 @@ public: const std::string& config="", bool implib = false) const; - /** Get the name of the pdb file for the target. */ - std::string GetPDBName(const std::string& config) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; -- cgit v0.12 From 8d2de00244f8338664c16bd8d8ebb03c6f0cb83f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:46 +0200 Subject: cmGeneratorTarget: Move NeedRelinkBeforeInstall from cmTarget. --- Source/cmGeneratorTarget.cxx | 67 ++++++++++++++++++++++++++ Source/cmGeneratorTarget.h | 5 ++ Source/cmGlobalUnixMakefileGenerator3.cxx | 6 +-- Source/cmInstallTargetGenerator.cxx | 2 +- Source/cmLocalUnixMakefileGenerator3.cxx | 3 +- Source/cmMakefileExecutableTargetGenerator.cxx | 2 +- Source/cmMakefileLibraryTargetGenerator.cxx | 4 +- Source/cmTarget.cxx | 64 ------------------------ Source/cmTarget.h | 5 -- 9 files changed, 80 insertions(+), 78 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index a29f4c9..505d01f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -714,6 +714,73 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const } //---------------------------------------------------------------------------- +bool +cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const +{ + // Only executables and shared libraries can have an rpath and may + // need relinking. + if(this->GetType() != cmTarget::EXECUTABLE && + this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY) + { + return false; + } + + // If there is no install location this target will not be installed + // and therefore does not need relinking. + if(!this->Target->GetHaveInstallRule()) + { + return false; + } + + // If skipping all rpaths completely then no relinking is needed. + if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) + { + return false; + } + + // If building with the install-tree rpath no relinking is needed. + if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + return false; + } + + // If chrpath is going to be used no relinking is needed. + if(this->Target->IsChrpathUsed(config)) + { + return false; + } + + // Check for rpath support on this platform. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; + flagVar += ll; + flagVar += "_FLAG"; + if(!this->Makefile->IsSet(flagVar)) + { + // There is no rpath support on this platform so nothing needs + // relinking. + return false; + } + } + else + { + // No linker language is known. This error will be reported by + // other code. + return false; + } + + // If either a build or install tree rpath is set then the rpath + // will likely change between the build tree and install tree and + // this target must be relinked. + return this->Target->HaveBuildTreeRPATH(config) + || this->Target->HaveInstallTreeRPATH(); +} + + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const { if(this->Target->IsImported()) diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 441bbcf..c9a2508 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -210,6 +210,11 @@ public: std::string& realName, std::string& impName, std::string& pdbName, const std::string& config) const; + /** + * Compute whether this target must be relinked before installing. + */ + bool NeedRelinkBeforeInstall(const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmGlobalUnixMakefileGenerator3.cxx b/Source/cmGlobalUnixMakefileGenerator3.cxx index edf2705..69747a4 100644 --- a/Source/cmGlobalUnixMakefileGenerator3.cxx +++ b/Source/cmGlobalUnixMakefileGenerator3.cxx @@ -482,7 +482,7 @@ cmGlobalUnixMakefileGenerator3 // Add this to the list of depends rules in this directory. if((!check_all || !gtarget->GetPropertyAsBool("EXCLUDE_FROM_ALL")) && (!check_relink || - gtarget->Target + gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName()))) { std::string tname = lg->GetRelativeTargetDirectory(*gtarget->Target); @@ -691,7 +691,7 @@ cmGlobalUnixMakefileGenerator3 // Add a local name for the rule to relink the target before // installation. - if(gtarget->Target + if(gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName())) { makeTargetName = lg->GetRelativeTargetDirectory(*gtarget->Target); @@ -876,7 +876,7 @@ cmGlobalUnixMakefileGenerator3 name, depends, commands, true); // Add rules to prepare the target for installation. - if(gtarget->Target + if(gtarget ->NeedRelinkBeforeInstall(lg->GetConfigName())) { localName = lg->GetRelativeTargetDirectory(*gtarget->Target); diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index deabecf..7a7dcb4 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -73,7 +73,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, { // Compute the build tree directory from which to copy the target. std::string fromDirConfig; - if(this->Target->Target->NeedRelinkBeforeInstall(config)) + if(this->Target->NeedRelinkBeforeInstall(config)) { fromDirConfig = this->Target->Target->GetMakefile()->GetCurrentBinaryDirectory(); diff --git a/Source/cmLocalUnixMakefileGenerator3.cxx b/Source/cmLocalUnixMakefileGenerator3.cxx index 98bd0ab..ce370bc 100644 --- a/Source/cmLocalUnixMakefileGenerator3.cxx +++ b/Source/cmLocalUnixMakefileGenerator3.cxx @@ -486,8 +486,7 @@ void cmLocalUnixMakefileGenerator3 // Add a local name for the rule to relink the target before // installation. - if(t->second->Target - ->NeedRelinkBeforeInstall(this->ConfigName)) + if(t->second->NeedRelinkBeforeInstall(this->ConfigName)) { makeTargetName = this->GetRelativeTargetDirectory(*t->second->Target); makeTargetName += "/preinstall"; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 31a78ad..2fd77c9 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -58,7 +58,7 @@ void cmMakefileExecutableTargetGenerator::WriteRuleFiles() // write the link rules this->WriteExecutableRule(false); - if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) + if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteExecutableRule(true); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 7d0dc49..a2fcbad 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -69,7 +69,7 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() break; case cmTarget::SHARED_LIBRARY: this->WriteSharedLibraryRules(false); - if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) + if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteSharedLibraryRules(true); @@ -77,7 +77,7 @@ void cmMakefileLibraryTargetGenerator::WriteRuleFiles() break; case cmTarget::MODULE_LIBRARY: this->WriteModuleLibraryRules(false); - if(this->Target->NeedRelinkBeforeInstall(this->ConfigName)) + if(this->GeneratorTarget->NeedRelinkBeforeInstall(this->ConfigName)) { // Write rules to link an installable version of the target. this->WriteModuleLibraryRules(true); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1e7fb5a..8dd62f9 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3855,70 +3855,6 @@ bool cmTarget::HaveInstallTreeRPATH() const } //---------------------------------------------------------------------------- -bool cmTarget::NeedRelinkBeforeInstall(const std::string& config) const -{ - // Only executables and shared libraries can have an rpath and may - // need relinking. - if(this->TargetTypeValue != cmTarget::EXECUTABLE && - this->TargetTypeValue != cmTarget::SHARED_LIBRARY && - this->TargetTypeValue != cmTarget::MODULE_LIBRARY) - { - return false; - } - - // If there is no install location this target will not be installed - // and therefore does not need relinking. - if(!this->GetHaveInstallRule()) - { - return false; - } - - // If skipping all rpaths completely then no relinking is needed. - if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) - { - return false; - } - - // If building with the install-tree rpath no relinking is needed. - if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) - { - return false; - } - - // If chrpath is going to be used no relinking is needed. - if(this->IsChrpathUsed(config)) - { - return false; - } - - // Check for rpath support on this platform. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; - flagVar += ll; - flagVar += "_FLAG"; - if(!this->Makefile->IsSet(flagVar)) - { - // There is no rpath support on this platform so nothing needs - // relinking. - return false; - } - } - else - { - // No linker language is known. This error will be reported by - // other code. - return false; - } - - // If either a build or install tree rpath is set then the rpath - // will likely change between the build tree and install tree and - // this target must be relinked. - return this->HaveBuildTreeRPATH(config) || this->HaveInstallTreeRPATH(); -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetInstallNameDirForBuildTree( const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8c23372..11f715a 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -395,11 +395,6 @@ public: bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, const char* newExt = 0) const; - /** - * Compute whether this target must be relinked before installing. - */ - bool NeedRelinkBeforeInstall(const std::string& config) const; - bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; -- cgit v0.12 From e27d737e27fbfc8cfde020ec02d6b2c74afb6885 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:46 +0200 Subject: cmGeneratorTarget: Move IsChrPathUsed from cmTarget. --- Source/cmComputeLinkInformation.cxx | 6 +++- Source/cmGeneratorTarget.cxx | 69 ++++++++++++++++++++++++++++++++++++- Source/cmGeneratorTarget.h | 3 ++ Source/cmInstallTargetGenerator.cxx | 5 ++- Source/cmTarget.cxx | 67 ----------------------------------- Source/cmTarget.h | 3 -- 6 files changed, 78 insertions(+), 75 deletions(-) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 72db6f8..b7555a6 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -321,7 +321,11 @@ cmComputeLinkInformation this->RuntimeAlways = (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - this->RuntimeUseChrpath = this->Target->IsChrpathUsed(config); + + cmGeneratorTarget *gtgt = this->Target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); // Get options needed to help find dependent libraries. std::string rlVar = "CMAKE_"; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 505d01f..6481390 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -746,7 +746,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const } // If chrpath is going to be used no relinking is needed. - if(this->Target->IsChrpathUsed(config)) + if(this->IsChrpathUsed(config)) { return false; } @@ -779,6 +779,73 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const || this->Target->HaveInstallTreeRPATH(); } +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const +{ + // Only certain target types have an rpath. + if(!(this->GetType() == cmTarget::SHARED_LIBRARY || + this->GetType() == cmTarget::MODULE_LIBRARY || + this->GetType() == cmTarget::EXECUTABLE)) + { + return false; + } + + // If the target will not be installed we do not need to change its + // rpath. + if(!this->Target->GetHaveInstallRule()) + { + return false; + } + + // Skip chrpath if skipping rpath altogether. + if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) + { + return false; + } + + // Skip chrpath if it does not need to be changed at install time. + if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + return false; + } + + // Allow the user to disable builtin chrpath explicitly. + if(this->Makefile->IsOn("CMAKE_NO_BUILTIN_CHRPATH")) + { + return false; + } + + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) + { + return true; + } + +#if defined(CMAKE_USE_ELF_PARSER) + // Enable if the rpath flag uses a separator and the target uses ELF + // binaries. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; + sepVar += ll; + sepVar += "_FLAG_SEP"; + const char* sep = this->Makefile->GetDefinition(sepVar); + if(sep && *sep) + { + // TODO: Add ELF check to ABI detection and get rid of + // CMAKE_EXECUTABLE_FORMAT. + if(const char* fmt = + this->Makefile->GetDefinition("CMAKE_EXECUTABLE_FORMAT")) + { + return strcmp(fmt, "ELF") == 0; + } + } + } +#endif + static_cast(config); + return false; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetSOName(const std::string& config) const diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index c9a2508..9ecbbbe 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -215,6 +215,9 @@ public: */ bool NeedRelinkBeforeInstall(const std::string& config) const; + /** Return true if builtin chrpath will work for this target */ + bool IsChrpathUsed(const std::string& config) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 7a7dcb4..24c1c49 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -656,11 +656,10 @@ cmInstallTargetGenerator std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. - if(this->ImportLibrary || !this->Target->Target->IsChrpathUsed(config)) + if(this->ImportLibrary || !this->Target->IsChrpathUsed(config)) { return; } - // Skip if on Apple if(this->Target->Target->GetMakefile() ->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) @@ -695,7 +694,7 @@ cmInstallTargetGenerator std::string const& toDestDirPath) { // Skip the chrpath if the target does not need it. - if(this->ImportLibrary || !this->Target->Target->IsChrpathUsed(config)) + if(this->ImportLibrary || !this->Target->IsChrpathUsed(config)) { return; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8dd62f9..1183fe4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -4314,73 +4314,6 @@ void cmTarget::GetLanguages(std::set& languages, } //---------------------------------------------------------------------------- -bool cmTarget::IsChrpathUsed(const std::string& config) const -{ - // Only certain target types have an rpath. - if(!(this->GetType() == cmTarget::SHARED_LIBRARY || - this->GetType() == cmTarget::MODULE_LIBRARY || - this->GetType() == cmTarget::EXECUTABLE)) - { - return false; - } - - // If the target will not be installed we do not need to change its - // rpath. - if(!this->GetHaveInstallRule()) - { - return false; - } - - // Skip chrpath if skipping rpath altogether. - if(this->Makefile->IsOn("CMAKE_SKIP_RPATH")) - { - return false; - } - - // Skip chrpath if it does not need to be changed at install time. - if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) - { - return false; - } - - // Allow the user to disable builtin chrpath explicitly. - if(this->Makefile->IsOn("CMAKE_NO_BUILTIN_CHRPATH")) - { - return false; - } - - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) - { - return true; - } - -#if defined(CMAKE_USE_ELF_PARSER) - // Enable if the rpath flag uses a separator and the target uses ELF - // binaries. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; - sepVar += ll; - sepVar += "_FLAG_SEP"; - const char* sep = this->Makefile->GetDefinition(sepVar); - if(sep && *sep) - { - // TODO: Add ELF check to ABI detection and get rid of - // CMAKE_EXECUTABLE_FORMAT. - if(const char* fmt = - this->Makefile->GetDefinition("CMAKE_EXECUTABLE_FORMAT")) - { - return strcmp(fmt, "ELF") == 0; - } - } - } -#endif - static_cast(config); - return false; -} - -//---------------------------------------------------------------------------- cmTarget::ImportInfo const* cmTarget::GetImportInfo(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 11f715a..1aef7b3 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -398,9 +398,6 @@ public: bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; - /** Return true if builtin chrpath will work for this target */ - bool IsChrpathUsed(const std::string& config) const; - /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ -- cgit v0.12 From 62720e44be3e9f28e4c1e7d38206b2c51d34745e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:47 +0200 Subject: cmGeneratorTarget: Move GetFullNameComponents from cmTarget. --- Source/cmGeneratorTarget.cxx | 10 ++++++++++ Source/cmGeneratorTarget.h | 5 +++++ Source/cmGlobalXCodeGenerator.cxx | 2 +- Source/cmNinjaNormalTargetGenerator.cxx | 2 +- Source/cmTarget.cxx | 9 --------- Source/cmTarget.h | 4 ---- 6 files changed, 17 insertions(+), 15 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6481390..4be034f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -891,6 +891,16 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } //---------------------------------------------------------------------------- +void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, + std::string& base, + std::string& suffix, + const std::string& config, + bool implib) const +{ + this->Target->GetFullNameInternal(config, implib, prefix, base, suffix); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 9ecbbbe..f96adad 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -118,6 +118,11 @@ public: /** Get the soname of the target. Allowed only for a shared library. */ std::string GetSOName(const std::string& config) const; + void GetFullNameComponents(std::string& prefix, + std::string& base, std::string& suffix, + const std::string& config="", + bool implib = false) const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d7ae36d..03f6d8f 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1940,7 +1940,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, std::string pnprefix; std::string pnbase; std::string pnsuffix; - target.GetFullNameComponents(pnprefix, pnbase, pnsuffix, configName); + gtgt->GetFullNameComponents(pnprefix, pnbase, pnsuffix, configName); const char* version = target.GetProperty("VERSION"); const char* soversion = target.GetProperty("SOVERSION"); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 2586b31..c80f485 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -569,7 +569,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() std::string prefix; std::string base; std::string suffix; - target.GetFullNameComponents(prefix, base, suffix); + this->GetGeneratorTarget()->GetFullNameComponents(prefix, base, suffix); std::string dbg_suffix = ".dbg"; // TODO: Where to document? if (mf->GetDefinition("CMAKE_DEBUG_SYMBOL_SUFFIX")) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 1183fe4..0d9aa49 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3609,15 +3609,6 @@ cmTarget::GetFullNameImported(const std::string& config, bool implib) const } //---------------------------------------------------------------------------- -void cmTarget::GetFullNameComponents(std::string& prefix, std::string& base, - std::string& suffix, - const std::string& config, - bool implib) const -{ - this->GetFullNameInternal(config, implib, prefix, base, suffix); -} - -//---------------------------------------------------------------------------- std::string cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 1aef7b3..9962fdb 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -372,10 +372,6 @@ public: makefile. */ std::string GetFullName(const std::string& config="", bool implib = false) const; - void GetFullNameComponents(std::string& prefix, - std::string& base, std::string& suffix, - const std::string& config="", - bool implib = false) const; /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; -- cgit v0.12 From 89e2a080e977b9632fa13c627b6a5370250d6ed5 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:47 +0200 Subject: cmGeneratorTarget: Move GetMacContentDirectory from cmTarget. --- Source/cmGeneratorTarget.cxx | 45 +++++++++++++++++++++++++++++++++++++++-- Source/cmGeneratorTarget.h | 9 +++++++++ Source/cmOSXBundleGenerator.cxx | 2 +- Source/cmTarget.cxx | 39 ----------------------------------- Source/cmTarget.h | 8 -------- 5 files changed, 53 insertions(+), 50 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4be034f..45577e5 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -567,7 +567,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const if(this->Target->IsAppBundleOnApple()) { - std::string macdir = this->Target->BuildMacContentDirectory("", "", + std::string macdir = this->BuildMacContentDirectory("", "", false); if(!macdir.empty()) { @@ -902,6 +902,47 @@ void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, //---------------------------------------------------------------------------- std::string +cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, + const std::string& config, + bool contentOnly) const +{ + std::string fpath = base; + if(this->Target->IsAppBundleOnApple()) + { + fpath += this->Target->GetAppBundleDirectory(config, contentOnly); + } + if(this->Target->IsFrameworkOnApple()) + { + fpath += this->Target->GetFrameworkDirectory(config, contentOnly); + } + if(this->Target->IsCFBundleOnApple()) + { + fpath += this->Target->GetCFBundleDirectory(config, contentOnly); + } + return fpath; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetMacContentDirectory(const std::string& config, + bool implib) const +{ + // Start with the output directory for the target. + std::string fpath = this->Target->GetDirectory(config, implib); + fpath += "/"; + bool contentOnly = true; + if(this->Target->IsFrameworkOnApple()) + { + // additional files with a framework go into the version specific + // directory + contentOnly = false; + } + fpath = this->BuildMacContentDirectory(fpath, config, contentOnly); + return fpath; +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const { std::string data; @@ -1527,7 +1568,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, fpath += "/"; if(this->Target->IsAppBundleOnApple()) { - fpath = this->Target->BuildMacContentDirectory(fpath, config, false); + fpath = this->BuildMacContentDirectory(fpath, config, false); fpath += "/"; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index f96adad..8fc1b44 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -123,6 +123,15 @@ public: const std::string& config="", bool implib = false) const; + /** Append to @a base the mac content directory and return it. */ + std::string BuildMacContentDirectory(const std::string& base, + const std::string& config = "", + bool contentOnly = true) const; + + /** @return the mac content directory for this target. */ + std::string GetMacContentDirectory(const std::string& config = 0, + bool implib = false) const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 3bc0eb7..7df2f78 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -217,7 +217,7 @@ cmOSXBundleGenerator::InitMacOSXContentDirectory(const char* pkgloc) // Construct the full path to the content subdirectory. std::string macdir = - this->GT->Target->GetMacContentDirectory(this->ConfigName, + this->GT->GetMacContentDirectory(this->ConfigName, /*implib*/ false); macdir += "/"; macdir += pkgloc; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0d9aa49..0f1d309 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5401,45 +5401,6 @@ std::string cmTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::BuildMacContentDirectory(const std::string& base, - const std::string& config, - bool contentOnly) const -{ - std::string fpath = base; - if(this->IsAppBundleOnApple()) - { - fpath += this->GetAppBundleDirectory(config, contentOnly); - } - if(this->IsFrameworkOnApple()) - { - fpath += this->GetFrameworkDirectory(config, contentOnly); - } - if(this->IsCFBundleOnApple()) - { - fpath += this->GetCFBundleDirectory(config, contentOnly); - } - return fpath; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetMacContentDirectory(const std::string& config, - bool implib) const -{ - // Start with the output directory for the target. - std::string fpath = this->GetDirectory(config, implib); - fpath += "/"; - bool contentOnly = true; - if(this->IsFrameworkOnApple()) - { - // additional files with a framework go into the version specific - // directory - contentOnly = false; - } - fpath = this->BuildMacContentDirectory(fpath, config, contentOnly); - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9962fdb..d03ba3b 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -471,10 +471,6 @@ public: directory. */ bool UsesDefaultOutputDir(const std::string& config, bool implib) const; - /** @return the mac content directory for this target. */ - std::string GetMacContentDirectory(const std::string& config, - bool implib) const; - /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; @@ -615,10 +611,6 @@ private: std::string ImportedGetFullPath(const std::string& config, bool implib) const; - /** Append to @a base the mac content directory and return it. */ - std::string BuildMacContentDirectory(const std::string& base, - const std::string& config, - bool contentOnly) const; void GetSourceFiles(std::vector &files, const std::string& config) const; -- cgit v0.12 From d560bfd2739f2594119c49d82485b99bb4fbbe1f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:47 +0200 Subject: cmGeneratorTarget: Move GetInstallNameDir* from cmTarget. --- Source/cmExportBuildFileGenerator.cxx | 4 +- Source/cmExportBuildFileGenerator.h | 3 +- Source/cmExportFileGenerator.cxx | 2 +- Source/cmExportFileGenerator.h | 2 +- Source/cmExportInstallFileGenerator.cxx | 4 +- Source/cmExportInstallFileGenerator.h | 3 +- Source/cmExportTryCompileFileGenerator.cxx | 4 +- Source/cmExportTryCompileFileGenerator.h | 2 +- Source/cmGeneratorTarget.cxx | 67 +++++++++++++++++++++++++++++ Source/cmGeneratorTarget.h | 9 ++++ Source/cmGlobalXCodeGenerator.cxx | 2 +- Source/cmInstallTargetGenerator.cxx | 11 +++-- Source/cmMakefileLibraryTargetGenerator.cxx | 2 +- Source/cmNinjaNormalTargetGenerator.cxx | 3 +- Source/cmTarget.cxx | 67 ----------------------------- Source/cmTarget.h | 9 ---- 16 files changed, 100 insertions(+), 94 deletions(-) diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 6274c3f..fed0dbc 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -333,12 +333,12 @@ cmExportBuildFileGenerator } std::string -cmExportBuildFileGenerator::InstallNameDir(cmTarget* target, +cmExportBuildFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string& config) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportBuildFileGenerator.h b/Source/cmExportBuildFileGenerator.h index 4d8e062..ff3d2e1 100644 --- a/Source/cmExportBuildFileGenerator.h +++ b/Source/cmExportBuildFileGenerator.h @@ -71,7 +71,8 @@ protected: cmGeneratorTarget* target, ImportPropertyMap& properties); - std::string InstallNameDir(cmTarget* target, const std::string& config); + std::string InstallNameDir(cmGeneratorTarget* target, + const std::string& config); std::vector FindNamespaces(cmMakefile* mf, const std::string& name); diff --git a/Source/cmExportFileGenerator.cxx b/Source/cmExportFileGenerator.cxx index e3652c5..cae60b7 100644 --- a/Source/cmExportFileGenerator.cxx +++ b/Source/cmExportFileGenerator.cxx @@ -893,7 +893,7 @@ cmExportFileGenerator { if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { - value = this->InstallNameDir(target->Target, config); + value = this->InstallNameDir(target, config); } prop = "IMPORTED_SONAME"; value += target->GetSOName(config); diff --git a/Source/cmExportFileGenerator.h b/Source/cmExportFileGenerator.h index 4e54740..44f779b 100644 --- a/Source/cmExportFileGenerator.h +++ b/Source/cmExportFileGenerator.h @@ -200,7 +200,7 @@ private: virtual void ReplaceInstallPrefix(std::string &input); - virtual std::string InstallNameDir(cmTarget* target, + virtual std::string InstallNameDir(cmGeneratorTarget* target, const std::string& config) = 0; }; diff --git a/Source/cmExportInstallFileGenerator.cxx b/Source/cmExportInstallFileGenerator.cxx index b0bc686..d55be11 100644 --- a/Source/cmExportInstallFileGenerator.cxx +++ b/Source/cmExportInstallFileGenerator.cxx @@ -546,12 +546,12 @@ cmExportInstallFileGenerator } std::string -cmExportInstallFileGenerator::InstallNameDir(cmTarget* target, +cmExportInstallFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string&) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportInstallFileGenerator.h b/Source/cmExportInstallFileGenerator.h index 6f86ac9..b06fee5 100644 --- a/Source/cmExportInstallFileGenerator.h +++ b/Source/cmExportInstallFileGenerator.h @@ -83,7 +83,8 @@ protected: std::set& importedLocations ); - std::string InstallNameDir(cmTarget* target, const std::string& config); + std::string InstallNameDir(cmGeneratorTarget* target, + const std::string& config); cmInstallExportGenerator* IEGen; diff --git a/Source/cmExportTryCompileFileGenerator.cxx b/Source/cmExportTryCompileFileGenerator.cxx index 94831f8..ba66531 100644 --- a/Source/cmExportTryCompileFileGenerator.cxx +++ b/Source/cmExportTryCompileFileGenerator.cxx @@ -125,12 +125,12 @@ cmExportTryCompileFileGenerator::PopulateProperties(cmTarget const* target, } std::string -cmExportTryCompileFileGenerator::InstallNameDir(cmTarget* target, +cmExportTryCompileFileGenerator::InstallNameDir(cmGeneratorTarget* target, const std::string& config) { std::string install_name_dir; - cmMakefile* mf = target->GetMakefile(); + cmMakefile* mf = target->Target->GetMakefile(); if(mf->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) { install_name_dir = diff --git a/Source/cmExportTryCompileFileGenerator.h b/Source/cmExportTryCompileFileGenerator.h index 749f3ef..8838eca 100644 --- a/Source/cmExportTryCompileFileGenerator.h +++ b/Source/cmExportTryCompileFileGenerator.h @@ -45,7 +45,7 @@ protected: ImportPropertyMap& properties, std::set &emitted); - std::string InstallNameDir(cmTarget* target, + std::string InstallNameDir(cmGeneratorTarget* target, const std::string& config); private: std::string FindTargets(const std::string& prop, cmTarget const* tgt, diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 45577e5..2de3c77 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -891,6 +891,73 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetInstallNameDirForBuildTree( + const std::string& config) const +{ + // If building directly for installation then the build tree install_name + // is the same as the install tree. + if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) + { + return this->GetInstallNameDirForInstallTree(); + } + + // Use the build tree directory for the target. + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") && + !this->Makefile->IsOn("CMAKE_SKIP_RPATH") && + !this->GetPropertyAsBool("SKIP_BUILD_RPATH")) + { + std::string dir; + if(this->Target->MacOSXRpathInstallNameDirDefault()) + { + dir = "@rpath"; + } + else + { + dir = this->Target->GetDirectory(config); + } + dir += "/"; + return dir; + } + else + { + return ""; + } +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const +{ + if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) + { + std::string dir; + const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR"); + + if(!this->Makefile->IsOn("CMAKE_SKIP_RPATH") && + !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH")) + { + if(install_name_dir && *install_name_dir) + { + dir = install_name_dir; + dir += "/"; + } + } + if(!install_name_dir) + { + if(this->Target->MacOSXRpathInstallNameDirDefault()) + { + dir = "@rpath/"; + } + } + return dir; + } + else + { + return ""; + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 8fc1b44..6d084f7 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -115,6 +115,15 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** Return the install name directory for the target in the + * build tree. For example: "\@rpath/", "\@loader_path/", + * or "/full/path/to/library". */ + std::string GetInstallNameDirForBuildTree(const std::string& config) const; + + /** Return the install name directory for the target in the + * install tree. For example: "\@rpath/" or "\@loader_path/". */ + std::string GetInstallNameDirForInstallTree() const; + /** Get the soname of the target. Allowed only for a shared library. */ std::string GetSOName(const std::string& config) const; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 03f6d8f..d53ecde 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2331,7 +2331,7 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, if(target.GetType() == cmTarget::SHARED_LIBRARY) { // Get the install_name directory for the build tree. - install_name_dir = target.GetInstallNameDirForBuildTree(configName); + install_name_dir = gtgt->GetInstallNameDirForBuildTree(configName); // Xcode doesn't create the correct install_name in some cases. // That is, if the INSTALL_PATH is empty, or if we have versioning // of dylib libraries, we want to specify the install_name. diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index 24c1c49..30cf175 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -576,11 +576,14 @@ cmInstallTargetGenerator continue; } + cmGeneratorTarget *gtgt = tgt->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(tgt); // If the build tree and install tree use different path // components of the install_name field then we need to create a // mapping to be applied after installation. - std::string for_build = tgt->GetInstallNameDirForBuildTree(config); - std::string for_install = tgt->GetInstallNameDirForInstallTree(); + std::string for_build = gtgt->GetInstallNameDirForBuildTree(config); + std::string for_install = gtgt->GetInstallNameDirForInstallTree(); if(for_build != for_install) { // The directory portions differ. Append the filename to @@ -605,9 +608,9 @@ cmInstallTargetGenerator if(this->Target->GetType() == cmTarget::SHARED_LIBRARY) { std::string for_build = - this->Target->Target->GetInstallNameDirForBuildTree(config); + this->Target->GetInstallNameDirForBuildTree(config); std::string for_install = - this->Target->Target->GetInstallNameDirForInstallTree(); + this->Target->GetInstallNameDirForInstallTree(); if(this->Target->Target->IsFrameworkOnApple() && for_install.empty()) { diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index a2fcbad..b85b8a8 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -666,7 +666,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules { // Get the install_name directory for the build tree. install_name_dir = - this->Target->GetInstallNameDirForBuildTree(this->ConfigName); + this->GeneratorTarget->GetInstallNameDirForBuildTree(this->ConfigName); // Set the rule variable replacement value. if(install_name_dir.empty()) diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index c80f485..1835841 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -537,7 +537,8 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement() vars["SONAME"] = this->TargetNameSO; if (targetType == cmTarget::SHARED_LIBRARY) { - std::string install_dir = target.GetInstallNameDirForBuildTree(cfgName); + std::string install_dir = + this->GetGeneratorTarget()->GetInstallNameDirForBuildTree(cfgName); if (!install_dir.empty()) { vars["INSTALLNAME_DIR"] = localGen.Convert(install_dir, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 0f1d309..b49ad9b 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3846,73 +3846,6 @@ bool cmTarget::HaveInstallTreeRPATH() const } //---------------------------------------------------------------------------- -std::string cmTarget::GetInstallNameDirForBuildTree( - const std::string& config) const -{ - // If building directly for installation then the build tree install_name - // is the same as the install tree. - if(this->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")) - { - return GetInstallNameDirForInstallTree(); - } - - // Use the build tree directory for the target. - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME") && - !this->Makefile->IsOn("CMAKE_SKIP_RPATH") && - !this->GetPropertyAsBool("SKIP_BUILD_RPATH")) - { - std::string dir; - bool macosx_rpath = this->MacOSXRpathInstallNameDirDefault(); - if(macosx_rpath) - { - dir = "@rpath"; - } - else - { - dir = this->GetDirectory(config); - } - dir += "/"; - return dir; - } - else - { - return ""; - } -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetInstallNameDirForInstallTree() const -{ - if(this->Makefile->IsOn("CMAKE_PLATFORM_HAS_INSTALLNAME")) - { - std::string dir; - const char* install_name_dir = this->GetProperty("INSTALL_NAME_DIR"); - - if(!this->Makefile->IsOn("CMAKE_SKIP_RPATH") && - !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH")) - { - if(install_name_dir && *install_name_dir) - { - dir = install_name_dir; - dir += "/"; - } - } - if(!install_name_dir) - { - if(this->MacOSXRpathInstallNameDirDefault()) - { - dir = "@rpath/"; - } - } - return dir; - } - else - { - return ""; - } -} - -//---------------------------------------------------------------------------- const char* cmTarget::GetOutputTargetType(bool implib) const { switch(this->GetType()) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d03ba3b..c1c518f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -394,15 +394,6 @@ public: bool HaveBuildTreeRPATH(const std::string& config) const; bool HaveInstallTreeRPATH() const; - /** Return the install name directory for the target in the - * build tree. For example: "\@rpath/", "\@loader_path/", - * or "/full/path/to/library". */ - std::string GetInstallNameDirForBuildTree(const std::string& config) const; - - /** Return the install name directory for the target in the - * install tree. For example: "\@rpath/" or "\@loader_path/". */ - std::string GetInstallNameDirForInstallTree() const; - // Get the properties cmPropertyMap &GetProperties() const { return this->Properties; } -- cgit v0.12 From 7a460852fa1bc9df22d4c54bac3d57f909488608 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:48 +0200 Subject: cmGeneratorTarget: Move GetAppBundleDirectory from cmTarget. --- Source/cmGeneratorTarget.cxx | 15 ++++++++++++++- Source/cmGeneratorTarget.h | 4 ++++ Source/cmOSXBundleGenerator.cxx | 4 ++-- Source/cmTarget.cxx | 11 ----------- Source/cmTarget.h | 4 ---- 5 files changed, 20 insertions(+), 18 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 2de3c77..0fdf646 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -890,6 +890,19 @@ std::string cmGeneratorTarget::GetSOName(const std::string& config) const } } + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, + bool contentOnly) const +{ + std::string fpath = this->Target->GetFullName(config, false); + fpath += ".app/Contents"; + if(!contentOnly) + fpath += "/MacOS"; + return fpath; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetInstallNameDirForBuildTree( @@ -976,7 +989,7 @@ cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, std::string fpath = base; if(this->Target->IsAppBundleOnApple()) { - fpath += this->Target->GetAppBundleDirectory(config, contentOnly); + fpath += this->GetAppBundleDirectory(config, contentOnly); } if(this->Target->IsFrameworkOnApple()) { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 6d084f7..f0d8c60 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -115,6 +115,10 @@ public: bool realname) const; std::string NormalGetRealName(const std::string& config) const; + /** @return the Mac App directory without the base */ + std::string GetAppBundleDirectory(const std::string& config, + bool contentOnly) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 7df2f78..1d85d9c 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -47,7 +47,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, // Compute bundle directory names. std::string out = outpath; out += "/"; - out += this->GT->Target->GetAppBundleDirectory(this->ConfigName, false); + out += this->GT->GetAppBundleDirectory(this->ConfigName, false); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); @@ -57,7 +57,7 @@ void cmOSXBundleGenerator::CreateAppBundle(const std::string& targetName, // to be set. std::string plist = outpath; plist += "/"; - plist += this->GT->Target->GetAppBundleDirectory(this->ConfigName, true); + plist += this->GT->GetAppBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, targetName, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b49ad9b..e8ef770 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5323,17 +5323,6 @@ std::string cmTarget::GetCFBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::GetAppBundleDirectory(const std::string& config, - bool contentOnly) const -{ - std::string fpath = this->GetFullName(config, false); - fpath += ".app/Contents"; - if(!contentOnly) - fpath += "/MacOS"; - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index c1c518f..4b804da 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -473,10 +473,6 @@ public: std::string GetCFBundleDirectory(const std::string& config, bool contentOnly) const; - /** @return the Mac App directory without the base */ - std::string GetAppBundleDirectory(const std::string& config, - bool contentOnly) const; - std::vector GetIncludeDirectories( const std::string& config, const std::string& language) const; -- cgit v0.12 From d6bb319b09d056428468d8894f7d7dd2cb0d963e Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:48 +0200 Subject: cmGeneratorTarget: Move GetFullName from cmTarget. Bring GetFullNameInternal with it. --- Source/cmGeneratorTarget.cxx | 180 +++++++++++++++++++++++++++-- Source/cmGeneratorTarget.h | 11 ++ Source/cmGlobalXCodeGenerator.cxx | 5 +- Source/cmLocalVisualStudio6Generator.cxx | 28 ++--- Source/cmLocalVisualStudio7Generator.cxx | 4 +- Source/cmTarget.cxx | 156 ------------------------- Source/cmTarget.h | 10 -- Source/cmVisualStudio10TargetGenerator.cxx | 2 +- 8 files changed, 201 insertions(+), 195 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 0fdf646..436e5dd 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -576,7 +576,7 @@ const char* cmGeneratorTarget::GetLocationForBuild() const } } location += "/"; - location += this->Target->GetFullName("", false); + location += this->GetFullName("", false); return location.c_str(); } @@ -663,7 +663,7 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // Check for a per-configuration output directory target property. std::string configUpper = cmSystemTools::UpperCase(config); @@ -896,7 +896,7 @@ std::string cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, bool contentOnly) const { - std::string fpath = this->Target->GetFullName(config, false); + std::string fpath = this->GetFullName(config, false); fpath += ".app/Contents"; if(!contentOnly) fpath += "/MacOS"; @@ -905,6 +905,20 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, //---------------------------------------------------------------------------- std::string +cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const +{ + if(this->Target->IsImported()) + { + return this->Target->GetFullNameImported(config, implib); + } + else + { + return this->GetFullNameInternal(config, implib); + } +} + +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetInstallNameDirForBuildTree( const std::string& config) const { @@ -977,7 +991,7 @@ void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, const std::string& config, bool implib) const { - this->Target->GetFullNameInternal(config, implib, prefix, base, suffix); + this->GetFullNameInternal(config, implib, prefix, base, suffix); } //---------------------------------------------------------------------------- @@ -1655,7 +1669,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, // Add the full name of the target. if(implib) { - fpath += this->Target->GetFullName(config, true); + fpath += this->GetFullName(config, true); } else if(realname) { @@ -1663,7 +1677,7 @@ std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, } else { - fpath += this->Target->GetFullName(config, false); + fpath += this->GetFullName(config, false); } return fpath; } @@ -1753,7 +1767,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // The library name. name = prefix+base+suffix; @@ -1782,7 +1796,7 @@ void cmGeneratorTarget::GetLibraryNames(std::string& name, if(this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) { - impName = this->Target->GetFullNameInternal(config, true); + impName = this->GetFullNameInternal(config, true); } else { @@ -1828,7 +1842,7 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); // The executable name. name = prefix+base+suffix; @@ -1849,19 +1863,163 @@ void cmGeneratorTarget::GetExecutableNames(std::string& name, #endif // The import library name. - impName = this->Target->GetFullNameInternal(config, true); + impName = this->GetFullNameInternal(config, true); // The program database file name. pdbName = this->GetPDBName(config); } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetFullNameInternal(const std::string& config, + bool implib) const +{ + std::string prefix; + std::string base; + std::string suffix; + this->GetFullNameInternal(config, implib, prefix, base, suffix); + return prefix+base+suffix; +} + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::GetFullNameInternal(const std::string& config, + bool implib, + std::string& outPrefix, + std::string& outBase, + std::string& outSuffix) const +{ + // Use just the target name for non-main target types. + if(this->GetType() != cmTarget::STATIC_LIBRARY && + this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY && + this->GetType() != cmTarget::EXECUTABLE) + { + outPrefix = ""; + outBase = this->GetName(); + outSuffix = ""; + return; + } + + // Return an empty name for the import library if this platform + // does not support import libraries. + if(implib && + !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) + { + outPrefix = ""; + outBase = ""; + outSuffix = ""; + return; + } + + // The implib option is only allowed for shared libraries, module + // libraries, and executables. + if(this->GetType() != cmTarget::SHARED_LIBRARY && + this->GetType() != cmTarget::MODULE_LIBRARY && + this->GetType() != cmTarget::EXECUTABLE) + { + implib = false; + } + + // Compute the full name for main target types. + const char* targetPrefix = (implib + ? this->GetProperty("IMPORT_PREFIX") + : this->GetProperty("PREFIX")); + const char* targetSuffix = (implib + ? this->GetProperty("IMPORT_SUFFIX") + : this->GetProperty("SUFFIX")); + const char* configPostfix = 0; + if(!config.empty()) + { + std::string configProp = cmSystemTools::UpperCase(config); + configProp += "_POSTFIX"; + configPostfix = this->GetProperty(configProp); + // Mac application bundles and frameworks have no postfix. + if(configPostfix && + (this->Target->IsAppBundleOnApple() + || this->Target->IsFrameworkOnApple())) + { + configPostfix = 0; + } + } + const char* prefixVar = this->Target->GetPrefixVariableInternal(implib); + const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); + + // Check for language-specific default prefix and suffix. + std::string ll = this->Target->GetLinkerLanguage(config); + if(!ll.empty()) + { + if(!targetSuffix && suffixVar && *suffixVar) + { + std::string langSuff = suffixVar + std::string("_") + ll; + targetSuffix = this->Makefile->GetDefinition(langSuff); + } + if(!targetPrefix && prefixVar && *prefixVar) + { + std::string langPrefix = prefixVar + std::string("_") + ll; + targetPrefix = this->Makefile->GetDefinition(langPrefix); + } + } + + // if there is no prefix on the target use the cmake definition + if(!targetPrefix && prefixVar) + { + targetPrefix = this->Makefile->GetSafeDefinition(prefixVar); + } + // if there is no suffix on the target use the cmake definition + if(!targetSuffix && suffixVar) + { + targetSuffix = this->Makefile->GetSafeDefinition(suffixVar); + } + + // frameworks have directory prefix but no suffix + std::string fw_prefix; + if(this->Target->IsFrameworkOnApple()) + { + fw_prefix = this->Target->GetOutputName(config, false); + fw_prefix += ".framework/"; + targetPrefix = fw_prefix.c_str(); + targetSuffix = 0; + } + + if(this->Target->IsCFBundleOnApple()) + { + fw_prefix = this->Target->GetCFBundleDirectory(config, false); + fw_prefix += "/"; + targetPrefix = fw_prefix.c_str(); + targetSuffix = 0; + } + + // Begin the final name with the prefix. + outPrefix = targetPrefix?targetPrefix:""; + + // Append the target name or property-specified name. + outBase += this->Target->GetOutputName(config, implib); + + // Append the per-configuration postfix. + outBase += configPostfix?configPostfix:""; + + // Name shared libraries with their version number on some platforms. + if(const char* soversion = this->GetProperty("SOVERSION")) + { + if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib && + this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) + { + outBase += "-"; + outBase += soversion; + } + } + + // Append the suffix. + outSuffix = targetSuffix?targetSuffix:""; +} + + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetPDBName(const std::string& config) const { std::string prefix; std::string base; std::string suffix; - this->Target->GetFullNameInternal(config, false, prefix, base, suffix); + this->GetFullNameInternal(config, false, prefix, base, suffix); std::vector props; std::string configUpper = diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index f0d8c60..1dfdbb3 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -119,6 +119,11 @@ public: std::string GetAppBundleDirectory(const std::string& config, bool contentOnly) const; + /** Get the full name of the target according to the settings in its + makefile. */ + std::string GetFullName(const std::string& config="", + bool implib = false) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ @@ -279,6 +284,12 @@ private: mutable std::map DebugCompatiblePropertiesDone; + std::string GetFullNameInternal(const std::string& config, + bool implib) const; + void GetFullNameInternal(const std::string& config, bool implib, + std::string& outPrefix, std::string& outBase, + std::string& outSuffix) const; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index d53ecde..7b0e153 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -2742,7 +2742,8 @@ cmGlobalXCodeGenerator::CreateXCodeTarget(cmTarget& cmtarget, } else { - fullName = cmtarget.GetFullName(defConfig.c_str()); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); + fullName = gtgt->GetFullName(defConfig.c_str()); } fileRef->AddAttribute("path", this->CreateString(fullName.c_str())); fileRef->AddAttribute("refType", this->CreateString("0")); @@ -3688,7 +3689,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( std::string universalFile = universal; universalFile += *arch; universalFile += "/"; - universalFile += t->GetFullName(configName); + universalFile += gt->GetFullName(configName); makefileStream << "\t/bin/rm -f " << this->ConvertToRelativeForMake(universalFile.c_str()) diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 61d7847..014d3be 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1115,10 +1115,12 @@ void cmLocalVisualStudio6Generator cmTarget* tgt = this->GlobalGenerator->FindTarget(j->first.c_str()); if(tgt) { + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(tgt); lib = cmSystemTools::GetFilenameWithoutExtension - (tgt->GetFullName().c_str()); + (gt->GetFullName().c_str()); libDebug = cmSystemTools::GetFilenameWithoutExtension - (tgt->GetFullName("Debug").c_str()); + (gt->GetFullName("Debug").c_str()); lib += ".lib"; libDebug += ".lib"; } @@ -1258,8 +1260,8 @@ void cmLocalVisualStudio6Generator extraLinkOptionsRelWithDebInfo += targetLinkFlags; } - - + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); // Get standard libraries for this language. if(targetBuilds) @@ -1328,11 +1330,11 @@ void cmLocalVisualStudio6Generator target.GetType() == cmTarget::SHARED_LIBRARY || target.GetType() == cmTarget::MODULE_LIBRARY) { - outputName = target.GetFullName(); - outputNameDebug = target.GetFullName("Debug"); - outputNameRelease = target.GetFullName("Release"); - outputNameMinSizeRel = target.GetFullName("MinSizeRel"); - outputNameRelWithDebInfo = target.GetFullName("RelWithDebInfo"); + outputName = gt->GetFullName(); + outputNameDebug = gt->GetFullName("Debug"); + outputNameRelease = gt->GetFullName("Release"); + outputNameMinSizeRel = gt->GetFullName("MinSizeRel"); + outputNameRelWithDebInfo = gt->GetFullName("RelWithDebInfo"); } else if(target.GetType() == cmTarget::OBJECT_LIBRARY) { @@ -1429,10 +1431,10 @@ void cmLocalVisualStudio6Generator fullPathImpRelease += "/"; fullPathImpMinSizeRel += "/"; fullPathImpRelWithDebInfo += "/"; - fullPathImpDebug += target.GetFullName("Debug", true); - fullPathImpRelease += target.GetFullName("Release", true); - fullPathImpMinSizeRel += target.GetFullName("MinSizeRel", true); - fullPathImpRelWithDebInfo += target.GetFullName("RelWithDebInfo", true); + fullPathImpDebug += gt->GetFullName("Debug", true); + fullPathImpRelease += gt->GetFullName("Release", true); + fullPathImpMinSizeRel += gt->GetFullName("MinSizeRel", true); + fullPathImpRelWithDebInfo += gt->GetFullName("RelWithDebInfo", true); targetImplibFlagDebug = "/implib:"; targetImplibFlagRelease = "/implib:"; diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 799bac6..9f26712 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -803,7 +803,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, if (this->FortranProject) { // Intel Fortran >= 15.0 uses TargetName property. - std::string targetNameFull = target.GetFullName(configName); + std::string targetNameFull = gt->GetFullName(configName); std::string targetName = cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull); std::string targetExt = @@ -1107,7 +1107,7 @@ void cmLocalVisualStudio7Generator::OutputBuildTool(std::ostream& fout, } case cmTarget::STATIC_LIBRARY: { - std::string targetNameFull = target.GetFullName(configName); + std::string targetNameFull = gt->GetFullName(configName); std::string libpath = target.GetDirectory(configName); libpath += "/"; libpath += targetNameFull; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e8ef770..a5ff829 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3587,20 +3587,6 @@ bool cmTarget::IsImportedSharedLibWithoutSOName( } //---------------------------------------------------------------------------- -std::string cmTarget::GetFullName(const std::string& config, - bool implib) const -{ - if(this->IsImported()) - { - return this->GetFullNameImported(config, implib); - } - else - { - return this->GetFullNameInternal(config, implib); - } -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFullNameImported(const std::string& config, bool implib) const { @@ -3626,148 +3612,6 @@ cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const } //---------------------------------------------------------------------------- -std::string -cmTarget::GetFullNameInternal(const std::string& config, bool implib) const -{ - std::string prefix; - std::string base; - std::string suffix; - this->GetFullNameInternal(config, implib, prefix, base, suffix); - return prefix+base+suffix; -} - -//---------------------------------------------------------------------------- -void cmTarget::GetFullNameInternal(const std::string& config, - bool implib, - std::string& outPrefix, - std::string& outBase, - std::string& outSuffix) const -{ - // Use just the target name for non-main target types. - if(this->GetType() != cmTarget::STATIC_LIBRARY && - this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY && - this->GetType() != cmTarget::EXECUTABLE) - { - outPrefix = ""; - outBase = this->GetName(); - outSuffix = ""; - return; - } - - // Return an empty name for the import library if this platform - // does not support import libraries. - if(implib && - !this->Makefile->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) - { - outPrefix = ""; - outBase = ""; - outSuffix = ""; - return; - } - - // The implib option is only allowed for shared libraries, module - // libraries, and executables. - if(this->GetType() != cmTarget::SHARED_LIBRARY && - this->GetType() != cmTarget::MODULE_LIBRARY && - this->GetType() != cmTarget::EXECUTABLE) - { - implib = false; - } - - // Compute the full name for main target types. - const char* targetPrefix = (implib - ? this->GetProperty("IMPORT_PREFIX") - : this->GetProperty("PREFIX")); - const char* targetSuffix = (implib - ? this->GetProperty("IMPORT_SUFFIX") - : this->GetProperty("SUFFIX")); - const char* configPostfix = 0; - if(!config.empty()) - { - std::string configProp = cmSystemTools::UpperCase(config); - configProp += "_POSTFIX"; - configPostfix = this->GetProperty(configProp); - // Mac application bundles and frameworks have no postfix. - if(configPostfix && - (this->IsAppBundleOnApple() || this->IsFrameworkOnApple())) - { - configPostfix = 0; - } - } - const char* prefixVar = this->GetPrefixVariableInternal(implib); - const char* suffixVar = this->GetSuffixVariableInternal(implib); - - // Check for language-specific default prefix and suffix. - std::string ll = this->GetLinkerLanguage(config); - if(!ll.empty()) - { - if(!targetSuffix && suffixVar && *suffixVar) - { - std::string langSuff = suffixVar + std::string("_") + ll; - targetSuffix = this->Makefile->GetDefinition(langSuff); - } - if(!targetPrefix && prefixVar && *prefixVar) - { - std::string langPrefix = prefixVar + std::string("_") + ll; - targetPrefix = this->Makefile->GetDefinition(langPrefix); - } - } - - // if there is no prefix on the target use the cmake definition - if(!targetPrefix && prefixVar) - { - targetPrefix = this->Makefile->GetSafeDefinition(prefixVar); - } - // if there is no suffix on the target use the cmake definition - if(!targetSuffix && suffixVar) - { - targetSuffix = this->Makefile->GetSafeDefinition(suffixVar); - } - - // frameworks have directory prefix but no suffix - std::string fw_prefix; - if(this->IsFrameworkOnApple()) - { - fw_prefix = this->GetOutputName(config, false); - fw_prefix += ".framework/"; - targetPrefix = fw_prefix.c_str(); - targetSuffix = 0; - } - - if(this->IsCFBundleOnApple()) - { - fw_prefix = this->GetCFBundleDirectory(config, false); - fw_prefix += "/"; - targetPrefix = fw_prefix.c_str(); - targetSuffix = 0; - } - - // Begin the final name with the prefix. - outPrefix = targetPrefix?targetPrefix:""; - - // Append the target name or property-specified name. - outBase += this->GetOutputName(config, implib); - - // Append the per-configuration postfix. - outBase += configPostfix?configPostfix:""; - - // Name shared libraries with their version number on some platforms. - if(const char* soversion = this->GetProperty("SOVERSION")) - { - if(this->GetType() == cmTarget::SHARED_LIBRARY && !implib && - this->Makefile->IsOn("CMAKE_SHARED_LIBRARY_NAME_WITH_VERSION")) - { - outBase += "-"; - outBase += soversion; - } - } - - // Append the suffix. - outSuffix = targetSuffix?targetSuffix:""; -} - -//---------------------------------------------------------------------------- void cmTarget::ComputeVersionedName(std::string& vName, std::string const& prefix, std::string const& base, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 4b804da..e22d3af 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -368,11 +368,6 @@ public: ///! Return the preferred linker language for this target std::string GetLinkerLanguage(const std::string& config = "") const; - /** Get the full name of the target according to the settings in its - makefile. */ - std::string GetFullName(const std::string& config="", - bool implib = false) const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; @@ -575,11 +570,6 @@ private: const char* GetSuffixVariableInternal(bool implib) const; const char* GetPrefixVariableInternal(bool implib) const; - std::string GetFullNameInternal(const std::string& config, - bool implib) const; - void GetFullNameInternal(const std::string& config, bool implib, - std::string& outPrefix, std::string& outBase, - std::string& outSuffix) const; // Use a makefile variable to set a default for the given property. // If the variable is not defined use the given default instead. diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 16edf3c..2b33c2c 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1774,7 +1774,7 @@ void cmVisualStudio10TargetGenerator::WritePathAndIncrementalLinkOptions() else { outDir = this->Target->GetDirectory(config->c_str()) + "/"; - targetNameFull = this->Target->GetFullName(config->c_str()); + targetNameFull = this->GeneratorTarget->GetFullName(config->c_str()); } this->ConvertToWindowsSlash(intermediateDir); this->ConvertToWindowsSlash(outDir); -- cgit v0.12 From 6da99de3236fbaeebf6a4fc66f7d68f43a59902f Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:48 +0200 Subject: cmGeneratorTarget: Move GetFrameworkDirectory from cmTarget. --- Source/cmGeneratorTarget.cxx | 48 ++++++++++++++++++++++++++++++++++++++--- Source/cmGeneratorTarget.h | 8 +++++++ Source/cmOSXBundleGenerator.cxx | 8 +++---- Source/cmTarget.cxx | 41 ----------------------------------- Source/cmTarget.h | 8 ------- 5 files changed, 57 insertions(+), 56 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 436e5dd..834a2e3 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -904,6 +904,48 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, + bool contentOnly) const +{ + std::string fpath; + fpath += this->Target->GetOutputName(config, false); + fpath += "."; + const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); + if (!ext) + { + if (this->Target->IsXCTestOnApple()) + { + ext = "xctest"; + } + else + { + ext = "bundle"; + } + } + fpath += ext; + fpath += "/Contents"; + if(!contentOnly) + fpath += "/MacOS"; + return fpath; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, + bool rootDir) const +{ + std::string fpath; + fpath += this->Target->GetOutputName(config, false); + fpath += ".framework"; + if(!rootDir) + { + fpath += "/Versions/"; + fpath += this->Target->GetFrameworkVersion(); + } + return fpath; +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetFullName(const std::string& config, bool implib) const { @@ -1007,11 +1049,11 @@ cmGeneratorTarget::BuildMacContentDirectory(const std::string& base, } if(this->Target->IsFrameworkOnApple()) { - fpath += this->Target->GetFrameworkDirectory(config, contentOnly); + fpath += this->GetFrameworkDirectory(config, contentOnly); } if(this->Target->IsCFBundleOnApple()) { - fpath += this->Target->GetCFBundleDirectory(config, contentOnly); + fpath += this->GetCFBundleDirectory(config, contentOnly); } return fpath; } @@ -1982,7 +2024,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, if(this->Target->IsCFBundleOnApple()) { - fw_prefix = this->Target->GetCFBundleDirectory(config, false); + fw_prefix = this->GetCFBundleDirectory(config, false); fw_prefix += "/"; targetPrefix = fw_prefix.c_str(); targetSuffix = 0; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 1dfdbb3..7ee4fc5 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -124,6 +124,14 @@ public: std::string GetFullName(const std::string& config="", bool implib = false) const; + /** @return the Mac framework directory without the base. */ + std::string GetFrameworkDirectory(const std::string& config, + bool rootDir) const; + + /** @return the Mac CFBundle directory without the base */ + std::string GetCFBundleDirectory(const std::string& config, + bool contentOnly) const; + /** Return the install name directory for the target in the * build tree. For example: "\@rpath/", "\@loader_path/", * or "/full/path/to/library". */ diff --git a/Source/cmOSXBundleGenerator.cxx b/Source/cmOSXBundleGenerator.cxx index 1d85d9c..4fe99e3 100644 --- a/Source/cmOSXBundleGenerator.cxx +++ b/Source/cmOSXBundleGenerator.cxx @@ -77,11 +77,11 @@ void cmOSXBundleGenerator::CreateFramework( // Compute the location of the top-level foo.framework directory. std::string contentdir = outpath + "/" + - this->GT->Target->GetFrameworkDirectory(this->ConfigName, true); + this->GT->GetFrameworkDirectory(this->ConfigName, true); contentdir += "/"; std::string newoutpath = outpath + "/" + - this->GT->Target->GetFrameworkDirectory(this->ConfigName, false); + this->GT->GetFrameworkDirectory(this->ConfigName, false); std::string frameworkVersion = this->GT->Target->GetFrameworkVersion(); @@ -172,14 +172,14 @@ void cmOSXBundleGenerator::CreateCFBundle(const std::string& targetName, // Compute bundle directory names. std::string out = root; out += "/"; - out += this->GT->Target->GetCFBundleDirectory(this->ConfigName, false); + out += this->GT->GetCFBundleDirectory(this->ConfigName, false); cmSystemTools::MakeDirectory(out.c_str()); this->Makefile->AddCMakeOutputFile(out); // Configure the Info.plist file. Note that it needs the executable name // to be set. std::string plist = root + "/" + - this->GT->Target->GetCFBundleDirectory(this->ConfigName, true); + this->GT->GetCFBundleDirectory(this->ConfigName, true); plist += "/Info.plist"; std::string name = cmSystemTools::GetFilenameName(targetName); this->LocalGenerator->GenerateAppleInfoPList(this->GT->Target, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index a5ff829..37b788d 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -5126,47 +5126,6 @@ std::string cmTarget::CheckCMP0004(std::string const& item) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetFrameworkDirectory(const std::string& config, - bool rootDir) const -{ - std::string fpath; - fpath += this->GetOutputName(config, false); - fpath += ".framework"; - if(!rootDir) - { - fpath += "/Versions/"; - fpath += this->GetFrameworkVersion(); - } - return fpath; -} - -//---------------------------------------------------------------------------- -std::string cmTarget::GetCFBundleDirectory(const std::string& config, - bool contentOnly) const -{ - std::string fpath; - fpath += this->GetOutputName(config, false); - fpath += "."; - const char *ext = this->GetProperty("BUNDLE_EXTENSION"); - if (!ext) - { - if (this->IsXCTestOnApple()) - { - ext = "xctest"; - } - else - { - ext = "bundle"; - } - } - fpath += ext; - fpath += "/Contents"; - if(!contentOnly) - fpath += "/MacOS"; - return fpath; -} - -//---------------------------------------------------------------------------- cmTargetInternalPointer::cmTargetInternalPointer() { this->Pointer = new cmTargetInternals; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e22d3af..d0cbc66 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -460,14 +460,6 @@ public: /** @return whether this target have a well defined output file name. */ bool HaveWellDefinedOutputFiles() const; - /** @return the Mac framework directory without the base. */ - std::string GetFrameworkDirectory(const std::string& config, - bool rootDir) const; - - /** @return the Mac CFBundle directory without the base */ - std::string GetCFBundleDirectory(const std::string& config, - bool contentOnly) const; - std::vector GetIncludeDirectories( const std::string& config, const std::string& language) const; -- cgit v0.12 From 7c809fa2a675b7e669e76683f73397e38dd22999 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:49 +0200 Subject: cmGeneratorTarget: Move GetLinkerLanguage from cmTarget. --- Source/cmComputeLinkInformation.cxx | 7 +++---- Source/cmGeneratorExpressionNode.cxx | 10 +++++----- Source/cmGeneratorTarget.cxx | 16 +++++++++++----- Source/cmGeneratorTarget.h | 3 +++ Source/cmGhsMultiTargetGenerator.cxx | 3 ++- Source/cmGlobalXCodeGenerator.cxx | 7 ++++--- Source/cmLocalGenerator.cxx | 2 +- Source/cmLocalVisualStudio6Generator.cxx | 8 ++++---- Source/cmLocalVisualStudio7Generator.cxx | 10 ++++++---- Source/cmMakefileExecutableTargetGenerator.cxx | 2 +- Source/cmMakefileLibraryTargetGenerator.cxx | 10 +++++----- Source/cmMakefileTargetGenerator.cxx | 8 +++++--- Source/cmNinjaNormalTargetGenerator.cxx | 3 +-- Source/cmTarget.cxx | 6 ------ Source/cmTarget.h | 3 --- Source/cmVisualStudio10TargetGenerator.cxx | 6 +++--- 16 files changed, 54 insertions(+), 50 deletions(-) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index b7555a6..c46cab8 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -265,8 +265,10 @@ cmComputeLinkInformation "runtime search path"); this->OrderDependentRPath = 0; + cmGeneratorTarget *gtgt = this->GlobalGenerator + ->GetGeneratorTarget(this->Target); // Get the language used for linking this target. - this->LinkLanguage = this->Target->GetLinkerLanguage(config); + this->LinkLanguage = gtgt->GetLinkerLanguage(config); if(this->LinkLanguage.empty()) { // The Compute method will do nothing, so skip the rest of the @@ -322,9 +324,6 @@ cmComputeLinkInformation (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - cmGeneratorTarget *gtgt = this->Target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); // Get options needed to help find dependent libraries. diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 49fc96b..a86c2bc 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -990,6 +990,9 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode assert(target); + cmGeneratorTarget* gtgt = + context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); + if (propertyName == "LINKER_LANGUAGE") { if (target->LinkLanguagePropagatesToDependents() && @@ -1001,7 +1004,7 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode "link libraries for a static library"); return std::string(); } - return target->GetLinkerLanguage(context->Config); + return gtgt->GetLinkerLanguage(context->Config); } cmGeneratorExpressionDAGChecker dagChecker(context->Backtrace, @@ -1128,9 +1131,6 @@ static const struct TargetPropertyNode : public cmGeneratorExpressionNode } } - cmGeneratorTarget* gtgt = - context->Makefile->GetGlobalGenerator()->GetGeneratorTarget(target); - if (!prop) { if (target->IsImported() @@ -1600,7 +1600,7 @@ struct TargetFilesystemArtifactResultCreator cmGeneratorExpressionContext *context, const GeneratorExpressionContent *content) { - std::string language = target->Target->GetLinkerLanguage(context->Config); + std::string language = target->GetLinkerLanguage(context->Config); std::string pdbSupportVar = "CMAKE_" + language + "_LINKER_SUPPORTS_PDB"; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 834a2e3..4de5e9c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -709,8 +709,7 @@ bool cmGeneratorTarget::HasSOName(const std::string& config) const return ((this->GetType() == cmTarget::SHARED_LIBRARY || this->GetType() == cmTarget::MODULE_LIBRARY) && !this->GetPropertyAsBool("NO_SONAME") && - this->Makefile->GetSONameFlag( - this->Target->GetLinkerLanguage(config))); + this->Makefile->GetSONameFlag(this->GetLinkerLanguage(config))); } //---------------------------------------------------------------------------- @@ -752,7 +751,7 @@ cmGeneratorTarget::NeedRelinkBeforeInstall(const std::string& config) const } // Check for rpath support on this platform. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { std::string flagVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; @@ -823,7 +822,7 @@ bool cmGeneratorTarget::IsChrpathUsed(const std::string& config) const #if defined(CMAKE_USE_ELF_PARSER) // Enable if the rpath flag uses a separator and the target uses ELF // binaries. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { std::string sepVar = "CMAKE_SHARED_LIBRARY_RUNTIME_"; @@ -1986,7 +1985,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, const char* suffixVar = this->Target->GetSuffixVariableInternal(implib); // Check for language-specific default prefix and suffix. - std::string ll = this->Target->GetLinkerLanguage(config); + std::string ll = this->GetLinkerLanguage(config); if(!ll.empty()) { if(!targetSuffix && suffixVar && *suffixVar) @@ -2056,6 +2055,13 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, //---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::GetLinkerLanguage(const std::string& config) const +{ + return this->Target->GetLinkClosure(config)->LinkerLanguage; +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetPDBName(const std::string& config) const { std::string prefix; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 7ee4fc5..41fb848 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -258,6 +258,9 @@ public: /** Return true if builtin chrpath will work for this target */ bool IsChrpathUsed(const std::string& config) const; + ///! Return the preferred linker language for this target + std::string GetLinkerLanguage(const std::string& config = "") const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmGhsMultiTargetGenerator.cxx b/Source/cmGhsMultiTargetGenerator.cxx index 2f9265a..1e57c33 100644 --- a/Source/cmGhsMultiTargetGenerator.cxx +++ b/Source/cmGhsMultiTargetGenerator.cxx @@ -128,7 +128,8 @@ void cmGhsMultiTargetGenerator::Generate() { config = "RELEASE"; } - const std::string language(this->Target->GetLinkerLanguage(config)); + const std::string language( + this->GeneratorTarget->GetLinkerLanguage(config)); config = cmSystemTools::UpperCase(config); this->DynamicDownload = this->DetermineIfDynamicDownload(config, language); if (this->DynamicDownload) diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 7b0e153..5006828 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -1376,7 +1376,8 @@ void cmGlobalXCodeGenerator::ForceLinkerLanguage(cmTarget& cmtarget) return; } - std::string llang = cmtarget.GetLinkerLanguage("NOCONFIG"); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&cmtarget); + std::string llang = gtgt->GetLinkerLanguage("NOCONFIG"); if(llang.empty()) { return; } // If the language is compiled as a source trust Xcode to link with it. @@ -1824,7 +1825,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, AddCompileOptions(flags, &target, lang, configName); } - std::string llang = target.GetLinkerLanguage(configName); + cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); + std::string llang = gtgt->GetLinkerLanguage(configName); if(binary && llang.empty()) { cmSystemTools::Error @@ -1850,7 +1852,6 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmTarget& target, // Add the export symbol definition for shared library objects. this->AppendDefines(ppDefs, exportMacro); } - cmGeneratorTarget *gtgt = this->GetGeneratorTarget(&target); std::vector targetDefines; target.GetCompileDefinitions(targetDefines, configName, "C"); this->AppendDefines(ppDefs, targetDefines); diff --git a/Source/cmLocalGenerator.cxx b/Source/cmLocalGenerator.cxx index 3ab501d..4ec77a1 100644 --- a/Source/cmLocalGenerator.cxx +++ b/Source/cmLocalGenerator.cxx @@ -1353,7 +1353,7 @@ void cmLocalGenerator::GetTargetFlags(std::string& linkLibs, linkFlags += this->Makefile->GetSafeDefinition(build); linkFlags += " "; } - std::string linkLanguage = target->Target->GetLinkerLanguage(buildType); + std::string linkLanguage = target->GetLinkerLanguage(buildType); if(linkLanguage.empty()) { cmSystemTools::Error diff --git a/Source/cmLocalVisualStudio6Generator.cxx b/Source/cmLocalVisualStudio6Generator.cxx index 014d3be..29e1034 100644 --- a/Source/cmLocalVisualStudio6Generator.cxx +++ b/Source/cmLocalVisualStudio6Generator.cxx @@ -1270,10 +1270,10 @@ void cmLocalVisualStudio6Generator std::vector configs; target.GetMakefile()->GetConfigurations(configs); std::vector::const_iterator it = configs.begin(); - const std::string& linkLanguage = target.GetLinkerLanguage(*it); + const std::string& linkLanguage = gt->GetLinkerLanguage(*it); for ( ; it != configs.end(); ++it) { - const std::string& configLinkLanguage = target.GetLinkerLanguage(*it); + const std::string& configLinkLanguage = gt->GetLinkerLanguage(*it); if (configLinkLanguage != linkLanguage) { cmSystemTools::Error @@ -1703,10 +1703,10 @@ void cmLocalVisualStudio6Generator std::vector configs; target.GetMakefile()->GetConfigurations(configs); std::vector::const_iterator it = configs.begin(); - const std::string& linkLanguage = target.GetLinkerLanguage(*it); + const std::string& linkLanguage = gt->GetLinkerLanguage(*it); for ( ; it != configs.end(); ++it) { - const std::string& configLinkLanguage = target.GetLinkerLanguage(*it); + const std::string& configLinkLanguage = gt->GetLinkerLanguage(*it); if (configLinkLanguage != linkLanguage) { cmSystemTools::Error diff --git a/Source/cmLocalVisualStudio7Generator.cxx b/Source/cmLocalVisualStudio7Generator.cxx index 9f26712..a38a061 100644 --- a/Source/cmLocalVisualStudio7Generator.cxx +++ b/Source/cmLocalVisualStudio7Generator.cxx @@ -664,6 +664,10 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, const char* configType = "10"; const char* projectType = 0; bool targetBuilds = true; + + cmGeneratorTarget* gt = + this->GlobalGenerator->GetGeneratorTarget(&target); + switch(target.GetType()) { case cmTarget::OBJECT_LIBRARY: @@ -696,7 +700,7 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, { const std::string& linkLanguage = (this->FortranProject? std::string("Fortran"): - target.GetLinkerLanguage(configName)); + gt->GetLinkerLanguage(configName)); if(linkLanguage.empty()) { cmSystemTools::Error @@ -758,8 +762,6 @@ void cmLocalVisualStudio7Generator::WriteConfiguration(std::ostream& fout, targetOptions.Parse(flags.c_str()); targetOptions.Parse(defineFlags.c_str()); targetOptions.ParseFinish(); - cmGeneratorTarget* gt = - this->GlobalGenerator->GetGeneratorTarget(&target); std::vector targetDefines; target.GetCompileDefinitions(targetDefines, configName, "CXX"); targetOptions.AddDefines(targetDefines); @@ -1635,7 +1637,7 @@ cmLocalVisualStudio7GeneratorFCInfo lg->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); const std::string& sourceLang = lg->GetSourceFileLanguage(sf); - const std::string& linkLanguage = target.GetLinkerLanguage(i->c_str()); + const std::string& linkLanguage = gt->GetLinkerLanguage(i->c_str()); bool needForceLang = false; // source file does not match its extension language if(lang != sourceLang) diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index 2fd77c9..afe145a 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -161,7 +161,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) // Get the language to use for linking this executable. std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. if(linkLanguage.empty()) diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index b85b8a8..bb0f9dd 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -133,7 +133,7 @@ void cmMakefileLibraryTargetGenerator::WriteObjectLibraryRules() void cmMakefileLibraryTargetGenerator::WriteStaticLibraryRules() { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_STATIC_LIBRARY"; @@ -159,7 +159,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) return; } std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_LIBRARY"; @@ -183,7 +183,7 @@ void cmMakefileLibraryTargetGenerator::WriteSharedLibraryRules(bool relink) void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_SHARED_MODULE"; @@ -206,7 +206,7 @@ void cmMakefileLibraryTargetGenerator::WriteModuleLibraryRules(bool relink) void cmMakefileLibraryTargetGenerator::WriteFrameworkRules(bool relink) { std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); std::string linkRuleVar = "CMAKE_"; linkRuleVar += linkLanguage; linkRuleVar += "_CREATE_MACOSX_FRAMEWORK"; @@ -238,7 +238,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules // Get the language to use for linking this library. std::string linkLanguage = - this->Target->GetLinkerLanguage(this->ConfigName); + this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); // Make sure we have a link language. if(linkLanguage.empty()) diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index b94e151..d38cf4c 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1509,7 +1509,7 @@ std::string cmMakefileTargetGenerator::GetLinkRule( if(this->Target->HasImplibGNUtoMS()) { std::string ruleVar = "CMAKE_"; - ruleVar += this->Target->GetLinkerLanguage(this->ConfigName); + ruleVar += this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); ruleVar += "_GNUtoMS_RULE"; if(const char* rule = this->Makefile->GetDefinition(ruleVar)) { @@ -1663,7 +1663,8 @@ cmMakefileTargetGenerator { // Lookup the response file reference flag. std::string responseFlagVar = "CMAKE_"; - responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); + responseFlagVar += this->GeneratorTarget + ->GetLinkerLanguage(this->ConfigName); responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar); @@ -1707,7 +1708,8 @@ cmMakefileTargetGenerator // Lookup the response file reference flag. std::string responseFlagVar = "CMAKE_"; - responseFlagVar += this->Target->GetLinkerLanguage(this->ConfigName); + responseFlagVar += this->GeneratorTarget + ->GetLinkerLanguage(this->ConfigName); responseFlagVar += "_RESPONSE_FILE_LINK_FLAG"; const char* responseFlag = this->Makefile->GetDefinition(responseFlagVar); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index 1835841..b855bea 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -40,8 +40,7 @@ cmNinjaNormalTargetGenerator(cmGeneratorTarget* target) , TargetNamePDB() , TargetLinkLanguage("") { - this->TargetLinkLanguage = target->Target - ->GetLinkerLanguage(this->GetConfigName()); + this->TargetLinkLanguage = target->GetLinkerLanguage(this->GetConfigName()); if (target->GetType() == cmTarget::EXECUTABLE) this->GetGeneratorTarget()->GetExecutableNames(this->TargetNameOut, this->TargetNameReal, diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 37b788d..c7118dc 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3218,12 +3218,6 @@ private: }; //---------------------------------------------------------------------------- -std::string cmTarget::GetLinkerLanguage(const std::string& config) const -{ - return this->GetLinkClosure(config)->LinkerLanguage; -} - -//---------------------------------------------------------------------------- cmTarget::LinkClosure const* cmTarget::GetLinkClosure(const std::string& config) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index d0cbc66..dea9bef 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -365,9 +365,6 @@ public: void GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const; - ///! Return the preferred linker language for this target - std::string GetLinkerLanguage(const std::string& config = "") const; - /** Whether this library has \@rpath and platform supports it. */ bool HasMacOSXRpathInstallNameDir(const std::string& config) const; diff --git a/Source/cmVisualStudio10TargetGenerator.cxx b/Source/cmVisualStudio10TargetGenerator.cxx index 2b33c2c..80b8591 100644 --- a/Source/cmVisualStudio10TargetGenerator.cxx +++ b/Source/cmVisualStudio10TargetGenerator.cxx @@ -1627,7 +1627,7 @@ bool cmVisualStudio10TargetGenerator::OutputSourceSpecificFlags( this->GlobalGenerator->GetLanguageFromExtension (sf.GetExtension().c_str()); std::string sourceLang = this->LocalGenerator->GetSourceFileLanguage(sf); - const std::string& linkLanguage = this->Target->GetLinkerLanguage(); + const std::string& linkLanguage = this->GeneratorTarget->GetLinkerLanguage(); bool needForceLang = false; // source file does not match its extension language if(lang != sourceLang) @@ -1888,7 +1888,7 @@ bool cmVisualStudio10TargetGenerator::ComputeClOptions( std::string flags; const std::string& linkLanguage = - this->Target->GetLinkerLanguage(configName.c_str()); + this->GeneratorTarget->GetLinkerLanguage(configName.c_str()); if(linkLanguage.empty()) { cmSystemTools::Error @@ -2371,7 +2371,7 @@ cmVisualStudio10TargetGenerator::ComputeLinkOptions(std::string const& config) Options& linkOptions = *pOptions; const std::string& linkLanguage = - this->Target->GetLinkerLanguage(config.c_str()); + this->GeneratorTarget->GetLinkerLanguage(config.c_str()); if(linkLanguage.empty()) { cmSystemTools::Error -- cgit v0.12 From f8076644ce21c5c20cb0d368d25c191a05364481 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:49 +0200 Subject: cmGeneratorTarget: Move GetLinkClosure from cmTarget. --- Source/cmComputeLinkInformation.cxx | 15 ++- Source/cmComputeLinkInformation.h | 1 + Source/cmGeneratorTarget.cxx | 226 +++++++++++++++++++++++++++++++++++- Source/cmGeneratorTarget.h | 17 +++ Source/cmTarget.cxx | 221 ----------------------------------- Source/cmTarget.h | 13 --- 6 files changed, 255 insertions(+), 238 deletions(-) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index c46cab8..269aa69 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -19,6 +19,7 @@ #include "cmOutputConverter.h" #include "cmMakefile.h" #include "cmTarget.h" +#include "cmGeneratorTarget.h" #include "cmake.h" #include "cmAlgorithms.h" @@ -579,8 +580,12 @@ bool cmComputeLinkInformation::Compute() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddImplicitLinkInfo() { + cmGeneratorTarget *gtgt = this->Target->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + // The link closure lists all languages whose implicit info is needed. - cmTarget::LinkClosure const* lc=this->Target->GetLinkClosure(this->Config); + cmGeneratorTarget::LinkClosure const* lc=gtgt->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { @@ -2006,8 +2011,12 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // Add runtime paths required by the languages to always be // present. This is done even when skipping rpath support. { - cmTarget::LinkClosure const* lc = - this->Target->GetLinkClosure(this->Config); + cmGeneratorTarget *gtgt = this->Makefile + ->GetGlobalGenerator() + ->GetGeneratorTarget(this->Target); + + cmGeneratorTarget::LinkClosure const* lc = + gtgt->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 3afbb92..2d7a5a5 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -20,6 +20,7 @@ class cmake; class cmGlobalGenerator; class cmMakefile; class cmTarget; +class cmGeneratorTarget; class cmOrderDirectories; /** \class cmComputeLinkInformation diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 4de5e9c..c314372 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -27,6 +27,13 @@ #include #include "assert.h" +#if defined(CMAKE_BUILD_WITH_CMAKE) +#include +#define UNORDERED_SET cmsys::hash_set +#else +#define UNORDERED_SET std::set +#endif + //---------------------------------------------------------------------------- void reportBadObjLib(std::vector const& badObjLib, cmTarget *target, cmake *cm) @@ -1026,6 +1033,223 @@ std::string cmGeneratorTarget::GetInstallNameDirForInstallTree() const } //---------------------------------------------------------------------------- +class cmTargetCollectLinkLanguages +{ +public: + cmTargetCollectLinkLanguages(cmGeneratorTarget const* target, + const std::string& config, + UNORDERED_SET& languages, + cmTarget const* head): + Config(config), Languages(languages), HeadTarget(head), + Makefile(target->Target->GetMakefile()), Target(target) + { this->Visited.insert(target->Target); } + + void Visit(cmLinkItem const& item) + { + if(!item.Target) + { + if(item.find("::") != std::string::npos) + { + bool noMessage = false; + cmake::MessageType messageType = cmake::FATAL_ERROR; + std::stringstream e; + switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028)) + { + case cmPolicies::WARN: + { + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n"; + messageType = cmake::AUTHOR_WARNING; + } + break; + case cmPolicies::OLD: + noMessage = true; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + // Issue the fatal message. + break; + } + + if(!noMessage) + { + e << "Target \"" << this->Target->GetName() + << "\" links to target \"" << item + << "\" but the target was not found. Perhaps a find_package() " + "call is missing for an IMPORTED target, or an ALIAS target is " + "missing?"; + this->Makefile->GetCMakeInstance()->IssueMessage( + messageType, e.str(), this->Target->Target->GetBacktrace()); + } + } + return; + } + if(!this->Visited.insert(item.Target).second) + { + return; + } + + cmTarget::LinkInterface const* iface = + item.Target->GetLinkInterface(this->Config, this->HeadTarget); + if(!iface) { return; } + + for(std::vector::const_iterator + li = iface->Languages.begin(); li != iface->Languages.end(); ++li) + { + this->Languages.insert(*li); + } + + for(std::vector::const_iterator + li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li) + { + this->Visit(*li); + } + } +private: + std::string Config; + UNORDERED_SET& Languages; + cmTarget const* HeadTarget; + cmMakefile* Makefile; + const cmGeneratorTarget* Target; + std::set Visited; +}; + +//---------------------------------------------------------------------------- +cmGeneratorTarget::LinkClosure const* +cmGeneratorTarget::GetLinkClosure(const std::string& config) const +{ + std::string key(cmSystemTools::UpperCase(config)); + LinkClosureMapType::iterator + i = this->LinkClosureMap.find(key); + if(i == this->LinkClosureMap.end()) + { + LinkClosure lc; + this->ComputeLinkClosure(config, lc); + LinkClosureMapType::value_type entry(key, lc); + i = this->LinkClosureMap.insert(entry).first; + } + return &i->second; +} + +//---------------------------------------------------------------------------- +class cmTargetSelectLinker +{ + int Preference; + cmGeneratorTarget const* Target; + cmMakefile* Makefile; + cmGlobalGenerator* GG; + std::set Preferred; +public: + cmTargetSelectLinker(cmGeneratorTarget const* target) + : Preference(0), Target(target) + { + this->Makefile = this->Target->Makefile; + this->GG = this->Makefile->GetGlobalGenerator(); + } + void Consider(const char* lang) + { + int preference = this->GG->GetLinkerPreference(lang); + if(preference > this->Preference) + { + this->Preference = preference; + this->Preferred.clear(); + } + if(preference == this->Preference) + { + this->Preferred.insert(lang); + } + } + std::string Choose() + { + if(this->Preferred.empty()) + { + return ""; + } + else if(this->Preferred.size() > 1) + { + std::stringstream e; + e << "Target " << this->Target->GetName() + << " contains multiple languages with the highest linker preference" + << " (" << this->Preference << "):\n"; + for(std::set::const_iterator + li = this->Preferred.begin(); li != this->Preferred.end(); ++li) + { + e << " " << *li << "\n"; + } + e << "Set the LINKER_LANGUAGE property for this target."; + cmake* cm = this->Makefile->GetCMakeInstance(); + cm->IssueMessage(cmake::FATAL_ERROR, e.str(), + this->Target->Target->GetBacktrace()); + } + return *this->Preferred.begin(); + } +}; + +//---------------------------------------------------------------------------- +void cmGeneratorTarget::ComputeLinkClosure(const std::string& config, + LinkClosure& lc) const +{ + // Get languages built in this target. + UNORDERED_SET languages; + cmTarget::LinkImplementation const* impl = + this->Target->GetLinkImplementation(config); + for(std::vector::const_iterator li = impl->Languages.begin(); + li != impl->Languages.end(); ++li) + { + languages.insert(*li); + } + + // Add interface languages from linked targets. + cmTargetCollectLinkLanguages cll(this, config, languages, this->Target); + for(std::vector::const_iterator li = impl->Libraries.begin(); + li != impl->Libraries.end(); ++li) + { + cll.Visit(*li); + } + + // Store the transitive closure of languages. + for(UNORDERED_SET::const_iterator li = languages.begin(); + li != languages.end(); ++li) + { + lc.Languages.push_back(*li); + } + + // Choose the language whose linker should be used. + if(this->GetProperty("HAS_CXX")) + { + lc.LinkerLanguage = "CXX"; + } + else if(const char* linkerLang = this->GetProperty("LINKER_LANGUAGE")) + { + lc.LinkerLanguage = linkerLang; + } + else + { + // Find the language with the highest preference value. + cmTargetSelectLinker tsl(this); + + // First select from the languages compiled directly in this target. + for(std::vector::const_iterator li = impl->Languages.begin(); + li != impl->Languages.end(); ++li) + { + tsl.Consider(li->c_str()); + } + + // Now consider languages that propagate from linked targets. + for(UNORDERED_SET::const_iterator sit = languages.begin(); + sit != languages.end(); ++sit) + { + std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; + if(this->Makefile->IsOn(propagates)) + { + tsl.Consider(sit->c_str()); + } + } + + lc.LinkerLanguage = tsl.Choose(); + } +} + +//---------------------------------------------------------------------------- void cmGeneratorTarget::GetFullNameComponents(std::string& prefix, std::string& base, std::string& suffix, @@ -2058,7 +2282,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, std::string cmGeneratorTarget::GetLinkerLanguage(const std::string& config) const { - return this->Target->GetLinkClosure(config)->LinkerLanguage; + return this->GetLinkClosure(config)->LinkerLanguage; } //---------------------------------------------------------------------------- diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 41fb848..a1193a6 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -165,6 +165,20 @@ public: std::string GetModuleDefinitionFile(const std::string& config) const; + /** Link information from the transitive closure of the link + implementation and the interfaces of its dependencies. */ + struct LinkClosure + { + // The preferred linker language. + std::string LinkerLanguage; + + // Languages whose runtime libraries must be linked. + std::vector Languages; + }; + + LinkClosure const* GetLinkClosure(const std::string& config) const; + void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; + /** Full path with trailing slash to the top-level directory holding object files for this target. Includes the build time config name placeholder if needed for the generator. */ @@ -301,6 +315,9 @@ private: std::string& outPrefix, std::string& outBase, std::string& outSuffix) const; + typedef std::map LinkClosureMapType; + mutable LinkClosureMapType LinkClosureMap; + struct CompatibleInterfacesBase { std::set PropsBool; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index c7118dc..62aa12a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -160,9 +160,6 @@ public: HeadToLinkImplementationMap> LinkImplMapType; LinkImplMapType LinkImplMap; - typedef std::map LinkClosureMapType; - LinkClosureMapType LinkClosureMap; - typedef std::map > SourceFilesMapType; SourceFilesMapType SourceFilesMap; @@ -511,7 +508,6 @@ void cmTarget::ClearLinkMaps() this->Internal->LinkImplMap.clear(); this->Internal->LinkInterfaceMap.clear(); this->Internal->LinkInterfaceUsageRequirementsOnlyMap.clear(); - this->Internal->LinkClosureMap.clear(); this->Internal->SourceFilesMap.clear(); } @@ -3136,223 +3132,6 @@ bool cmTarget::GetPropertyAsBool(const std::string& prop) const } //---------------------------------------------------------------------------- -class cmTargetCollectLinkLanguages -{ -public: - cmTargetCollectLinkLanguages(cmTarget const* target, - const std::string& config, - UNORDERED_SET& languages, - cmTarget const* head): - Config(config), Languages(languages), HeadTarget(head), - Makefile(target->GetMakefile()), Target(target) - { this->Visited.insert(target); } - - void Visit(cmLinkItem const& item) - { - if(!item.Target) - { - if(item.find("::") != std::string::npos) - { - bool noMessage = false; - cmake::MessageType messageType = cmake::FATAL_ERROR; - std::ostringstream e; - switch(this->Makefile->GetPolicyStatus(cmPolicies::CMP0028)) - { - case cmPolicies::WARN: - { - e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0028) << "\n"; - messageType = cmake::AUTHOR_WARNING; - } - break; - case cmPolicies::OLD: - noMessage = true; - case cmPolicies::REQUIRED_IF_USED: - case cmPolicies::REQUIRED_ALWAYS: - case cmPolicies::NEW: - // Issue the fatal message. - break; - } - - if(!noMessage) - { - e << "Target \"" << this->Target->GetName() - << "\" links to target \"" << item - << "\" but the target was not found. Perhaps a find_package() " - "call is missing for an IMPORTED target, or an ALIAS target is " - "missing?"; - this->Makefile->GetCMakeInstance()->IssueMessage(messageType, - e.str(), - this->Target->GetBacktrace()); - } - } - return; - } - if(!this->Visited.insert(item.Target).second) - { - return; - } - - cmTarget::LinkInterface const* iface = - item.Target->GetLinkInterface(this->Config, this->HeadTarget); - if(!iface) { return; } - - for(std::vector::const_iterator - li = iface->Languages.begin(); li != iface->Languages.end(); ++li) - { - this->Languages.insert(*li); - } - - for(std::vector::const_iterator - li = iface->Libraries.begin(); li != iface->Libraries.end(); ++li) - { - this->Visit(*li); - } - } -private: - std::string Config; - UNORDERED_SET& Languages; - cmTarget const* HeadTarget; - cmMakefile* Makefile; - const cmTarget* Target; - std::set Visited; -}; - -//---------------------------------------------------------------------------- -cmTarget::LinkClosure const* -cmTarget::GetLinkClosure(const std::string& config) const -{ - std::string key(cmSystemTools::UpperCase(config)); - cmTargetInternals::LinkClosureMapType::iterator - i = this->Internal->LinkClosureMap.find(key); - if(i == this->Internal->LinkClosureMap.end()) - { - LinkClosure lc; - this->ComputeLinkClosure(config, lc); - cmTargetInternals::LinkClosureMapType::value_type entry(key, lc); - i = this->Internal->LinkClosureMap.insert(entry).first; - } - return &i->second; -} - -//---------------------------------------------------------------------------- -class cmTargetSelectLinker -{ - int Preference; - cmTarget const* Target; - cmMakefile* Makefile; - cmGlobalGenerator* GG; - UNORDERED_SET Preferred; -public: - cmTargetSelectLinker(cmTarget const* target): Preference(0), Target(target) - { - this->Makefile = this->Target->GetMakefile(); - this->GG = this->Makefile->GetGlobalGenerator(); - } - void Consider(const std::string& lang) - { - int preference = this->GG->GetLinkerPreference(lang); - if(preference > this->Preference) - { - this->Preference = preference; - this->Preferred.clear(); - } - if(preference == this->Preference) - { - this->Preferred.insert(lang); - } - } - std::string Choose() - { - if(this->Preferred.empty()) - { - return ""; - } - else if(this->Preferred.size() > 1) - { - std::ostringstream e; - e << "Target " << this->Target->GetName() - << " contains multiple languages with the highest linker preference" - << " (" << this->Preference << "):\n"; - for(UNORDERED_SET::const_iterator - li = this->Preferred.begin(); li != this->Preferred.end(); ++li) - { - e << " " << *li << "\n"; - } - e << "Set the LINKER_LANGUAGE property for this target."; - cmake* cm = this->Makefile->GetCMakeInstance(); - cm->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); - } - return *this->Preferred.begin(); - } -}; - -//---------------------------------------------------------------------------- -void cmTarget::ComputeLinkClosure(const std::string& config, - LinkClosure& lc) const -{ - // Get languages built in this target. - UNORDERED_SET languages; - LinkImplementation const* impl = this->GetLinkImplementation(config); - for(std::vector::const_iterator li = impl->Languages.begin(); - li != impl->Languages.end(); ++li) - { - languages.insert(*li); - } - - // Add interface languages from linked targets. - cmTargetCollectLinkLanguages cll(this, config, languages, this); - for(std::vector::const_iterator - li = impl->Libraries.begin(); - li != impl->Libraries.end(); ++li) - { - cll.Visit(*li); - } - - // Store the transitive closure of languages. - for(UNORDERED_SET::const_iterator li = languages.begin(); - li != languages.end(); ++li) - { - lc.Languages.push_back(*li); - } - - // Choose the language whose linker should be used. - if(this->GetProperty("HAS_CXX")) - { - lc.LinkerLanguage = "CXX"; - } - else if(const char* linkerLang = this->GetProperty("LINKER_LANGUAGE")) - { - lc.LinkerLanguage = linkerLang; - } - else - { - // Find the language with the highest preference value. - cmTargetSelectLinker tsl(this); - - // First select from the languages compiled directly in this target. - for(std::vector::const_iterator li = impl->Languages.begin(); - li != impl->Languages.end(); ++li) - { - tsl.Consider(*li); - } - - // Now consider languages that propagate from linked targets. - for(UNORDERED_SET::const_iterator sit = languages.begin(); - sit != languages.end(); ++sit) - { - std::string propagates = "CMAKE_"+*sit+"_LINKER_PREFERENCE_PROPAGATES"; - if(this->Makefile->IsOn(propagates)) - { - tsl.Consider(*sit); - } - } - - lc.LinkerLanguage = tsl.Choose(); - } -} - -//---------------------------------------------------------------------------- void cmTarget::ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index dea9bef..9a4915f 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -315,18 +315,6 @@ public: LinkImplementationLibraries const* GetLinkImplementationLibraries(const std::string& config) const; - /** Link information from the transitive closure of the link - implementation and the interfaces of its dependencies. */ - struct LinkClosure - { - // The preferred linker language. - std::string LinkerLanguage; - - // Languages whose runtime libraries must be linked. - std::vector Languages; - }; - LinkClosure const* GetLinkClosure(const std::string& config) const; - cmTarget const* FindTargetToLink(std::string const& name) const; /** Strip off leading and trailing whitespace from an item named in @@ -662,7 +650,6 @@ private: LinkImplementationLibraries const* GetLinkImplementationLibrariesInternal(const std::string& config, cmTarget const* head) const; - void ComputeLinkClosure(const std::string& config, LinkClosure& lc) const; void ExpandLinkItems(std::string const& prop, std::string const& value, std::string const& config, cmTarget const* headTarget, -- cgit v0.12 From c8a5f5ae60c911298fc3c0f168ac3652223722a4 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:49 +0200 Subject: cmMakefileTargetGenerator: Add accessor for GeneratorTarget. --- Source/cmMakefileTargetGenerator.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Source/cmMakefileTargetGenerator.h b/Source/cmMakefileTargetGenerator.h index b885672..fd4527b 100644 --- a/Source/cmMakefileTargetGenerator.h +++ b/Source/cmMakefileTargetGenerator.h @@ -53,6 +53,7 @@ public: { return this->ProgressFileNameFull; } cmTarget* GetTarget() { return this->Target;} + cmGeneratorTarget* GetGeneratorTarget() { return this->GeneratorTarget;} protected: -- cgit v0.12 From ee26add4f4062d8b53f22e161027a573dc03399c Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:49 +0200 Subject: cmGeneratorTarget: Move IsBundleOnApple from cmTarget. --- Source/cmGeneratorTarget.cxx | 8 ++++++++ Source/cmGeneratorTarget.h | 4 ++++ Source/cmMakefileTargetGenerator.cxx | 2 +- Source/cmNinjaTargetGenerator.cxx | 2 +- Source/cmTarget.cxx | 7 ------- Source/cmTarget.h | 4 ---- 6 files changed, 14 insertions(+), 13 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c314372..c68c2b9 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -910,6 +910,14 @@ cmGeneratorTarget::GetAppBundleDirectory(const std::string& config, } //---------------------------------------------------------------------------- +bool cmGeneratorTarget::IsBundleOnApple() const +{ + return this->Target->IsFrameworkOnApple() + || this->Target->IsAppBundleOnApple() + || this->Target->IsCFBundleOnApple(); +} + +//---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, bool contentOnly) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index a1193a6..21e0900 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -119,6 +119,10 @@ public: std::string GetAppBundleDirectory(const std::string& config, bool contentOnly) const; + /** Return whether this target is an executable Bundle, a framework + or CFBundle on Apple. */ + bool IsBundleOnApple() const; + /** Get the full name of the target according to the settings in its makefile. */ std::string GetFullName(const std::string& config="", diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index d38cf4c..0b3df90 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -313,7 +313,7 @@ cmMakefileTargetGenerator::MacOSXContentGeneratorType::operator() (cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. - if(!this->Generator->GetTarget()->IsBundleOnApple()) + if(!this->Generator->GetGeneratorTarget()->IsBundleOnApple()) { return; } diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 16e1f48..07efa16 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -742,7 +742,7 @@ cmNinjaTargetGenerator::MacOSXContentGeneratorType::operator()( cmSourceFile const& source, const char* pkgloc) { // Skip OS X content when not building a Framework or Bundle. - if(!this->Generator->GetTarget()->IsBundleOnApple()) + if(!this->Generator->GetGeneratorTarget()->IsBundleOnApple()) { return; } diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 62aa12a..e887ef3 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -590,13 +590,6 @@ bool cmTarget::IsXCTestOnApple() const } //---------------------------------------------------------------------------- -bool cmTarget::IsBundleOnApple() const -{ - return this->IsFrameworkOnApple() || this->IsAppBundleOnApple() || - this->IsCFBundleOnApple(); -} - -//---------------------------------------------------------------------------- static bool processSources(cmTarget const* tgt, const std::vector &entries, std::vector &srcs, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 9a4915f..e53afff 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -424,10 +424,6 @@ public: /** Return whether this target is an executable Bundle on Apple. */ bool IsAppBundleOnApple() const; - /** Return whether this target is an executable Bundle, a framework - or CFBundle on Apple. */ - bool IsBundleOnApple() const; - /** Return the framework version string. Undefined if IsFrameworkOnApple returns false. */ std::string GetFrameworkVersion() const; -- cgit v0.12 From c93230ac3838231f2f44986e224da1bdaf9a7dfe Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:50 +0200 Subject: cmComputeLinkInformation: Port to cmGeneratorTarget. --- Source/cmComputeLinkInformation.cxx | 84 ++++++++++++++++++------------------- Source/cmComputeLinkInformation.h | 5 ++- Source/cmGeneratorTarget.cxx | 2 +- 3 files changed, 44 insertions(+), 47 deletions(-) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 269aa69..f00a8cf 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -242,11 +242,12 @@ because this need be done only for shared libraries without soname-s. //---------------------------------------------------------------------------- cmComputeLinkInformation -::cmComputeLinkInformation(cmTarget const* target, const std::string& config) +::cmComputeLinkInformation(const cmGeneratorTarget* target, + const std::string& config) { // Store context information. this->Target = target; - this->Makefile = this->Target->GetMakefile(); + this->Makefile = this->Target->Target->GetMakefile(); this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); @@ -259,17 +260,15 @@ cmComputeLinkInformation // Allocate internals. this->OrderLinkerSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "linker search path"); this->OrderRuntimeSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "runtime search path"); this->OrderDependentRPath = 0; - cmGeneratorTarget *gtgt = this->GlobalGenerator - ->GetGeneratorTarget(this->Target); // Get the language used for linking this target. - this->LinkLanguage = gtgt->GetLinkerLanguage(config); + this->LinkLanguage = this->Target->GetLinkerLanguage(config); if(this->LinkLanguage.empty()) { // The Compute method will do nothing, so skip the rest of the @@ -283,14 +282,14 @@ cmComputeLinkInformation // Check whether we should skip dependencies on shared library files. this->LinkDependsNoShared = - this->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); + this->Target->Target->GetPropertyAsBool("LINK_DEPENDS_NO_SHARED"); // On platforms without import libraries there may be a special flag // to use when creating a plugin (module) that obtains symbols from // the program that will load it. this->LoaderFlag = 0; if(!this->UseImportLibrary && - this->Target->GetType() == cmTarget::MODULE_LIBRARY) + this->Target->Target->GetType() == cmTarget::MODULE_LIBRARY) { std::string loader_flag_var = "CMAKE_SHARED_MODULE_LOADER_"; loader_flag_var += this->LinkLanguage; @@ -308,10 +307,10 @@ cmComputeLinkInformation // Get options needed to specify RPATHs. this->RuntimeUseChrpath = false; - if(this->Target->GetType() != cmTarget::STATIC_LIBRARY) + if(this->Target->Target->GetType() != cmTarget::STATIC_LIBRARY) { const char* tType = - ((this->Target->GetType() == cmTarget::EXECUTABLE)? + ((this->Target->Target->GetType() == cmTarget::EXECUTABLE)? "EXECUTABLE" : "SHARED_LIBRARY"); std::string rtVar = "CMAKE_"; rtVar += tType; @@ -325,7 +324,7 @@ cmComputeLinkInformation (this->Makefile-> GetSafeDefinition("CMAKE_PLATFORM_REQUIRED_RUNTIME_PATH")); - this->RuntimeUseChrpath = gtgt->IsChrpathUsed(config); + this->RuntimeUseChrpath = this->Target->IsChrpathUsed(config); // Get options needed to help find dependent libraries. std::string rlVar = "CMAKE_"; @@ -371,15 +370,15 @@ cmComputeLinkInformation { this->SharedDependencyMode = SharedDepModeDir; this->OrderDependentRPath = - new cmOrderDirectories(this->GlobalGenerator, target, + new cmOrderDirectories(this->GlobalGenerator, target->Target, "dependent library path"); } // Add the search path entries requested by the user to path ordering. this->OrderLinkerSearchPath - ->AddUserDirectories(this->Target->GetLinkDirectories()); + ->AddUserDirectories(this->Target->Target->GetLinkDirectories()); this->OrderRuntimeSearchPath - ->AddUserDirectories(this->Target->GetLinkDirectories()); + ->AddUserDirectories(this->Target->Target->GetLinkDirectories()); // Set up the implicit link directories. this->LoadImplicitLinkInfo(); @@ -407,12 +406,13 @@ cmComputeLinkInformation // order to support such projects we need to add the directories // containing libraries linked with a full path to the -L path. this->OldLinkDirMode = - this->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; + this->Target->Target->GetPolicyStatusCMP0003() != cmPolicies::NEW; if(this->OldLinkDirMode) { // Construct a mask to not bother with this behavior for link // directories already specified by the user. - std::vector const& dirs = this->Target->GetLinkDirectories(); + std::vector const& dirs = + this->Target->Target->GetLinkDirectories(); this->OldLinkDirMask.insert(dirs.begin(), dirs.end()); } @@ -497,7 +497,7 @@ bool cmComputeLinkInformation::Compute() } // Compute the ordered link line items. - cmComputeLinkDepends cld(this->Target, this->Config); + cmComputeLinkDepends cld(this->Target->Target, this->Config); cld.SetOldLinkDirMode(this->OldLinkDirMode); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); @@ -518,7 +518,8 @@ bool cmComputeLinkInformation::Compute() // Restore the target link type so the correct system runtime // libraries are found. - const char* lss = this->Target->GetProperty("LINK_SEARCH_END_STATIC"); + const char* lss = + this->Target->Target->GetProperty("LINK_SEARCH_END_STATIC"); if(cmSystemTools::IsOn(lss)) { this->SetCurrentLinkType(LinkStatic); @@ -571,7 +572,7 @@ bool cmComputeLinkInformation::Compute() "name." ; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } return true; @@ -580,12 +581,9 @@ bool cmComputeLinkInformation::Compute() //---------------------------------------------------------------------------- void cmComputeLinkInformation::AddImplicitLinkInfo() { - cmGeneratorTarget *gtgt = this->Target->GetMakefile() - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); - // The link closure lists all languages whose implicit info is needed. - cmGeneratorTarget::LinkClosure const* lc=gtgt->GetLinkClosure(this->Config); + cmGeneratorTarget::LinkClosure const* lc = + this->Target->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { @@ -863,7 +861,8 @@ void cmComputeLinkInformation::ComputeLinkTypeInfo() } // Lookup the starting link type from the target (linked statically?). - const char* lss = this->Target->GetProperty("LINK_SEARCH_START_STATIC"); + const char* lss = + this->Target->Target->GetProperty("LINK_SEARCH_START_STATIC"); this->StartLinkType = cmSystemTools::IsOn(lss)? LinkStatic : LinkShared; this->CurrentLinkType = this->StartLinkType; } @@ -1149,7 +1148,7 @@ void cmComputeLinkInformation::AddFullItem(std::string const& item) // Full path libraries should specify a valid library file name. // See documentation of CMP0008. std::string generator = this->GlobalGenerator->GetName(); - if(this->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && + if(this->Target->Target->GetPolicyStatusCMP0008() != cmPolicies::NEW && (generator.find("Visual Studio") != generator.npos || generator.find("Xcode") != generator.npos)) { @@ -1230,7 +1229,7 @@ bool cmComputeLinkInformation::CheckImplicitDirItem(std::string const& item) } // Check the policy for whether we should use the approach below. - switch (this->Target->GetPolicyStatusCMP0060()) + switch (this->Target->Target->GetPolicyStatusCMP0060()) { case cmPolicies::WARN: if (this->CMP0060Warn) @@ -1540,7 +1539,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, this->OrderLinkerSearchPath->AddLinkLibrary(item); // Produce any needed message. - switch(this->Target->GetPolicyStatusCMP0008()) + switch(this->Target->Target->GetPolicyStatusCMP0008()) { case cmPolicies::WARN: { @@ -1557,7 +1556,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } } case cmPolicies::OLD: @@ -1575,7 +1574,7 @@ void cmComputeLinkInformation::HandleBadFullItem(std::string const& item, << " " << item << "\n" << "which is a full-path but not a valid library file name."; this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } break; } @@ -1592,7 +1591,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() } // Enforce policy constraints. - switch(this->Target->GetPolicyStatusCMP0003()) + switch(this->Target->Target->GetPolicyStatusCMP0003()) { case cmPolicies::WARN: if(!this->CMakeInstance->GetState() @@ -1603,7 +1602,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() std::ostringstream w; this->PrintLinkPolicyDiagnosis(w); this->CMakeInstance->IssueMessage(cmake::AUTHOR_WARNING, w.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); } case cmPolicies::OLD: // OLD behavior is to add the paths containing libraries with @@ -1619,7 +1618,7 @@ bool cmComputeLinkInformation::FinishLinkerSearchDirectories() e << cmPolicies::GetRequiredPolicyError(cmPolicies::CMP0003) << "\n"; this->PrintLinkPolicyDiagnosis(e); this->CMakeInstance->IssueMessage(cmake::FATAL_ERROR, e.str(), - this->Target->GetBacktrace()); + this->Target->Target->GetBacktrace()); return false; } } @@ -1923,23 +1922,24 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // build tree. bool linking_for_install = (for_install || - this->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); + this->Target->Target->GetPropertyAsBool("BUILD_WITH_INSTALL_RPATH")); bool use_install_rpath = - (outputRuntime && this->Target->HaveInstallTreeRPATH() && + (outputRuntime && this->Target->Target->HaveInstallTreeRPATH() && linking_for_install); bool use_build_rpath = - (outputRuntime && this->Target->HaveBuildTreeRPATH(this->Config) && + (outputRuntime && this->Target->Target->HaveBuildTreeRPATH(this->Config) && !linking_for_install); bool use_link_rpath = outputRuntime && linking_for_install && !this->Makefile->IsOn("CMAKE_SKIP_INSTALL_RPATH") && - this->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); + this->Target->Target->GetPropertyAsBool("INSTALL_RPATH_USE_LINK_PATH"); // Construct the RPATH. std::set emitted; if(use_install_rpath) { - const char* install_rpath = this->Target->GetProperty("INSTALL_RPATH"); + const char* install_rpath = + this->Target->Target->GetProperty("INSTALL_RPATH"); cmCLI_ExpandListUnique(install_rpath, runtimeDirs, emitted); } if(use_build_rpath || use_link_rpath) @@ -2011,12 +2011,8 @@ void cmComputeLinkInformation::GetRPath(std::vector& runtimeDirs, // Add runtime paths required by the languages to always be // present. This is done even when skipping rpath support. { - cmGeneratorTarget *gtgt = this->Makefile - ->GetGlobalGenerator() - ->GetGeneratorTarget(this->Target); - cmGeneratorTarget::LinkClosure const* lc = - gtgt->GetLinkClosure(this->Config); + this->Target->GetLinkClosure(this->Config); for(std::vector::const_iterator li = lc->Languages.begin(); li != lc->Languages.end(); ++li) { diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h index 2d7a5a5..8b83574 100644 --- a/Source/cmComputeLinkInformation.h +++ b/Source/cmComputeLinkInformation.h @@ -29,7 +29,8 @@ class cmOrderDirectories; class cmComputeLinkInformation { public: - cmComputeLinkInformation(cmTarget const* target, const std::string& config); + cmComputeLinkInformation(cmGeneratorTarget const* target, + const std::string& config); ~cmComputeLinkInformation(); bool Compute(); @@ -73,7 +74,7 @@ private: std::set SharedLibrariesLinked; // Context information. - cmTarget const* Target; + cmGeneratorTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator* GlobalGenerator; cmake* CMakeInstance; diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c68c2b9..55e2922 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -3166,7 +3166,7 @@ cmGeneratorTarget::GetLinkInformation(const std::string& config) const { // Compute information for this configuration. cmComputeLinkInformation* info = - new cmComputeLinkInformation(this->Target, config); + new cmComputeLinkInformation(this, config); if(!info || !info->Compute()) { delete info; -- cgit v0.12 From 4329a71c128f8a8fca48a8827226d09f61fcbe85 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:50 +0200 Subject: cmComputeLinkDepends: Port to cmGeneratorTarget. --- Source/cmComputeLinkDepends.cxx | 17 +++++++++-------- Source/cmComputeLinkDepends.h | 6 ++++-- Source/cmComputeLinkInformation.cxx | 2 +- 3 files changed, 14 insertions(+), 11 deletions(-) diff --git a/Source/cmComputeLinkDepends.cxx b/Source/cmComputeLinkDepends.cxx index abd9877..8ba8847 100644 --- a/Source/cmComputeLinkDepends.cxx +++ b/Source/cmComputeLinkDepends.cxx @@ -173,18 +173,19 @@ items that we know the linker will re-use automatically (shared libs). //---------------------------------------------------------------------------- cmComputeLinkDepends -::cmComputeLinkDepends(cmTarget const* target, const std::string& config) +::cmComputeLinkDepends(const cmGeneratorTarget* target, + const std::string& config) { // Store context information. this->Target = target; - this->Makefile = this->Target->GetMakefile(); + this->Makefile = this->Target->Target->GetMakefile(); this->GlobalGenerator = this->Makefile->GetGlobalGenerator(); this->CMakeInstance = this->GlobalGenerator->GetCMakeInstance(); // The configuration being linked. this->HasConfig = !config.empty(); this->Config = (this->HasConfig)? config : std::string(); - this->LinkType = this->Target->ComputeLinkType(this->Config); + this->LinkType = this->Target->Target->ComputeLinkType(this->Config); // Enable debug mode if requested. this->DebugMode = this->Makefile->IsOn("CMAKE_LINK_DEPENDS_DEBUG_MODE"); @@ -363,7 +364,7 @@ void cmComputeLinkDepends::FollowLinkEntry(BFSEntry const& qe) { // Follow the target dependencies. if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target)) + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { const bool isIface = entry.Target->GetType() == cmTarget::INTERFACE_LIBRARY; @@ -461,7 +462,7 @@ void cmComputeLinkDepends::HandleSharedDependency(SharedDepEntry const& dep) if(entry.Target) { if(cmTarget::LinkInterface const* iface = - entry.Target->GetLinkInterface(this->Config, this->Target)) + entry.Target->GetLinkInterface(this->Config, this->Target->Target)) { // Follow public and private dependencies transitively. this->FollowSharedDeps(index, iface, true); @@ -552,7 +553,7 @@ void cmComputeLinkDepends::AddDirectLinkEntries() { // Add direct link dependencies in this configuration. cmTarget::LinkImplementation const* impl = - this->Target->GetLinkImplementation(this->Config); + this->Target->Target->GetLinkImplementation(this->Config); this->AddLinkEntries(-1, impl->Libraries); for(std::vector::const_iterator wi = impl->WrongConfigLibraries.begin(); @@ -634,7 +635,7 @@ cmTarget const* cmComputeLinkDepends::FindTargetToLink(int depender_index, const std::string& name) { // Look for a target in the scope of the depender. - cmTarget const* from = this->Target; + cmTarget const* from = this->Target->Target; if(depender_index >= 0) { if(cmTarget const* depender = this->EntryList[depender_index].Target) @@ -932,7 +933,7 @@ int cmComputeLinkDepends::ComputeComponentCount(NodeList const& nl) if(cmTarget const* target = this->EntryList[*ni].Target) { if(cmTarget::LinkInterface const* iface = - target->GetLinkInterface(this->Config, this->Target)) + target->GetLinkInterface(this->Config, this->Target->Target)) { if(iface->Multiplicity > count) { diff --git a/Source/cmComputeLinkDepends.h b/Source/cmComputeLinkDepends.h index 51a08c5..b925a4f 100644 --- a/Source/cmComputeLinkDepends.h +++ b/Source/cmComputeLinkDepends.h @@ -22,6 +22,7 @@ class cmComputeComponentGraph; class cmGlobalGenerator; class cmMakefile; +class cmGeneratorTarget; class cmTarget; class cmake; @@ -31,7 +32,8 @@ class cmake; class cmComputeLinkDepends { public: - cmComputeLinkDepends(cmTarget const* target, const std::string& config); + cmComputeLinkDepends(cmGeneratorTarget const* target, + const std::string& config); ~cmComputeLinkDepends(); // Basic information about each link item. @@ -57,7 +59,7 @@ public: private: // Context information. - cmTarget const* Target; + cmGeneratorTarget const* Target; cmMakefile* Makefile; cmGlobalGenerator const* GlobalGenerator; cmake* CMakeInstance; diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index f00a8cf..7a516e2 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -497,7 +497,7 @@ bool cmComputeLinkInformation::Compute() } // Compute the ordered link line items. - cmComputeLinkDepends cld(this->Target->Target, this->Config); + cmComputeLinkDepends cld(this->Target, this->Config); cld.SetOldLinkDirMode(this->OldLinkDirMode); cmComputeLinkDepends::EntryVector const& linkEntries = cld.Compute(); -- cgit v0.12 From 34c437411dad89c671261269f2067129584a4259 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:50 +0200 Subject: cmGeneratorTarget: Move GetOutputName from cmTarget. --- Source/cmGeneratorTarget.cxx | 56 ++++++++++++++++++++++++++++++++++++++++---- Source/cmGeneratorTarget.h | 3 +++ Source/cmTarget.cxx | 48 ------------------------------------- Source/cmTarget.h | 3 --- 4 files changed, 55 insertions(+), 55 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 55e2922..aac941e 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -267,6 +267,54 @@ const char *cmGeneratorTarget::GetProperty(const std::string& prop) const } //---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetOutputName(const std::string& config, + bool implib) const +{ + std::vector props; + std::string type = this->Target->GetOutputTargetType(implib); + std::string configUpper = cmSystemTools::UpperCase(config); + if(!type.empty() && !configUpper.empty()) + { + // _OUTPUT_NAME_ + props.push_back(type + "_OUTPUT_NAME_" + configUpper); + } + if(!type.empty()) + { + // _OUTPUT_NAME + props.push_back(type + "_OUTPUT_NAME"); + } + if(!configUpper.empty()) + { + // OUTPUT_NAME_ + props.push_back("OUTPUT_NAME_" + configUpper); + // _OUTPUT_NAME + props.push_back(configUpper + "_OUTPUT_NAME"); + } + // OUTPUT_NAME + props.push_back("OUTPUT_NAME"); + + std::string outName; + for(std::vector::const_iterator i = props.begin(); + i != props.end(); ++i) + { + if (const char* outNameProp = this->Target->GetProperty(*i)) + { + outName = outNameProp; + break; + } + } + + if (outName.empty()) + { + outName = this->GetName(); + } + + cmGeneratorExpression ge; + cmsys::auto_ptr cge = ge.Parse(outName); + return cge->Evaluate(this->Makefile, config); +} + +//---------------------------------------------------------------------------- std::vector const* cmGeneratorTarget::GetSourceDepends(cmSourceFile const* sf) const { @@ -922,7 +970,7 @@ std::string cmGeneratorTarget::GetCFBundleDirectory(const std::string& config, bool contentOnly) const { std::string fpath; - fpath += this->Target->GetOutputName(config, false); + fpath += this->GetOutputName(config, false); fpath += "."; const char *ext = this->Target->GetProperty("BUNDLE_EXTENSION"); if (!ext) @@ -949,7 +997,7 @@ cmGeneratorTarget::GetFrameworkDirectory(const std::string& config, bool rootDir) const { std::string fpath; - fpath += this->Target->GetOutputName(config, false); + fpath += this->GetOutputName(config, false); fpath += ".framework"; if(!rootDir) { @@ -2247,7 +2295,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, std::string fw_prefix; if(this->Target->IsFrameworkOnApple()) { - fw_prefix = this->Target->GetOutputName(config, false); + fw_prefix = this->GetOutputName(config, false); fw_prefix += ".framework/"; targetPrefix = fw_prefix.c_str(); targetSuffix = 0; @@ -2265,7 +2313,7 @@ void cmGeneratorTarget::GetFullNameInternal(const std::string& config, outPrefix = targetPrefix?targetPrefix:""; // Append the target name or property-specified name. - outBase += this->Target->GetOutputName(config, implib); + outBase += this->GetOutputName(config, implib); // Append the per-configuration postfix. outBase += configPostfix?configPostfix:""; diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 21e0900..52ab6c0 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -230,6 +230,9 @@ public: /** Get the path for the MSVC /Fd option for this target. */ std::string GetCompilePDBPath(const std::string& config="") const; + // Get the target base name. + std::string GetOutputName(const std::string& config, bool implib) const; + /** * Flags for a given source file as used in this target. Typically assigned * via SET_TARGET_PROPERTIES when the property is a list of source files. diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index e887ef3..8b64bc4 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3663,54 +3663,6 @@ bool cmTarget::UsesDefaultOutputDir(const std::string& config, } //---------------------------------------------------------------------------- -std::string cmTarget::GetOutputName(const std::string& config, - bool implib) const -{ - std::vector props; - std::string type = this->GetOutputTargetType(implib); - std::string configUpper = cmSystemTools::UpperCase(config); - if(!type.empty() && !configUpper.empty()) - { - // _OUTPUT_NAME_ - props.push_back(type + "_OUTPUT_NAME_" + configUpper); - } - if(!type.empty()) - { - // _OUTPUT_NAME - props.push_back(type + "_OUTPUT_NAME"); - } - if(!configUpper.empty()) - { - // OUTPUT_NAME_ - props.push_back("OUTPUT_NAME_" + configUpper); - // _OUTPUT_NAME - props.push_back(configUpper + "_OUTPUT_NAME"); - } - // OUTPUT_NAME - props.push_back("OUTPUT_NAME"); - - std::string outName; - for(std::vector::const_iterator i = props.begin(); - i != props.end(); ++i) - { - if (const char* outNameProp = this->GetProperty(*i)) - { - outName = outNameProp; - break; - } - } - - if (outName.empty()) - { - outName = this->GetName(); - } - - cmGeneratorExpression ge; - cmsys::auto_ptr cge = ge.Parse(outName); - return cge->Evaluate(this->Makefile, config); -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFrameworkVersion() const { assert(this->GetType() != INTERFACE_LIBRARY); diff --git a/Source/cmTarget.h b/Source/cmTarget.h index e53afff..a6f2465 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -552,9 +552,6 @@ private: // Returns ARCHIVE, LIBRARY, or RUNTIME based on platform and type. const char* GetOutputTargetType(bool implib) const; - // Get the target base name. - std::string GetOutputName(const std::string& config, bool implib) const; - std::string GetFullNameImported(const std::string& config, bool implib) const; -- cgit v0.12 From b3f0e35308993de825f00ec18fc6559e6609c9b0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:51 +0200 Subject: cmGeneratorTarget: Move GetCompilePDBDirectory from cmTarget. --- Source/cmGeneratorTarget.cxx | 12 +++++++++++- Source/cmGeneratorTarget.h | 6 ++++++ Source/cmMakefileExecutableTargetGenerator.cxx | 2 +- Source/cmMakefileLibraryTargetGenerator.cxx | 2 +- Source/cmTarget.cxx | 16 ---------------- Source/cmTarget.h | 12 +++++------- 6 files changed, 24 insertions(+), 26 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index aac941e..c6f248c 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -743,7 +743,7 @@ cmGeneratorTarget::GetCompilePDBName(const std::string& config) const std::string cmGeneratorTarget::GetCompilePDBPath(const std::string& config) const { - std::string dir = this->Target->GetCompilePDBDirectory(config); + std::string dir = this->GetCompilePDBDirectory(config); std::string name = this->GetCompilePDBName(config); if(dir.empty() && !name.empty()) { @@ -1824,6 +1824,16 @@ void cmGeneratorTarget::TraceDependencies() tracer.Trace(); } +std::string +cmGeneratorTarget::GetCompilePDBDirectory(const std::string& config) const +{ + if(cmTarget::CompileInfo const* info = this->Target->GetCompileInfo(config)) + { + return info->CompilePdbDir; + } + return ""; +} + //---------------------------------------------------------------------------- void cmGeneratorTarget::GetAppleArchs(const std::string& config, std::vector& archVec) const diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 52ab6c0..3dbbca1 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -214,6 +214,12 @@ public: */ void TraceDependencies(); + /** Get the directory in which to place the target compiler .pdb file. + If the configuration name is given then the generator will add its + subdirectory for that configuration. Otherwise just the canonical + compiler pdb output directory is given. */ + std::string GetCompilePDBDirectory(const std::string& config = "") const; + /** Get sources that must be built before the given source. */ std::vector const* GetSourceDepends(cmSourceFile const* sf) const; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index afe145a..ccb0974 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -130,7 +130,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) } std::string compilePdbOutputPath = - this->Target->GetCompilePDBDirectory(this->ConfigName); + this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index bb0f9dd..2f995e8 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -311,7 +311,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules } std::string compilePdbOutputPath = - this->Target->GetCompilePDBDirectory(this->ConfigName); + this->GeneratorTarget->GetCompilePDBDirectory(this->ConfigName); cmSystemTools::MakeDirectory(compilePdbOutputPath.c_str()); std::string pdbOutputPath = this->Target->GetPDBDirectory(this->ConfigName); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 8b64bc4..9308113 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -69,12 +69,6 @@ struct cmTarget::OutputInfo }; //---------------------------------------------------------------------------- -struct cmTarget::CompileInfo -{ - std::string CompilePdbDir; -}; - -//---------------------------------------------------------------------------- class cmTargetInternals { public: @@ -2673,16 +2667,6 @@ std::string cmTarget::GetPDBDirectory(const std::string& config) const } //---------------------------------------------------------------------------- -std::string cmTarget::GetCompilePDBDirectory(const std::string& config) const -{ - if(CompileInfo const* info = this->GetCompileInfo(config)) - { - return info->CompilePdbDir; - } - return ""; -} - -//---------------------------------------------------------------------------- const char* cmTarget::ImportedGetLocation(const std::string& config) const { static std::string location; diff --git a/Source/cmTarget.h b/Source/cmTarget.h index a6f2465..8689838 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -334,12 +334,6 @@ public: pdb output directory is given. */ std::string GetPDBDirectory(const std::string& config) const; - /** Get the directory in which to place the target compiler .pdb file. - If the configuration name is given then the generator will add its - subdirectory for that configuration. Otherwise just the canonical - compiler pdb output directory is given. */ - std::string GetCompilePDBDirectory(const std::string& config = "") const; - const char* ImportedGetLocation(const std::string& config) const; /** Get the target major and minor version numbers interpreted from @@ -633,7 +627,11 @@ private: ImportInfo& info) const; // Cache target compile paths for each configuration. - struct CompileInfo; + struct CompileInfo + { + std::string CompilePdbDir; + }; + CompileInfo const* GetCompileInfo(const std::string& config) const; LinkInterface const* -- cgit v0.12 From f83e84028ac28ce098ea76bd857ae1663c295494 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:51 +0200 Subject: cmGeneratorTarget: Move CompileInfoMap from cmTarget. --- Source/cmGeneratorTarget.cxx | 42 +++++++++++++++++++++++++++++++++++++++++- Source/cmGeneratorTarget.h | 10 ++++++++++ Source/cmTarget.cxx | 42 ------------------------------------------ Source/cmTarget.h | 7 ------- 4 files changed, 51 insertions(+), 50 deletions(-) diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c6f248c..c831704 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -1356,6 +1356,46 @@ cmGeneratorTarget::GetMacContentDirectory(const std::string& config, return fpath; } + +//---------------------------------------------------------------------------- +cmGeneratorTarget::CompileInfo const* cmGeneratorTarget::GetCompileInfo( + const std::string& config) const +{ + // There is no compile information for imported targets. + if(this->IsImported()) + { + return 0; + } + + if(this->GetType() > cmTarget::OBJECT_LIBRARY) + { + std::string msg = "cmTarget::GetCompileInfo called for "; + msg += this->GetName(); + msg += " which has type "; + msg += cmTarget::GetTargetTypeName(this->Target->GetType()); + this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, msg); + return 0; + } + + // Lookup/compute/cache the compile information for this configuration. + std::string config_upper; + if(!config.empty()) + { + config_upper = cmSystemTools::UpperCase(config); + } + CompileInfoMapType::const_iterator i = + this->CompileInfoMap.find(config_upper); + if(i == this->CompileInfoMap.end()) + { + CompileInfo info; + this->Target + ->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); + CompileInfoMapType::value_type entry(config_upper, info); + i = this->CompileInfoMap.insert(entry).first; + } + return &i->second; +} + //---------------------------------------------------------------------------- std::string cmGeneratorTarget::GetModuleDefinitionFile(const std::string& config) const @@ -1827,7 +1867,7 @@ void cmGeneratorTarget::TraceDependencies() std::string cmGeneratorTarget::GetCompilePDBDirectory(const std::string& config) const { - if(cmTarget::CompileInfo const* info = this->Target->GetCompileInfo(config)) + if(CompileInfo const* info = this->GetCompileInfo(config)) { return info->CompilePdbDir; } diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 3dbbca1..68e7a8a 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -230,6 +230,16 @@ public: /** Whether this library has soname enabled and platform supports it. */ bool HasSOName(const std::string& config) const; + struct CompileInfo + { + std::string CompilePdbDir; + }; + + CompileInfo const* GetCompileInfo(const std::string& config) const; + + typedef std::map CompileInfoMapType; + mutable CompileInfoMapType CompileInfoMap; + /** Get the name of the compiler pdb file for the target. */ std::string GetCompilePDBName(const std::string& config="") const; diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index 9308113..1f8f07a 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -126,9 +126,6 @@ public: typedef std::map ImportInfoMapType; ImportInfoMapType ImportInfoMap; - typedef std::map CompileInfoMapType; - CompileInfoMapType CompileInfoMap; - // Cache link implementation computation from each configuration. struct OptionalLinkImplementation: public cmTarget::LinkImplementation { @@ -2598,45 +2595,6 @@ cmTarget::OutputInfo const* cmTarget::GetOutputInfo( } //---------------------------------------------------------------------------- -cmTarget::CompileInfo const* cmTarget::GetCompileInfo( - const std::string& config) const -{ - // There is no compile information for imported targets. - if(this->IsImported()) - { - return 0; - } - - if(this->GetType() > cmTarget::OBJECT_LIBRARY) - { - std::string msg = "cmTarget::GetCompileInfo called for "; - msg += this->GetName(); - msg += " which has type "; - msg += cmTarget::GetTargetTypeName(this->GetType()); - this->GetMakefile()->IssueMessage(cmake::INTERNAL_ERROR, msg); - return 0; - } - - // Lookup/compute/cache the compile information for this configuration. - std::string config_upper; - if(!config.empty()) - { - config_upper = cmSystemTools::UpperCase(config); - } - typedef cmTargetInternals::CompileInfoMapType CompileInfoMapType; - CompileInfoMapType::const_iterator i = - this->Internal->CompileInfoMap.find(config_upper); - if(i == this->Internal->CompileInfoMap.end()) - { - CompileInfo info; - this->ComputePDBOutputDir("COMPILE_PDB", config, info.CompilePdbDir); - CompileInfoMapType::value_type entry(config_upper, info); - i = this->Internal->CompileInfoMap.insert(entry).first; - } - return &i->second; -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetDirectory(const std::string& config, bool implib) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 8689838..e3fbdfd 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -626,13 +626,6 @@ private: void ComputeImportInfo(std::string const& desired_config, ImportInfo& info) const; - // Cache target compile paths for each configuration. - struct CompileInfo - { - std::string CompilePdbDir; - }; - - CompileInfo const* GetCompileInfo(const std::string& config) const; LinkInterface const* GetImportLinkInterface(const std::string& config, cmTarget const* head, -- cgit v0.12 From a309409ead0bde721a17e8b3c4e89fe6a2181423 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Tue, 4 Aug 2015 19:19:51 +0200 Subject: cmOrderDirectories: Port to cmGeneratorTarget. --- Source/cmComputeLinkInformation.cxx | 6 +++--- Source/cmOrderDirectories.cxx | 8 +++++--- Source/cmOrderDirectories.h | 6 +++--- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 7a516e2..c3f36af 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -260,10 +260,10 @@ cmComputeLinkInformation // Allocate internals. this->OrderLinkerSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "linker search path"); this->OrderRuntimeSearchPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "runtime search path"); this->OrderDependentRPath = 0; @@ -370,7 +370,7 @@ cmComputeLinkInformation { this->SharedDependencyMode = SharedDepModeDir; this->OrderDependentRPath = - new cmOrderDirectories(this->GlobalGenerator, target->Target, + new cmOrderDirectories(this->GlobalGenerator, target, "dependent library path"); } diff --git a/Source/cmOrderDirectories.cxx b/Source/cmOrderDirectories.cxx index a612437..35ee127 100644 --- a/Source/cmOrderDirectories.cxx +++ b/Source/cmOrderDirectories.cxx @@ -280,7 +280,7 @@ bool cmOrderDirectoriesConstraintLibrary::FindConflict(std::string const& dir) //---------------------------------------------------------------------------- cmOrderDirectories::cmOrderDirectories(cmGlobalGenerator* gg, - cmTarget const* target, + const cmGeneratorTarget* target, const char* purpose) { this->GlobalGenerator = gg; @@ -554,7 +554,8 @@ void cmOrderDirectories::FindImplicitConflicts() << text << "Some of these libraries may not be found correctly."; this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::WARNING, w.str(), this->Target->GetBacktrace()); + ->IssueMessage(cmake::WARNING, w.str(), + this->Target->Target->GetBacktrace()); } //---------------------------------------------------------------------------- @@ -635,5 +636,6 @@ void cmOrderDirectories::DiagnoseCycle() } e << "Some of these libraries may not be found correctly."; this->GlobalGenerator->GetCMakeInstance() - ->IssueMessage(cmake::WARNING, e.str(), this->Target->GetBacktrace()); + ->IssueMessage(cmake::WARNING, e.str(), + this->Target->Target->GetBacktrace()); } diff --git a/Source/cmOrderDirectories.h b/Source/cmOrderDirectories.h index cb5a51f..211c786 100644 --- a/Source/cmOrderDirectories.h +++ b/Source/cmOrderDirectories.h @@ -19,7 +19,7 @@ class cmGlobalGenerator; class cmOrderDirectoriesConstraint; class cmOrderDirectoriesConstraintLibrary; -class cmTarget; +class cmGeneratorTarget; /** \class cmOrderDirectories * \brief Compute a safe runtime path order for a set of shared libraries. @@ -27,7 +27,7 @@ class cmTarget; class cmOrderDirectories { public: - cmOrderDirectories(cmGlobalGenerator* gg, cmTarget const* target, + cmOrderDirectories(cmGlobalGenerator* gg, cmGeneratorTarget const* target, const char* purpose); ~cmOrderDirectories(); void AddRuntimeLibrary(std::string const& fullPath, const char* soname = 0); @@ -41,7 +41,7 @@ public: std::vector const& GetOrderedDirectories(); private: cmGlobalGenerator* GlobalGenerator; - cmTarget const* Target; + cmGeneratorTarget const* Target; std::string Purpose; std::vector OrderedDirectories; -- cgit v0.12