[cmake-commits] king committed cmInstallCommand.cxx 1.19 1.20 cmInstallTargetGenerator.cxx 1.27 1.28 cmLocalUnixMakefileGenerator3.cxx 1.203 1.204 cmLocalVisualStudio6Generator.cxx 1.118 1.119 cmLocalVisualStudio7Generator.cxx 1.183 1.184 cmMakefileExecutableTargetGenerator.cxx 1.30 1.31 cmMakefileLibraryTargetGenerator.cxx 1.38 1.39 cmTarget.cxx 1.130 1.131 cmTarget.h 1.78 1.79

cmake-commits at cmake.org cmake-commits at cmake.org
Mon Mar 19 09:00:37 EST 2007


Update of /cvsroot/CMake/CMake/Source
In directory public:/mounts/ram/cvs-serv24557/Source

Modified Files:
	cmInstallCommand.cxx cmInstallTargetGenerator.cxx 
	cmLocalUnixMakefileGenerator3.cxx 
	cmLocalVisualStudio6Generator.cxx 
	cmLocalVisualStudio7Generator.cxx 
	cmMakefileExecutableTargetGenerator.cxx 
	cmMakefileLibraryTargetGenerator.cxx cmTarget.cxx cmTarget.h 
Log Message:
ENH: Added support for import libraries created by executable and module targets.  The module import libraries should never be used but some windows compilers always create them for .dll files since there is no distinction from shared libraries on that platform.  The executable import libraries may be used to create modules that when loaded bind to symbols from the executables.  This is an enhancement related to bug#4210 though not requested by it explicitly.


Index: cmLocalVisualStudio7Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio7Generator.cxx,v
retrieving revision 1.183
retrieving revision 1.184
diff -u -d -r1.183 -r1.184
--- cmLocalVisualStudio7Generator.cxx	16 Mar 2007 14:34:25 -0000	1.183
+++ cmLocalVisualStudio7Generator.cxx	19 Mar 2007 14:00:35 -0000	1.184
@@ -733,17 +733,6 @@
     target.GetLibraryNames(targetName, targetNameSO, targetNameFull,
                            targetNameImport, targetNamePDB, configName);
 
-    // VS does not distinguish between shared libraries and module
-    // libraries so it still wants to be given the name of an import
-    // library for modules.
-    if(targetNameImport.empty() &&
-       target.GetType() == cmTarget::MODULE_LIBRARY)
-      {
-      targetNameImport =
-        cmSystemTools::GetFilenameWithoutLastExtension(targetNameFull);
-      targetNameImport += ".lib";
-      }
-
     // Compute the link library and directory information.
     std::vector<cmStdString> linkLibs;
     std::vector<cmStdString> linkDirs;
@@ -816,9 +805,10 @@
     {
     std::string targetName;
     std::string targetNameFull;
+    std::string targetNameImport;
     std::string targetNamePDB;
     target.GetExecutableNames(targetName, targetNameFull,
-                              targetNamePDB, configName);
+                              targetNameImport, targetNamePDB, configName);
 
     // Compute the link library and directory information.
     std::vector<cmStdString> linkLibs;
@@ -886,7 +876,11 @@
       {
       fout << "\t\t\t\tStackReserveSize=\"" << stackVal << "\"";
       }
-    fout << "/>\n";
+    temp = target.GetDirectory(configName, true);
+    temp += "/";
+    temp += targetNameImport;
+    fout << "\t\t\t\tImportLibrary=\""
+         << this->ConvertToXMLOutputPathSingle(temp.c_str()) << "\"/>\n";
     break;
     }
     case cmTarget::UTILITY:

Index: cmLocalVisualStudio6Generator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalVisualStudio6Generator.cxx,v
retrieving revision 1.118
retrieving revision 1.119
diff -u -d -r1.118 -r1.119
--- cmLocalVisualStudio6Generator.cxx	16 Mar 2007 14:34:25 -0000	1.118
+++ cmLocalVisualStudio6Generator.cxx	19 Mar 2007 14:00:35 -0000	1.119
@@ -1221,7 +1221,9 @@
   std::string targetImplibFlagRelease;
   std::string targetImplibFlagMinSizeRel;
   std::string targetImplibFlagRelWithDebInfo;
-  if(target.GetType() == cmTarget::SHARED_LIBRARY)
+  if(target.GetType() == cmTarget::SHARED_LIBRARY ||
+     target.GetType() == cmTarget::MODULE_LIBRARY ||
+     target.GetType() == cmTarget::EXECUTABLE)
     {
     std::string fullPathImpDebug = target.GetDirectory("Debug", true);
     std::string fullPathImpRelease = target.GetDirectory("Release", true);

Index: cmMakefileLibraryTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileLibraryTargetGenerator.cxx,v
retrieving revision 1.38
retrieving revision 1.39
diff -u -d -r1.38 -r1.39
--- cmMakefileLibraryTargetGenerator.cxx	9 Mar 2007 18:56:45 -0000	1.38
+++ cmMakefileLibraryTargetGenerator.cxx	19 Mar 2007 14:00:35 -0000	1.39
@@ -341,10 +341,7 @@
           cmLocalGenerator::START_OUTPUT,
           cmLocalGenerator::UNCHANGED));
       }
-    if(!targetNameImport.empty() &&
-       targetNameImport != targetName &&
-       targetNameImport != targetNameReal &&
-       targetNameImport != targetNameSO)
+    if(!targetNameImport.empty())
       {
       libCleanFiles.push_back(this->Convert(targetFullPathImport.c_str(),
           cmLocalGenerator::START_OUTPUT,
@@ -401,11 +398,7 @@
           cmLocalGenerator::START_OUTPUT,
           cmLocalGenerator::UNCHANGED));
       }
-    if(!cleanImportName.empty() &&
-      cleanImportName != cleanStaticName &&
-      cleanImportName != cleanSharedSOName &&
-      cleanImportName != cleanSharedRealName &&
-      cleanImportName != cleanSharedName)
+    if(!cleanImportName.empty())
       {
       libCleanFiles.push_back(this->Convert(cleanFullImportName.c_str(),
           cmLocalGenerator::START_OUTPUT,

Index: cmInstallCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmInstallCommand.cxx,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- cmInstallCommand.cxx	5 Oct 2006 15:31:56 -0000	1.19
+++ cmInstallCommand.cxx	19 Mar 2007 14:00:35 -0000	1.20
@@ -532,6 +532,20 @@
           this->SetError(e.str().c_str());
           return false;
           }
+
+        // On DLL platforms an executable may also have an import
+        // library.  Install it to the archive destination if it
+        // exists.
+        if(dll_platform && archive_destination)
+          {
+          // The import library uses the ARCHIVE properties.
+          this->Makefile->AddInstallGenerator(
+            new cmInstallTargetGenerator(target, archive_dest.c_str(), true,
+                                         archive_permissions.c_str(),
+                                         archive_configurations,
+                                         archive_component.c_str(),
+                                         true));
+          }
         }
         break;
       default:

Index: cmTarget.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.h,v
retrieving revision 1.78
retrieving revision 1.79
diff -u -d -r1.78 -r1.79
--- cmTarget.h	12 Mar 2007 14:26:59 -0000	1.78
+++ cmTarget.h	19 Mar 2007 14:00:35 -0000	1.79
@@ -228,6 +228,7 @@
       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 char* config);
 
   /** Get the names of the executable used to remove existing copies
@@ -235,6 +236,7 @@
       during a clean step.  This should be called only on an
       executable target.  */
   void GetExecutableCleanNames(std::string& name, std::string& realName,
+                               std::string& impName,
                                std::string& pdbName, const char* config);
 
   /**
@@ -323,6 +325,7 @@
                                const char* config);
   void GetExecutableNamesInternal(std::string& name,
                                   std::string& realName,
+                                  std::string& impName,
                                   std::string& pdbName,
                                   TargetType type,
                                   const char* config);
@@ -360,6 +363,7 @@
   bool RecordDependencies; 
   cmPropertyMap Properties;
   LinkLibraryVectorType OriginalLinkLibraries;
+  bool DLLPlatform;
 
   // The cmMakefile instance that owns this target.  This should
   // always be set.

Index: cmMakefileExecutableTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmMakefileExecutableTargetGenerator.cxx,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- cmMakefileExecutableTargetGenerator.cxx	9 Mar 2007 19:50:11 -0000	1.30
+++ cmMakefileExecutableTargetGenerator.cxx	19 Mar 2007 14:00:35 -0000	1.31
@@ -110,9 +110,10 @@
   // Get the name of the executable to generate.
   std::string targetName;
   std::string targetNameReal;
+  std::string targetNameImport;
   std::string targetNamePDB;
   this->Target->GetExecutableNames
-    (targetName, targetNameReal, targetNamePDB,
+    (targetName, targetNameReal, targetNameImport, targetNamePDB,
      this->LocalGenerator->ConfigurationName.c_str());
 
   // Construct the full path version of the names.
@@ -167,6 +168,7 @@
                                   false, false, false);
     }
 #endif
+  std::string outpathImp;
   if(relink)
     {
     outpath = this->Makefile->GetStartOutputDirectory();
@@ -174,10 +176,23 @@
     outpath += "/CMakeRelink.dir";
     cmSystemTools::MakeDirectory(outpath.c_str());
     outpath += "/";
+    if(!targetNameImport.empty())
+      {
+      outpathImp = outpath;
+      }
+    }
+  else
+    {
+    if(!targetNameImport.empty())
+      {
+      outpathImp = this->Target->GetDirectory(0, true);
+      outpathImp += "/";
+      }
     }
   std::string targetFullPath = outpath + targetName;
   std::string targetFullPathReal = outpath + targetNameReal;
   std::string targetFullPathPDB = outpath + targetNamePDB;
+  std::string targetFullPathImport = outpathImp + targetNameImport;
   std::string targetOutPathPDB = 
     this->Convert(targetFullPathPDB.c_str(),
                   cmLocalGenerator::FULL,
@@ -191,7 +206,11 @@
     this->Convert(targetFullPathReal.c_str(),
                   cmLocalGenerator::START_OUTPUT,
                   cmLocalGenerator::SHELL);
-  
+  std::string targetOutPathImport =
+    this->Convert(targetFullPathImport.c_str(),
+                  cmLocalGenerator::START_OUTPUT,
+                  cmLocalGenerator::SHELL);
+
   // Get the language to use for linking this executable.
   const char* linkLanguage =
     this->Target->GetLinkerLanguage(this->GlobalGenerator);
@@ -258,14 +277,16 @@
   {
   std::string cleanName;
   std::string cleanRealName;
+  std::string cleanImportName;
   std::string cleanPDBName;
   this->Target->GetExecutableCleanNames
-    (cleanName, cleanRealName, cleanPDBName,
+    (cleanName, cleanRealName, cleanImportName, cleanPDBName,
      this->LocalGenerator->ConfigurationName.c_str());
 
   std::string cleanFullName = outpath + cleanName;
   std::string cleanFullRealName = outpath + cleanRealName;
   std::string cleanFullPDBName = outpath + cleanPDBName;
+  std::string cleanFullImportName = outpathImp + cleanImportName;
   exeCleanFiles.push_back(this->Convert(cleanFullName.c_str(),
                                         cmLocalGenerator::START_OUTPUT,
                                         cmLocalGenerator::UNCHANGED));
@@ -282,6 +303,12 @@
                                           cmLocalGenerator::START_OUTPUT,
                                           cmLocalGenerator::UNCHANGED));
     }
+  if(!cleanImportName.empty())
+    {
+    exeCleanFiles.push_back(this->Convert(cleanFullImportName.c_str(),
+                                          cmLocalGenerator::START_OUTPUT,
+                                          cmLocalGenerator::UNCHANGED));
+    }
 
   // List the PDB for cleaning only when the whole target is
   // cleaned.  We do not want to delete the .pdb file just before
@@ -394,11 +421,13 @@
   vars.Flags = flags.c_str();
   vars.LinkFlags = linkFlags.c_str();
   // Expand placeholders in the commands.
+  this->LocalGenerator->TargetImplib = targetOutPathImport;
   for(std::vector<std::string>::iterator i = commands.begin();
       i != commands.end(); ++i)
     {
     this->LocalGenerator->ExpandRuleVariables(*i, vars);
     }
+  this->LocalGenerator->TargetImplib = "";
 
   // Write the build rule.
   this->LocalGenerator->WriteMakeRule(*this->BuildFileStream,

Index: cmLocalUnixMakefileGenerator3.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalUnixMakefileGenerator3.cxx,v
retrieving revision 1.203
retrieving revision 1.204
diff -u -d -r1.203 -r1.204
--- cmLocalUnixMakefileGenerator3.cxx	16 Mar 2007 20:48:27 -0000	1.203
+++ cmLocalUnixMakefileGenerator3.cxx	19 Mar 2007 14:00:35 -0000	1.204
@@ -1645,8 +1645,9 @@
     objectName = cmSystemTools::GetFilenameName(objectName.c_str());
     std::string targetName;
     std::string targetNameReal;
+    std::string targetNameImport;
     std::string targetNamePDB;
-    target.GetExecutableNames(targetName, targetNameReal,
+    target.GetExecutableNames(targetName, targetNameReal, targetNameImport,
                               targetNamePDB, this->ConfigurationName.c_str());
     std::string obj;
     if ( target.GetPropertyAsBool("MACOSX_BUNDLE") )

Index: cmInstallTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmInstallTargetGenerator.cxx,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- cmInstallTargetGenerator.cxx	16 Mar 2007 20:28:30 -0000	1.27
+++ cmInstallTargetGenerator.cxx	19 Mar 2007 14:00:35 -0000	1.28
@@ -208,11 +208,21 @@
       {
       std::string targetName;
       std::string targetNameReal;
+      std::string targetNameImport;
       std::string targetNamePDB;
       target->GetExecutableNames(targetName, targetNameReal,
-                                 targetNamePDB, i->c_str());
-      // Use the canonical name.
-      fname += targetName;
+                                 targetNameImport, targetNamePDB,
+                                 i->c_str());
+      if(this->ImportLibrary)
+        {
+        // Use the import library name.
+        fname += targetNameImport;
+        }
+      else
+        {
+        // Use the canonical name.
+        fname += targetName;
+        }
       }
     else
       {
@@ -259,11 +269,21 @@
       {
       std::string targetName;
       std::string targetNameReal;
+      std::string targetNameImport;
       std::string targetNamePDB;
       target->GetExecutableNames(targetName, targetNameReal,
-                                 targetNamePDB, this->ConfigurationName);
-      // Use the canonical name.
-      return targetName;
+                                 targetNameImport, targetNamePDB,
+                                 this->ConfigurationName);
+      if(this->ImportLibrary)
+        {
+        // Use the import library name.
+        return targetNameImport;
+        }
+      else
+        {
+        // Use the canonical name.
+        return targetName;
+        }
       }
     else
       {

Index: cmTarget.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmTarget.cxx,v
retrieving revision 1.130
retrieving revision 1.131
diff -u -d -r1.130 -r1.131
--- cmTarget.cxx	13 Mar 2007 18:23:08 -0000	1.130
+++ cmTarget.cxx	19 Mar 2007 14:00:35 -0000	1.131
@@ -37,6 +37,7 @@
   this->LinkLibrariesAnalyzed = false;
   this->LinkDirectoriesComputed = false;
   this->HaveInstallRule = false;
+  this->DLLPlatform = false;
 
 }
 
@@ -335,6 +336,11 @@
   // set the cmake instance of the properties
   this->Properties.SetCMakeInstance(mf->GetCMakeInstance());
 
+  // Check whether this is a DLL platform.
+  this->DLLPlatform = (this->Makefile->IsOn("WIN32") ||
+                       this->Makefile->IsOn("CYGWIN") ||
+                       this->Makefile->IsOn("MINGW"));
+
   // Setup default property values.
   this->SetPropertyDefault("INSTALL_NAME_DIR", "");
   this->SetPropertyDefault("INSTALL_RPATH", "");
@@ -1427,9 +1433,13 @@
               ? "CMAKE_IMPORT_LIBRARY_SUFFIX"
               : "CMAKE_SHARED_LIBRARY_SUFFIX");
     case cmTarget::MODULE_LIBRARY:
-      return "CMAKE_SHARED_MODULE_SUFFIX";
+      return (implib
+              ? "CMAKE_IMPORT_LIBRARY_SUFFIX"
+              : "CMAKE_SHARED_MODULE_SUFFIX");
     case cmTarget::EXECUTABLE:
-      return "CMAKE_EXECUTABLE_SUFFIX";
+      return (implib
+              ? "CMAKE_IMPORT_LIBRARY_SUFFIX"
+              : "CMAKE_EXECUTABLE_SUFFIX");
     case cmTarget::UTILITY:
     case cmTarget::GLOBAL_TARGET:
     case cmTarget::INSTALL_FILES:
@@ -1453,8 +1463,11 @@
               ? "CMAKE_IMPORT_LIBRARY_PREFIX"
               : "CMAKE_SHARED_LIBRARY_PREFIX");
     case cmTarget::MODULE_LIBRARY:
-      return "CMAKE_SHARED_MODULE_PREFIX";
+      return (implib
+              ? "CMAKE_IMPORT_LIBRARY_PREFIX"
+              : "CMAKE_SHARED_MODULE_PREFIX");
     case cmTarget::EXECUTABLE:
+      return (implib? "CMAKE_IMPORT_LIBRARY_PREFIX" : "");
     case cmTarget::UTILITY:
     case cmTarget::GLOBAL_TARGET:
     case cmTarget::INSTALL_FILES:
@@ -1545,8 +1558,11 @@
     return;
     }
 
-  // The implib option is only allowed for shared libraries.
-  if(type != cmTarget::SHARED_LIBRARY)
+  // The implib option is only allowed for shared libraries, module
+  // libraries, and executables.
+  if(type != cmTarget::SHARED_LIBRARY &&
+     type != cmTarget::MODULE_LIBRARY &&
+     type != cmTarget::EXECUTABLE)
     {
     implib = false;
     }
@@ -1769,7 +1785,8 @@
 #endif
 
   // The import library name.
-  if(type == cmTarget::SHARED_LIBRARY)
+  if(type == cmTarget::SHARED_LIBRARY ||
+     type == cmTarget::MODULE_LIBRARY)
     {
     impName = this->GetFullNameInternal(type, config, true);
     }
@@ -1784,26 +1801,29 @@
 
 void cmTarget::GetExecutableNames(std::string& name,
                                   std::string& realName,
+                                  std::string& impName,
                                   std::string& pdbName,
                                   const char* config)
 {
   // Get the names based on the real type of the executable.
-  this->GetExecutableNamesInternal(name, realName, pdbName,
+  this->GetExecutableNamesInternal(name, realName, impName, pdbName,
                                    this->GetType(), config);
 }
 
 void cmTarget::GetExecutableCleanNames(std::string& name,
                                        std::string& realName,
+                                       std::string& impName,
                                        std::string& pdbName,
                                        const char* config)
 {
   // Get the name and versioned name of this executable.
-  this->GetExecutableNamesInternal(name, realName, pdbName,
+  this->GetExecutableNamesInternal(name, realName, impName, pdbName,
                                    cmTarget::EXECUTABLE, config);
 }
 
 void cmTarget::GetExecutableNamesInternal(std::string& name,
                                           std::string& realName,
+                                          std::string& impName,
                                           std::string& pdbName,
                                           TargetType type,
                                           const char* config)
@@ -1845,6 +1865,9 @@
   realName += suffix;
 #endif
 
+  // The import library name.
+  impName = this->GetFullNameInternal(type, config, true);
+
   // The program database file name.
   pdbName = prefix+base+".pdb";
 }
@@ -1986,8 +2009,11 @@
 //----------------------------------------------------------------------------
 const char* cmTarget::GetOutputDir(bool implib)
 {
-  // The implib option is only allowed for shared libraries.
-  if(this->GetType() != cmTarget::SHARED_LIBRARY)
+  // 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;
     }
@@ -2000,6 +2026,10 @@
     {
     abort();
     }
+  if(implib && !this->DLLPlatform)
+    {
+    abort();
+    }
 
   // Select whether we are constructing the directory for the main
   // target or the import library.
@@ -2019,12 +2049,7 @@
         // shared library is treated as a runtime target and the
         // corresponding import library is treated as an archive
         // target.
-
-        // Check whether this is a DLL platform.
-        bool dll_platform = (this->Makefile->IsOn("WIN32") ||
-                             this->Makefile->IsOn("CYGWIN") ||
-                             this->Makefile->IsOn("MINGW"));
-        if(dll_platform)
+        if(this->DLLPlatform)
           {
           if(implib)
             {
@@ -2048,12 +2073,28 @@
       case cmTarget::MODULE_LIBRARY:
         {
         // Module libraries are always treated as library targets.
-        propertyName = "LIBRARY_OUTPUT_DIRECTORY";
+        // Module import libraries are treated as archive targets.
+        if(implib)
+          {
+          propertyName = "ARCHIVE_OUTPUT_DIRECTORY";
+          }
+        else
+          {
+          propertyName = "LIBRARY_OUTPUT_DIRECTORY";
+          }
         } break;
       case cmTarget::EXECUTABLE:
         {
         // Executables are always treated as runtime targets.
-        propertyName = "RUNTIME_OUTPUT_DIRECTORY";
+        // Executable import libraries are treated as archive targets.
+        if(implib)
+          {
+          propertyName = "ARCHIVE_OUTPUT_DIRECTORY";
+          }
+        else
+          {
+          propertyName = "RUNTIME_OUTPUT_DIRECTORY";
+          }
         } break;
       default: break;
       }



More information about the Cmake-commits mailing list