diff options
author | Stephen Kelly <steveire@gmail.com> | 2012-10-06 16:30:43 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-07-27 19:59:02 (GMT) |
commit | ec38e4c84faa276e664f950b417a71c3901485f6 (patch) | |
tree | 7d7a85fcee40d9f950344f07ea4af5480a05e213 | |
parent | dfb025bf126080f6bb209f6f40ff909c4f5c5c97 (diff) | |
download | CMake-ec38e4c84faa276e664f950b417a71c3901485f6.zip CMake-ec38e4c84faa276e664f950b417a71c3901485f6.tar.gz CMake-ec38e4c84faa276e664f950b417a71c3901485f6.tar.bz2 |
Move GetFullPath to cmGeneratorTarget
-rw-r--r-- | Source/cmComputeLinkInformation.cxx | 18 | ||||
-rw-r--r-- | Source/cmExportBuildFileGenerator.cxx | 9 | ||||
-rw-r--r-- | Source/cmGeneratorExpressionNode.cxx | 35 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.cxx | 82 | ||||
-rw-r--r-- | Source/cmGeneratorTarget.h | 8 | ||||
-rw-r--r-- | Source/cmGlobalNinjaGenerator.cxx | 8 | ||||
-rw-r--r-- | Source/cmGlobalXCodeGenerator.cxx | 3 | ||||
-rw-r--r-- | Source/cmMakefileTargetGenerator.cxx | 2 | ||||
-rw-r--r-- | Source/cmNinjaNormalTargetGenerator.cxx | 7 | ||||
-rw-r--r-- | Source/cmTarget.cxx | 84 | ||||
-rw-r--r-- | Source/cmTarget.h | 13 | ||||
-rw-r--r-- | Source/cmTestGenerator.cxx | 2 |
12 files changed, 143 insertions, 128 deletions
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx index 1f3046a..e63b44f 100644 --- a/Source/cmComputeLinkInformation.cxx +++ b/Source/cmComputeLinkInformation.cxx @@ -535,10 +535,13 @@ bool cmComputeLinkInformation::Compute() i != wrongItems.end(); ++i) { cmTarget const* tgt = *i; + cmGeneratorTarget *gtgt = tgt->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(tgt); bool implib = (this->UseImportLibrary && (tgt->GetType() == cmTarget::SHARED_LIBRARY)); - std::string lib = tgt->GetFullPath(this->Config , implib, true); + std::string lib = gtgt->GetFullPath(this->Config , implib, true); this->OldLinkDirItems.push_back(lib); } } @@ -637,6 +640,9 @@ void cmComputeLinkInformation::AddItem(std::string const& item, if(tgt && tgt->IsLinkable()) { + cmGeneratorTarget *gtgt = tgt->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(tgt); // This is a CMake target. Ask the target for its real name. if(impexe && this->LoaderFlag) { @@ -645,7 +651,8 @@ void cmComputeLinkInformation::AddItem(std::string const& item, // platform. Add it now. std::string linkItem; linkItem = this->LoaderFlag; - std::string exe = tgt->GetFullPath(config, this->UseImportLibrary, + + std::string exe = gtgt->GetFullPath(config, this->UseImportLibrary, true); linkItem += exe; this->Items.push_back(Item(linkItem, true, tgt)); @@ -666,7 +673,7 @@ void cmComputeLinkInformation::AddItem(std::string const& item, (impexe || tgt->GetType() == cmTarget::SHARED_LIBRARY)); // Pass the full path to the target file. - std::string lib = tgt->GetFullPath(config, implib, true); + std::string lib = gtgt->GetFullPath(config, implib, true); if(!this->LinkDependsNoShared || tgt->GetType() != cmTarget::SHARED_LIBRARY) { @@ -755,7 +762,10 @@ void cmComputeLinkInformation::AddSharedDepItem(std::string const& item, std::string lib; if(tgt) { - lib = tgt->GetFullPath(this->Config, this->UseImportLibrary); + cmGeneratorTarget *gtgt = tgt->GetMakefile() + ->GetGlobalGenerator() + ->GetGeneratorTarget(tgt); + lib = gtgt->GetFullPath(this->Config, this->UseImportLibrary); this->AddLibraryRuntimeInfo(lib, tgt); } else diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index 568ce89..9ed2880 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -181,6 +181,9 @@ cmExportBuildFileGenerator // Get the makefile in which to lookup target information. cmMakefile* mf = target->GetMakefile(); + cmGeneratorTarget* gtgt = + mf->GetGlobalGenerator()->GetGeneratorTarget(target); + // Add the main target file. { std::string prop = "IMPORTED_LOCATION"; @@ -188,11 +191,11 @@ cmExportBuildFileGenerator std::string value; if(target->IsAppBundleOnApple()) { - value = target->GetFullPath(config, false); + value = gtgt->GetFullPath(config, false); } else { - value = target->GetFullPath(config, false, true); + value = gtgt->GetFullPath(config, false, true); } properties[prop] = value; } @@ -209,7 +212,7 @@ cmExportBuildFileGenerator { std::string prop = "IMPORTED_IMPLIB"; prop += suffix; - std::string value = target->GetFullPath(config, true); + std::string value = gtgt->GetFullPath(config, true); target->GetImplibGNUtoMS(value, value, "${CMAKE_IMPORT_LIBRARY_SUFFIX}"); properties[prop] = value; diff --git a/Source/cmGeneratorExpressionNode.cxx b/Source/cmGeneratorExpressionNode.cxx index 90c82c2..3daa7b8 100644 --- a/Source/cmGeneratorExpressionNode.cxx +++ b/Source/cmGeneratorExpressionNode.cxx @@ -1556,7 +1556,7 @@ class ArtifactDirTag; template<typename ArtifactT> struct TargetFilesystemArtifactResultCreator { - static std::string Create(cmTarget* target, + static std::string Create(cmGeneratorTarget* target, cmGeneratorExpressionContext *context, const GeneratorExpressionContent *content); }; @@ -1565,12 +1565,12 @@ struct TargetFilesystemArtifactResultCreator template<> struct TargetFilesystemArtifactResultCreator<ArtifactSonameTag> { - static std::string Create(cmTarget* target, + static std::string Create(cmGeneratorTarget* target, cmGeneratorExpressionContext *context, const GeneratorExpressionContent *content) { // The target soname file (.so.1). - if(target->IsDLLPlatform()) + if(target->Target->IsDLLPlatform()) { ::reportError(context, content->GetOriginalExpression(), "TARGET_SONAME_FILE is not allowed " @@ -1584,9 +1584,9 @@ struct TargetFilesystemArtifactResultCreator<ArtifactSonameTag> "SHARED libraries."); return std::string(); } - std::string result = target->GetDirectory(context->Config); + std::string result = target->Target->GetDirectory(context->Config); result += "/"; - result += target->GetSOName(context->Config); + result += target->Target->GetSOName(context->Config); return result; } }; @@ -1595,11 +1595,11 @@ struct TargetFilesystemArtifactResultCreator<ArtifactSonameTag> template<> struct TargetFilesystemArtifactResultCreator<ArtifactPdbTag> { - static std::string Create(cmTarget* target, + static std::string Create(cmGeneratorTarget* target, cmGeneratorExpressionContext *context, const GeneratorExpressionContent *content) { - std::string language = target->GetLinkerLanguage(context->Config); + std::string language = target->Target->GetLinkerLanguage(context->Config); std::string pdbSupportVar = "CMAKE_" + language + "_LINKER_SUPPORTS_PDB"; @@ -1610,7 +1610,7 @@ struct TargetFilesystemArtifactResultCreator<ArtifactPdbTag> return std::string(); } - cmTarget::TargetType targetType = target->GetType(); + cmTarget::TargetType targetType = target->Target->GetType(); if(targetType != cmTarget::SHARED_LIBRARY && targetType != cmTarget::MODULE_LIBRARY && @@ -1622,9 +1622,9 @@ struct TargetFilesystemArtifactResultCreator<ArtifactPdbTag> return std::string(); } - std::string result = target->GetPDBDirectory(context->Config); + std::string result = target->Target->GetPDBDirectory(context->Config); result += "/"; - result += target->GetPDBName(context->Config); + result += target->Target->GetPDBName(context->Config); return result; } }; @@ -1633,12 +1633,12 @@ struct TargetFilesystemArtifactResultCreator<ArtifactPdbTag> template<> struct TargetFilesystemArtifactResultCreator<ArtifactLinkerTag> { - static std::string Create(cmTarget* target, + static std::string Create(cmGeneratorTarget* target, cmGeneratorExpressionContext *context, const GeneratorExpressionContent *content) { // The file used to link to the target (.so, .lib, .a). - if(!target->IsLinkable()) + if(!target->Target->IsLinkable()) { ::reportError(context, content->GetOriginalExpression(), "TARGET_LINKER_FILE is allowed only for libraries and " @@ -1646,7 +1646,7 @@ struct TargetFilesystemArtifactResultCreator<ArtifactLinkerTag> return std::string(); } return target->GetFullPath(context->Config, - target->HasImportLibrary()); + target->Target->HasImportLibrary()); } }; @@ -1654,7 +1654,7 @@ struct TargetFilesystemArtifactResultCreator<ArtifactLinkerTag> template<> struct TargetFilesystemArtifactResultCreator<ArtifactNameTag> { - static std::string Create(cmTarget* target, + static std::string Create(cmGeneratorTarget* target, cmGeneratorExpressionContext *context, const GeneratorExpressionContent *) { @@ -1716,7 +1716,8 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode "Expression syntax not recognized."); return std::string(); } - cmTarget* target = context->Makefile->FindTargetToUse(name); + cmGeneratorTarget* target = + context->Makefile->FindGeneratorTargetToUse(name); if(!target) { ::reportError(context, content->GetOriginalExpression(), @@ -1739,8 +1740,8 @@ struct TargetFilesystemArtifact : public cmGeneratorExpressionNode "be used while evaluating link libraries"); return std::string(); } - context->DependTargets.insert(target); - context->AllTargets.insert(target); + context->DependTargets.insert(target->Target); + context->AllTargets.insert(target->Target); std::string result = TargetFilesystemArtifactResultCreator<ArtifactT>::Create( diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index efb414e..edd89e8 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -529,7 +529,7 @@ const char* cmGeneratorTarget::GetLocation(const std::string& config) const } else { - location = this->Target->GetFullPath(config, false); + location = this->GetFullPath(config, false); } return location.c_str(); } @@ -1182,6 +1182,86 @@ void cmGeneratorTarget::GenerateTargetManifest( } } +//---------------------------------------------------------------------------- +std::string cmGeneratorTarget::GetFullPath(const std::string& config, + bool implib, bool realname) const +{ + if(this->Target->IsImported()) + { + return this->Target->ImportedGetFullPath(config, implib); + } + else + { + return this->NormalGetFullPath(config, implib, realname); + } +} + +std::string cmGeneratorTarget::NormalGetFullPath(const std::string& config, + bool implib, + bool realname) const +{ + std::string fpath = this->Target->GetDirectory(config, implib); + fpath += "/"; + if(this->Target->IsAppBundleOnApple()) + { + fpath = this->Target->BuildMacContentDirectory(fpath, config, false); + fpath += "/"; + } + + // Add the full name of the target. + if(implib) + { + fpath += this->Target->GetFullName(config, true); + } + else if(realname) + { + fpath += this->NormalGetRealName(config); + } + else + { + fpath += this->Target->GetFullName(config, false); + } + return fpath; +} + +//---------------------------------------------------------------------------- +std::string +cmGeneratorTarget::NormalGetRealName(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 = "NormalGetRealName called on imported target: "; + msg += this->GetName(); + this->Makefile->IssueMessage(cmake::INTERNAL_ERROR, msg); + } + + if(this->GetType() == cmTarget::EXECUTABLE) + { + // Compute the real name that will be built. + std::string name; + std::string realName; + std::string impName; + std::string pdbName; + this->Target->GetExecutableNames(name, realName, impName, pdbName, config); + return realName; + } + else + { + // Compute the real name 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 realName; + } +} + bool cmStrictTargetComparison::operator()(cmTarget const* t1, cmTarget const* t2) const { diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index 72c5706..a584c71 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -82,6 +82,14 @@ public: bool GetFeatureAsBool(const std::string& feature, 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, + bool realname = false) const; + std::string NormalGetFullPath(const std::string& config, bool implib, + bool realname) const; + std::string NormalGetRealName(const std::string& config) const; + cmTarget* Target; cmMakefile* Makefile; cmLocalGenerator* LocalGenerator; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index b88b8c8..d24cce8 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -910,10 +910,14 @@ cmGlobalNinjaGenerator case cmTarget::SHARED_LIBRARY: case cmTarget::STATIC_LIBRARY: case cmTarget::MODULE_LIBRARY: + { + cmGeneratorTarget *gtgt = target->GetMakefile()->GetLocalGenerator() + ->GetGlobalGenerator() + ->GetGeneratorTarget(target); outputs.push_back(ng->ConvertToNinjaPath( - target->GetFullPath(configName, false, realname))); + gtgt->GetFullPath(configName, false, realname))); break; - + } case cmTarget::OBJECT_LIBRARY: case cmTarget::UTILITY: { std::string path = ng->ConvertToNinjaPath( diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx index 6e46bc0..ba5ff30 100644 --- a/Source/cmGlobalXCodeGenerator.cxx +++ b/Source/cmGlobalXCodeGenerator.cxx @@ -3598,6 +3598,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( { cmXCodeObject* target = *i; cmTarget* t =target->GetTarget(); + cmGeneratorTarget *gt = this->GetGeneratorTarget(t); if(t->GetType() == cmTarget::EXECUTABLE || // Nope - no post-build for OBJECT_LIRBRARY @@ -3615,7 +3616,7 @@ cmGlobalXCodeGenerator::CreateXCodeDependHackTarget( t->GetType() == cmTarget::SHARED_LIBRARY || t->GetType() == cmTarget::MODULE_LIBRARY) { - std::string tfull = t->GetFullPath(configName); + std::string tfull = gt->GetFullPath(configName); std::string trel = this->ConvertToRelativeForMake(tfull.c_str()); // Add this target to the post-build phases of its dependencies. diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index 5ef0b4f..0f82fb3 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -546,7 +546,7 @@ cmMakefileTargetGenerator this->Target->GetType() == cmTarget::MODULE_LIBRARY) { targetFullPathReal = - this->Target->GetFullPath(this->ConfigName, false, true); + this->GeneratorTarget->GetFullPath(this->ConfigName, false, true); targetFullPathPDB = this->Target->GetPDBDirectory(this->ConfigName); targetFullPathPDB += "/"; targetFullPathPDB += this->Target->GetPDBName(this->ConfigName); diff --git a/Source/cmNinjaNormalTargetGenerator.cxx b/Source/cmNinjaNormalTargetGenerator.cxx index ea2816b..8ec6f5e 100644 --- a/Source/cmNinjaNormalTargetGenerator.cxx +++ b/Source/cmNinjaNormalTargetGenerator.cxx @@ -398,15 +398,16 @@ static int calculateCommandLineLengthLimit(int linkRuleLength) void cmNinjaNormalTargetGenerator::WriteLinkStatement() { cmTarget& target = *this->GetTarget(); + cmGeneratorTarget& gt = *this->GetGeneratorTarget(); const std::string cfgName = this->GetConfigName(); std::string targetOutput = ConvertToNinjaPath( - target.GetFullPath(cfgName)); + gt.GetFullPath(cfgName)); std::string targetOutputReal = ConvertToNinjaPath( - target.GetFullPath(cfgName, + gt.GetFullPath(cfgName, /*implib=*/false, /*realpath=*/true)); std::string targetOutputImplib = ConvertToNinjaPath( - target.GetFullPath(cfgName, + gt.GetFullPath(cfgName, /*implib=*/true)); if (target.IsAppBundleOnApple()) diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index d880cc0..2d10d29 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2918,7 +2918,7 @@ const char *cmTarget::GetProperty(const std::string& prop, gg->CreateGenerationObjects(); cmGeneratorTarget* gt = gg->GetGeneratorTarget(this); this->Properties.SetProperty( - prop, gt->Target->GetFullPath(configName, false).c_str()); + prop, gt->GetFullPath(configName, false).c_str()); } } // Support "<CONFIG>_LOCATION". @@ -2942,7 +2942,7 @@ const char *cmTarget::GetProperty(const std::string& prop, gg->CreateGenerationObjects(); cmGeneratorTarget* gt = gg->GetGeneratorTarget(this); this->Properties.SetProperty( - prop, gt->Target->GetFullPath(configName, false).c_str()); + prop, gt->GetFullPath(configName, false).c_str()); } } } @@ -3759,44 +3759,6 @@ bool cmTarget::IsImportedSharedLibWithoutSOName( } //---------------------------------------------------------------------------- -std::string cmTarget::NormalGetRealName(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 = "NormalGetRealName called on imported target: "; - msg += this->GetName(); - this->GetMakefile()-> - IssueMessage(cmake::INTERNAL_ERROR, - msg); - } - - if(this->GetType() == cmTarget::EXECUTABLE) - { - // Compute the real name that will be built. - std::string name; - std::string realName; - std::string impName; - std::string pdbName; - this->GetExecutableNames(name, realName, impName, pdbName, config); - return realName; - } - else - { - // Compute the real name 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 realName; - } -} - -//---------------------------------------------------------------------------- std::string cmTarget::GetFullName(const std::string& config, bool implib) const { @@ -3828,48 +3790,6 @@ void cmTarget::GetFullNameComponents(std::string& prefix, std::string& base, } //---------------------------------------------------------------------------- -std::string cmTarget::GetFullPath(const std::string& config, bool implib, - bool realname) const -{ - if(this->IsImported()) - { - return this->ImportedGetFullPath(config, implib); - } - else - { - return this->NormalGetFullPath(config, implib, realname); - } -} - -//---------------------------------------------------------------------------- -std::string cmTarget::NormalGetFullPath(const std::string& config, - bool implib, bool realname) const -{ - std::string fpath = this->GetDirectory(config, implib); - fpath += "/"; - if(this->IsAppBundleOnApple()) - { - fpath = this->BuildMacContentDirectory(fpath, config, false); - fpath += "/"; - } - - // Add the full name of the target. - if(implib) - { - fpath += this->GetFullName(config, true); - } - else if(realname) - { - fpath += this->NormalGetRealName(config); - } - else - { - fpath += this->GetFullName(config, false); - } - return fpath; -} - -//---------------------------------------------------------------------------- std::string cmTarget::ImportedGetFullPath(const std::string& config, bool implib) const { diff --git a/Source/cmTarget.h b/Source/cmTarget.h index eb0bf91..2a26a64 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -424,11 +424,6 @@ public: no soname at all. */ bool IsImportedSharedLibWithoutSOName(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, - bool realname = false) 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. */ @@ -708,14 +703,6 @@ private: std::string ImportedGetFullPath(const std::string& config, bool implib) const; - std::string NormalGetFullPath(const std::string& config, bool implib, - bool realname) const; - - /** Get the real name of the target. Allowed only for non-imported - targets. When a library or executable file is versioned this is - the full versioned name. If the target is not versioned this is - the same as GetFullName. */ - std::string NormalGetRealName(const std::string& config) const; /** Append to @a base the mac content directory and return it. */ std::string BuildMacContentDirectory(const std::string& base, diff --git a/Source/cmTestGenerator.cxx b/Source/cmTestGenerator.cxx index 65d3b6a..1815ade 100644 --- a/Source/cmTestGenerator.cxx +++ b/Source/cmTestGenerator.cxx @@ -82,7 +82,7 @@ void cmTestGenerator::GenerateScriptForConfig(std::ostream& os, // be translated. std::string exe = command[0]; cmMakefile* mf = this->Test->GetMakefile(); - cmTarget* target = mf->FindTargetToUse(exe); + cmGeneratorTarget* target = mf->FindGeneratorTargetToUse(exe); if(target && target->GetType() == cmTarget::EXECUTABLE) { // Use the target file on disk. |