diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index 6a693f1d8..31c2df1cf 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,12 +1378,99 @@ 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, @@ -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 49aa65b6b..7fb7c3282 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 c87285922..deabecfb6 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 daac33130..dd4cd33f8 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 696dcc4f5..26273eecf 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 737510f45..5d86091c1 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 22b76e998..60fe7e49c 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -3861,95 +3861,6 @@ void cmTarget::GetFullNameInternal(const std::string& config, outSuffix = targetSuffix?targetSuffix:""; } -//---------------------------------------------------------------------------- -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, diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 714647cae..15dfb4a00 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 1bb21ffe6..83775a5ad 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()); }