From 8d2e3e53b903b1ee38292b6bcdf3e4eeb5399a05 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Fri, 9 Oct 2015 23:50:36 +0200 Subject: [PATCH] cmGeneratorTarget: Move HasImplibGNUtoMS from cmTarget. --- Source/cmExportBuildFileGenerator.cxx | 2 +- Source/cmGeneratorTarget.cxx | 21 +++++++++++++++++++ Source/cmGeneratorTarget.h | 8 +++++++ Source/cmInstallTargetGenerator.cxx | 8 +++---- .../cmMakefileExecutableTargetGenerator.cxx | 2 +- Source/cmMakefileLibraryTargetGenerator.cxx | 2 +- Source/cmMakefileTargetGenerator.cxx | 2 +- Source/cmTarget.cxx | 20 ------------------ Source/cmTarget.h | 8 ------- 9 files changed, 37 insertions(+), 36 deletions(-) diff --git a/Source/cmExportBuildFileGenerator.cxx b/Source/cmExportBuildFileGenerator.cxx index fed0dbc90..400fa170e 100644 --- a/Source/cmExportBuildFileGenerator.cxx +++ b/Source/cmExportBuildFileGenerator.cxx @@ -217,7 +217,7 @@ cmExportBuildFileGenerator std::string prop = "IMPORTED_IMPLIB"; prop += suffix; std::string value = target->GetFullPath(config, true); - target->Target->GetImplibGNUtoMS(value, value, + target->GetImplibGNUtoMS(value, value, "${CMAKE_IMPORT_LIBRARY_SUFFIX}"); properties[prop] = value; } diff --git a/Source/cmGeneratorTarget.cxx b/Source/cmGeneratorTarget.cxx index c24126fc2..90acca66f 100644 --- a/Source/cmGeneratorTarget.cxx +++ b/Source/cmGeneratorTarget.cxx @@ -5483,3 +5483,24 @@ cmGeneratorTarget::GetPDBDirectory(const std::string& config) const } return ""; } + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::HasImplibGNUtoMS() const +{ + return this->Target->HasImportLibrary() + && this->GetPropertyAsBool("GNUtoMS"); +} + +//---------------------------------------------------------------------------- +bool cmGeneratorTarget::GetImplibGNUtoMS(std::string const& gnuName, + std::string& out, const char* newExt) const +{ + if(this->HasImplibGNUtoMS() && + gnuName.size() > 6 && gnuName.substr(gnuName.size()-6) == ".dll.a") + { + out = gnuName.substr(0, gnuName.size()-6); + out += newExt? newExt : ".lib"; + return true; + } + return false; +} diff --git a/Source/cmGeneratorTarget.h b/Source/cmGeneratorTarget.h index b3519de19..e2be24961 100644 --- a/Source/cmGeneratorTarget.h +++ b/Source/cmGeneratorTarget.h @@ -390,6 +390,14 @@ public: ///! Return the preferred linker language for this target std::string GetLinkerLanguage(const std::string& config = "") const; + /** Does this target have a GNU implib to convert to MS format? */ + bool HasImplibGNUtoMS() const; + + /** Convert the given GNU import library name (.dll.a) to a name with a new + extension (.lib or ${CMAKE_IMPORT_LIBRARY_SUFFIX}). */ + bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, + const char* newExt = 0) const; + struct SourceFileFlags GetTargetSourceFileFlags(const cmSourceFile* sf) const; diff --git a/Source/cmInstallTargetGenerator.cxx b/Source/cmInstallTargetGenerator.cxx index b3bc95a26..c2a18af64 100644 --- a/Source/cmInstallTargetGenerator.cxx +++ b/Source/cmInstallTargetGenerator.cxx @@ -135,7 +135,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, filesFrom.push_back(from1); filesTo.push_back(to1); std::string targetNameImportLib; - if(this->Target->Target->GetImplibGNUtoMS(targetNameImport, + if(this->Target->GetImplibGNUtoMS(targetNameImport, targetNameImportLib)) { filesFrom.push_back(fromDirConfig + targetNameImportLib); @@ -199,7 +199,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(std::ostream& os, filesFrom.push_back(from1); filesTo.push_back(to1); std::string targetNameImportLib; - if(this->Target->Target->GetImplibGNUtoMS(targetNameImport, + if(this->Target->GetImplibGNUtoMS(targetNameImport, targetNameImportLib)) { filesFrom.push_back(fromDirConfig + targetNameImportLib); @@ -387,7 +387,7 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, if(nameType == NameImplib) { // Use the import library name. - if(!target->GetImplibGNUtoMS(targetNameImport, fname, + if(!gtgt->GetImplibGNUtoMS(targetNameImport, fname, "${CMAKE_IMPORT_LIBRARY_SUFFIX}")) { fname = targetNameImport; @@ -416,7 +416,7 @@ cmInstallTargetGenerator::GetInstallFilename(cmTarget const* target, if(nameType == NameImplib) { // Use the import library name. - if(!target->GetImplibGNUtoMS(targetNameImport, fname, + if(!gtgt->GetImplibGNUtoMS(targetNameImport, fname, "${CMAKE_IMPORT_LIBRARY_SUFFIX}")) { fname = targetNameImport; diff --git a/Source/cmMakefileExecutableTargetGenerator.cxx b/Source/cmMakefileExecutableTargetGenerator.cxx index f6b907e24..de84f8978 100644 --- a/Source/cmMakefileExecutableTargetGenerator.cxx +++ b/Source/cmMakefileExecutableTargetGenerator.cxx @@ -259,7 +259,7 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink) cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); std::string implib; - if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib)) + if(this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport, implib)) { exeCleanFiles.push_back(this->Convert(implib, cmLocalGenerator::START_OUTPUT, diff --git a/Source/cmMakefileLibraryTargetGenerator.cxx b/Source/cmMakefileLibraryTargetGenerator.cxx index 3b3f63e2d..2b019beb1 100644 --- a/Source/cmMakefileLibraryTargetGenerator.cxx +++ b/Source/cmMakefileLibraryTargetGenerator.cxx @@ -410,7 +410,7 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules cmLocalGenerator::START_OUTPUT, cmLocalGenerator::UNCHANGED)); std::string implib; - if(this->Target->GetImplibGNUtoMS(targetFullPathImport, implib)) + if(this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport, implib)) { libCleanFiles.push_back(this->Convert(implib, cmLocalGenerator::START_OUTPUT, diff --git a/Source/cmMakefileTargetGenerator.cxx b/Source/cmMakefileTargetGenerator.cxx index f17f66db6..5f9367df7 100644 --- a/Source/cmMakefileTargetGenerator.cxx +++ b/Source/cmMakefileTargetGenerator.cxx @@ -1517,7 +1517,7 @@ std::string cmMakefileTargetGenerator::GetLinkRule( const std::string& linkRuleVar) { std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar); - if(this->Target->HasImplibGNUtoMS()) + if(this->GeneratorTarget->HasImplibGNUtoMS()) { std::string ruleVar = "CMAKE_"; ruleVar += this->GeneratorTarget->GetLinkerLanguage(this->ConfigName); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index bebdd7789..b16bc3044 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -2198,26 +2198,6 @@ void cmTarget::ComputeVersionedName(std::string& vName, vName += this->IsApple? suffix : std::string(); } -//---------------------------------------------------------------------------- -bool cmTarget::HasImplibGNUtoMS() const -{ - return this->HasImportLibrary() && this->GetPropertyAsBool("GNUtoMS"); -} - -//---------------------------------------------------------------------------- -bool cmTarget::GetImplibGNUtoMS(std::string const& gnuName, - std::string& out, const char* newExt) const -{ - if(this->HasImplibGNUtoMS() && - gnuName.size() > 6 && gnuName.substr(gnuName.size()-6) == ".dll.a") - { - out = gnuName.substr(0, gnuName.size()-6); - out += newExt? newExt : ".lib"; - return true; - } - return false; -} - //---------------------------------------------------------------------------- void cmTarget::SetPropertyDefault(const std::string& property, const char* default_value) diff --git a/Source/cmTarget.h b/Source/cmTarget.h index 3bb1ccd44..500b598a1 100644 --- a/Source/cmTarget.h +++ b/Source/cmTarget.h @@ -240,14 +240,6 @@ public: void GetTargetVersion(bool soversion, int& major, int& minor, int& patch) const; - /** Does this target have a GNU implib to convert to MS format? */ - bool HasImplibGNUtoMS() const; - - /** Convert the given GNU import library name (.dll.a) to a name with a new - extension (.lib or ${CMAKE_IMPORT_LIBRARY_SUFFIX}). */ - bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out, - const char* newExt = 0) const; - // Get the properties cmPropertyMap &GetProperties() const { return this->Properties; }