1
0
Эх сурвалжийг харах

cmGeneratorTarget: Make import library checks config-aware

Michael Stürmer 7 жил өмнө
parent
commit
fb433ff283

+ 3 - 2
Source/cmExportBuildFileGenerator.cxx

@@ -224,13 +224,14 @@ void cmExportBuildFileGenerator::SetImportLocationProperty(
     }
     }
 
 
     // Add the import library for windows DLLs.
     // Add the import library for windows DLLs.
-    if (target->HasImportLibrary() &&
+    if (target->HasImportLibrary(config) &&
         mf->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) {
         mf->GetDefinition("CMAKE_IMPORT_LIBRARY_SUFFIX")) {
       std::string prop = "IMPORTED_IMPLIB";
       std::string prop = "IMPORTED_IMPLIB";
       prop += suffix;
       prop += suffix;
       std::string value =
       std::string value =
         target->GetFullPath(config, cmStateEnums::ImportLibraryArtifact);
         target->GetFullPath(config, cmStateEnums::ImportLibraryArtifact);
-      target->GetImplibGNUtoMS(value, value, "${CMAKE_IMPORT_LIBRARY_SUFFIX}");
+      target->GetImplibGNUtoMS(config, value, value,
+                               "${CMAKE_IMPORT_LIBRARY_SUFFIX}");
       properties[prop] = value;
       properties[prop] = value;
     }
     }
   }
   }

+ 2 - 1
Source/cmGeneratorExpressionNode.cxx

@@ -1675,7 +1675,8 @@ struct TargetFilesystemArtifactResultCreator<ArtifactLinkerTag>
                     "executables with ENABLE_EXPORTS.");
                     "executables with ENABLE_EXPORTS.");
       return std::string();
       return std::string();
     }
     }
-    cmStateEnums::ArtifactType artifact = target->HasImportLibrary()
+    cmStateEnums::ArtifactType artifact =
+      target->HasImportLibrary(context->Config)
       ? cmStateEnums::ImportLibraryArtifact
       ? cmStateEnums::ImportLibraryArtifact
       : cmStateEnums::RuntimeBinaryArtifact;
       : cmStateEnums::RuntimeBinaryArtifact;
     return target->GetFullPath(context->Config, artifact);
     return target->GetFullPath(context->Config, artifact);

+ 6 - 5
Source/cmGeneratorTarget.cxx

@@ -5403,16 +5403,17 @@ std::string cmGeneratorTarget::GetPDBDirectory(const std::string& config) const
   return "";
   return "";
 }
 }
 
 
-bool cmGeneratorTarget::HasImplibGNUtoMS() const
+bool cmGeneratorTarget::HasImplibGNUtoMS(std::string const& config) const
 {
 {
-  return this->HasImportLibrary() && this->GetPropertyAsBool("GNUtoMS");
+  return this->HasImportLibrary(config) && this->GetPropertyAsBool("GNUtoMS");
 }
 }
 
 
-bool cmGeneratorTarget::GetImplibGNUtoMS(std::string const& gnuName,
+bool cmGeneratorTarget::GetImplibGNUtoMS(std::string const& config,
+                                         std::string const& gnuName,
                                          std::string& out,
                                          std::string& out,
                                          const char* newExt) const
                                          const char* newExt) const
 {
 {
-  if (this->HasImplibGNUtoMS() && gnuName.size() > 6 &&
+  if (this->HasImplibGNUtoMS(config) && gnuName.size() > 6 &&
       gnuName.substr(gnuName.size() - 6) == ".dll.a") {
       gnuName.substr(gnuName.size() - 6) == ".dll.a") {
     out = gnuName.substr(0, gnuName.size() - 6);
     out = gnuName.substr(0, gnuName.size() - 6);
     out += newExt ? newExt : ".lib";
     out += newExt ? newExt : ".lib";
@@ -5427,7 +5428,7 @@ bool cmGeneratorTarget::IsExecutableWithExports() const
           this->GetPropertyAsBool("ENABLE_EXPORTS"));
           this->GetPropertyAsBool("ENABLE_EXPORTS"));
 }
 }
 
 
-bool cmGeneratorTarget::HasImportLibrary() const
+bool cmGeneratorTarget::HasImportLibrary(std::string const& config) const
 {
 {
   return (this->IsDLLPlatform() &&
   return (this->IsDLLPlatform() &&
           (this->GetType() == cmStateEnums::SHARED_LIBRARY ||
           (this->GetType() == cmStateEnums::SHARED_LIBRARY ||

+ 4 - 4
Source/cmGeneratorTarget.h

@@ -572,17 +572,17 @@ public:
   std::string GetLinkerLanguage(const std::string& config) const;
   std::string GetLinkerLanguage(const std::string& config) const;
 
 
   /** Does this target have a GNU implib to convert to MS format?  */
   /** Does this target have a GNU implib to convert to MS format?  */
-  bool HasImplibGNUtoMS() const;
+  bool HasImplibGNUtoMS(std::string const& config) const;
 
 
   /** Convert the given GNU import library name (.dll.a) to a name with a new
   /** Convert the given GNU import library name (.dll.a) to a name with a new
       extension (.lib or ${CMAKE_IMPORT_LIBRARY_SUFFIX}).  */
       extension (.lib or ${CMAKE_IMPORT_LIBRARY_SUFFIX}).  */
-  bool GetImplibGNUtoMS(std::string const& gnuName, std::string& out,
-                        const char* newExt = nullptr) const;
+  bool GetImplibGNUtoMS(std::string const& config, std::string const& gnuName,
+                        std::string& out, const char* newExt = nullptr) const;
 
 
   bool IsExecutableWithExports() const;
   bool IsExecutableWithExports() const;
 
 
   /** Return whether or not the target has a DLL import library.  */
   /** Return whether or not the target has a DLL import library.  */
-  bool HasImportLibrary() const;
+  bool HasImportLibrary(std::string const& config) const;
 
 
   /** Get a build-tree directory in which to place target support files.  */
   /** Get a build-tree directory in which to place target support files.  */
   std::string GetSupportDirectory() const;
   std::string GetSupportDirectory() const;

+ 4 - 4
Source/cmInstallTargetGenerator.cxx

@@ -135,7 +135,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(
       filesFrom.push_back(std::move(from1));
       filesFrom.push_back(std::move(from1));
       filesTo.push_back(std::move(to1));
       filesTo.push_back(std::move(to1));
       std::string targetNameImportLib;
       std::string targetNameImportLib;
-      if (this->Target->GetImplibGNUtoMS(targetNameImport,
+      if (this->Target->GetImplibGNUtoMS(config, targetNameImport,
                                          targetNameImportLib)) {
                                          targetNameImportLib)) {
         filesFrom.push_back(fromDirConfig + targetNameImportLib);
         filesFrom.push_back(fromDirConfig + targetNameImportLib);
         filesTo.push_back(toDir + targetNameImportLib);
         filesTo.push_back(toDir + targetNameImportLib);
@@ -201,7 +201,7 @@ void cmInstallTargetGenerator::GenerateScriptForConfig(
       filesFrom.push_back(std::move(from1));
       filesFrom.push_back(std::move(from1));
       filesTo.push_back(std::move(to1));
       filesTo.push_back(std::move(to1));
       std::string targetNameImportLib;
       std::string targetNameImportLib;
-      if (this->Target->GetImplibGNUtoMS(targetNameImport,
+      if (this->Target->GetImplibGNUtoMS(config, targetNameImport,
                                          targetNameImportLib)) {
                                          targetNameImportLib)) {
         filesFrom.push_back(fromDirConfig + targetNameImportLib);
         filesFrom.push_back(fromDirConfig + targetNameImportLib);
         filesTo.push_back(toDir + targetNameImportLib);
         filesTo.push_back(toDir + targetNameImportLib);
@@ -398,7 +398,7 @@ std::string cmInstallTargetGenerator::GetInstallFilename(
                                targetNamePDB, config);
                                targetNamePDB, config);
     if (nameType == NameImplib) {
     if (nameType == NameImplib) {
       // Use the import library name.
       // Use the import library name.
-      if (!target->GetImplibGNUtoMS(targetNameImport, fname,
+      if (!target->GetImplibGNUtoMS(config, targetNameImport, fname,
                                     "${CMAKE_IMPORT_LIBRARY_SUFFIX}")) {
                                     "${CMAKE_IMPORT_LIBRARY_SUFFIX}")) {
         fname = targetNameImport;
         fname = targetNameImport;
       }
       }
@@ -419,7 +419,7 @@ std::string cmInstallTargetGenerator::GetInstallFilename(
                             targetNameImport, targetNamePDB, config);
                             targetNameImport, targetNamePDB, config);
     if (nameType == NameImplib) {
     if (nameType == NameImplib) {
       // Use the import library name.
       // Use the import library name.
-      if (!target->GetImplibGNUtoMS(targetNameImport, fname,
+      if (!target->GetImplibGNUtoMS(config, targetNameImport, fname,
                                     "${CMAKE_IMPORT_LIBRARY_SUFFIX}")) {
                                     "${CMAKE_IMPORT_LIBRARY_SUFFIX}")) {
         fname = targetNameImport;
         fname = targetNameImport;
       }
       }

+ 2 - 2
Source/cmMakefileExecutableTargetGenerator.cxx

@@ -477,8 +477,8 @@ void cmMakefileExecutableTargetGenerator::WriteExecutableRule(bool relink)
       this->LocalGenerator->GetCurrentBinaryDirectory(),
       this->LocalGenerator->GetCurrentBinaryDirectory(),
       targetFullPathImport));
       targetFullPathImport));
     std::string implib;
     std::string implib;
-    if (this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport,
-                                                implib)) {
+    if (this->GeneratorTarget->GetImplibGNUtoMS(
+          this->ConfigName, targetFullPathImport, implib)) {
       exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
       exeCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
         this->LocalGenerator->GetCurrentBinaryDirectory(), implib));
         this->LocalGenerator->GetCurrentBinaryDirectory(), implib));
     }
     }

+ 2 - 2
Source/cmMakefileLibraryTargetGenerator.cxx

@@ -641,8 +641,8 @@ void cmMakefileLibraryTargetGenerator::WriteLibraryRules(
       this->LocalGenerator->GetCurrentBinaryDirectory(),
       this->LocalGenerator->GetCurrentBinaryDirectory(),
       targetFullPathImport));
       targetFullPathImport));
     std::string implib;
     std::string implib;
-    if (this->GeneratorTarget->GetImplibGNUtoMS(targetFullPathImport,
-                                                implib)) {
+    if (this->GeneratorTarget->GetImplibGNUtoMS(
+          this->ConfigName, targetFullPathImport, implib)) {
       libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
       libCleanFiles.push_back(this->LocalGenerator->MaybeConvertToRelativePath(
         this->LocalGenerator->GetCurrentBinaryDirectory(), implib));
         this->LocalGenerator->GetCurrentBinaryDirectory(), implib));
     }
     }

+ 1 - 1
Source/cmMakefileTargetGenerator.cxx

@@ -1402,7 +1402,7 @@ std::string cmMakefileTargetGenerator::GetLinkRule(
   const std::string& linkRuleVar)
   const std::string& linkRuleVar)
 {
 {
   std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar);
   std::string linkRule = this->Makefile->GetRequiredDefinition(linkRuleVar);
-  if (this->GeneratorTarget->HasImplibGNUtoMS()) {
+  if (this->GeneratorTarget->HasImplibGNUtoMS(this->ConfigName)) {
     std::string ruleVar = "CMAKE_";
     std::string ruleVar = "CMAKE_";
     ruleVar += this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
     ruleVar += this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
     ruleVar += "_GNUtoMS_RULE";
     ruleVar += "_GNUtoMS_RULE";

+ 2 - 2
Source/cmNinjaNormalTargetGenerator.cxx

@@ -482,7 +482,7 @@ std::vector<std::string> cmNinjaNormalTargetGenerator::ComputeLinkCmd()
     const char* linkCmd = mf->GetDefinition(linkCmdVar);
     const char* linkCmd = mf->GetDefinition(linkCmdVar);
     if (linkCmd) {
     if (linkCmd) {
       std::string linkCmdStr = linkCmd;
       std::string linkCmdStr = linkCmd;
-      if (this->GetGeneratorTarget()->HasImplibGNUtoMS()) {
+      if (this->GetGeneratorTarget()->HasImplibGNUtoMS(this->ConfigName)) {
         std::string ruleVar = "CMAKE_";
         std::string ruleVar = "CMAKE_";
         ruleVar += this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
         ruleVar += this->GeneratorTarget->GetLinkerLanguage(this->ConfigName);
         ruleVar += "_GNUtoMS_RULE";
         ruleVar += "_GNUtoMS_RULE";
@@ -881,7 +881,7 @@ void cmNinjaNormalTargetGenerator::WriteLinkStatement()
       targetOutputImplib, cmOutputConverter::SHELL);
       targetOutputImplib, cmOutputConverter::SHELL);
     vars["TARGET_IMPLIB"] = impLibPath;
     vars["TARGET_IMPLIB"] = impLibPath;
     EnsureParentDirectoryExists(impLibPath);
     EnsureParentDirectoryExists(impLibPath);
-    if (genTarget.HasImportLibrary()) {
+    if (genTarget.HasImportLibrary(cfgName)) {
       byproducts.push_back(targetOutputImplib);
       byproducts.push_back(targetOutputImplib);
     }
     }
   }
   }