[cmake-commits] king committed cmExportBuildFileGenerator.cxx 1.5 1.6 cmExportCommand.cxx 1.10 1.11 cmExportInstallFileGenerator.cxx 1.7 1.8 cmInstallCommand.cxx 1.43 1.44 cmInstallTargetGenerator.cxx 1.58 1.59 cmInstallTargetGenerator.h 1.23 1.24

cmake-commits at cmake.org cmake-commits at cmake.org
Wed Feb 6 14:20:38 EST 2008


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

Modified Files:
	cmExportBuildFileGenerator.cxx cmExportCommand.cxx 
	cmExportInstallFileGenerator.cxx cmInstallCommand.cxx 
	cmInstallTargetGenerator.cxx cmInstallTargetGenerator.h 
Log Message:
ENH: Improve exporting/importing of targets

  - Use real name instead of link for location of versioned targets
  - Error when a target is exported multiple times


Index: cmInstallTargetGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmInstallTargetGenerator.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- cmInstallTargetGenerator.h	4 Feb 2008 22:03:48 -0000	1.23
+++ cmInstallTargetGenerator.h	6 Feb 2008 19:20:35 -0000	1.24
@@ -45,10 +45,20 @@
     NamelinkModeSkip
   };
   void SetNamelinkMode(NamelinkModeType mode) { this->NamelinkMode = mode; }
+  NamelinkModeType GetNamelinkMode() const { return this->NamelinkMode; }
 
   std::string GetInstallFilename(const char* config) const;
-  static std::string GetInstallFilename(cmTarget*target, const char* config, 
-                                        bool implib, bool useSOName);
+
+  enum NameType
+  {
+    NameNormal,
+    NameImplib,
+    NameSO,
+    NameReal
+  };
+
+  static std::string GetInstallFilename(cmTarget*target, const char* config,
+                                        NameType nameType = NameNormal);
 
   cmTarget* GetTarget() const { return this->Target; }
   bool IsImportLibrary() const { return this->ImportLibrary; }

Index: cmInstallCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmInstallCommand.cxx,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- cmInstallCommand.cxx	4 Feb 2008 22:03:48 -0000	1.43
+++ cmInstallCommand.cxx	6 Feb 2008 19:20:35 -0000	1.44
@@ -394,6 +394,9 @@
     cmInstallFilesGenerator* publicHeaderGenerator = 0;
     cmInstallFilesGenerator* resourceGenerator = 0;
 
+    // Track whether this is a namelink-only rule.
+    bool namelinkOnly = false;
+
     switch(target.GetType())
       {
       case cmTarget::SHARED_LIBRARY:
@@ -464,6 +467,8 @@
               libraryGenerator = CreateInstallTargetGenerator(target, 
                                                            libraryArgs, false);
               libraryGenerator->SetNamelinkMode(namelinkMode);
+              namelinkOnly =
+                (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly);
               }
             else
               {
@@ -503,6 +508,8 @@
           libraryGenerator = CreateInstallTargetGenerator(target, libraryArgs, 
                                                           false);
           libraryGenerator->SetNamelinkMode(namelinkMode);
+          namelinkOnly =
+            (namelinkMode == cmInstallTargetGenerator::NamelinkModeOnly);
           }
         else
           {
@@ -583,7 +590,7 @@
     createInstallGeneratorsForTargetFileSets = false;
     }
 
-  if(createInstallGeneratorsForTargetFileSets)
+  if(createInstallGeneratorsForTargetFileSets && !namelinkOnly)
     {
     const char* files = target.GetProperty("PRIVATE_HEADER");
     if ((files) && (*files))
@@ -673,7 +680,9 @@
     this->Makefile->AddInstallGenerator(publicHeaderGenerator);
     this->Makefile->AddInstallGenerator(resourceGenerator);
 
-    if (!exports.GetString().empty())
+    // Add this install rule to an export if one was specified and
+    // this is not a namelink-only rule.
+    if(!exports.GetString().empty() && !namelinkOnly)
       {
       this->Makefile->GetLocalGenerator()->GetGlobalGenerator()
         ->AddTargetToExports(exports.GetCString(), &target, 

Index: cmInstallTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmInstallTargetGenerator.cxx,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -d -r1.58 -r1.59
--- cmInstallTargetGenerator.cxx	5 Feb 2008 00:00:33 -0000	1.58
+++ cmInstallTargetGenerator.cxx	6 Feb 2008 19:20:35 -0000	1.59
@@ -144,10 +144,10 @@
                              Indent const& indent)
 {
   // Compute the full path to the main installed file for this target.
+  NameType nameType = this->ImportLibrary? NameImplib : NameNormal;
   std::string toInstallPath = this->GetInstallDestination();
   toInstallPath += "/";
-  toInstallPath += this->GetInstallFilename(this->Target, config,
-                                              this->ImportLibrary, false);
+  toInstallPath += this->GetInstallFilename(this->Target, config, nameType);
 
   // Track whether post-install operations should be added to the
   // script.
@@ -194,8 +194,8 @@
         // Need to apply install_name_tool and stripping to binary
         // inside bundle.
         toInstallPath += ".app/Contents/MacOS/";
-        toInstallPath += this->GetInstallFilename(this->Target, config,
-                                                  this->ImportLibrary, false);
+        toInstallPath +=
+          this->GetInstallFilename(this->Target, config, nameType);
         literal_args += " USE_SOURCE_PERMISSIONS";
         }
       else
@@ -250,7 +250,7 @@
       // inside framework.
       toInstallPath += ".framework/";
       toInstallPath += this->GetInstallFilename(this->Target, config,
-                                                this->ImportLibrary, false);
+                                                NameNormal);
 
       literal_args += " USE_SOURCE_PERMISSIONS";
       }
@@ -369,16 +369,16 @@
 std::string
 cmInstallTargetGenerator::GetInstallFilename(const char* config) const
 {
+  NameType nameType = this->ImportLibrary? NameImplib : NameNormal;
   return
     cmInstallTargetGenerator::GetInstallFilename(this->Target, config,
-                                                 this->ImportLibrary, false);
+                                                 nameType);
 }
 
 //----------------------------------------------------------------------------
 std::string cmInstallTargetGenerator::GetInstallFilename(cmTarget* target,
                                                          const char* config,
-                                                         bool implib,
-                                                         bool useSOName)
+                                                         NameType nameType)
 {
   std::string fname;
   // Compute the name of the library.
@@ -391,11 +391,16 @@
     target->GetExecutableNames(targetName, targetNameReal,
                                targetNameImport, targetNamePDB,
                                config);
-    if(implib)
+    if(nameType == NameImplib)
       {
       // Use the import library name.
       fname = targetNameImport;
       }
+    else if(nameType == NameReal)
+      {
+      // Use the canonical name.
+      fname = targetNameReal;
+      }
     else
       {
       // Use the canonical name.
@@ -411,16 +416,21 @@
     std::string targetNamePDB;
     target->GetLibraryNames(targetName, targetNameSO, targetNameReal,
                             targetNameImport, targetNamePDB, config);
-    if(implib)
+    if(nameType == NameImplib)
       {
       // Use the import library name.
       fname = targetNameImport;
       }
-    else if(useSOName)
+    else if(nameType == NameSO)
       {
       // Use the soname.
       fname = targetNameSO;
       }
+    else if(nameType == NameReal)
+      {
+      // Use the real name.
+      fname = targetNameReal;
+      }
     else
       {
       // Use the canonical name.
@@ -474,7 +484,7 @@
         // The directory portions differ.  Append the filename to
         // create the mapping.
         std::string fname =
-          this->GetInstallFilename(tgt, config, false, true);
+          this->GetInstallFilename(tgt, config, NameSO);
 
         // Map from the build-tree install_name.
         for_build += fname;
@@ -511,8 +521,7 @@
       {
       // Prepare to refer to the install-tree install_name.
       new_id = for_install;
-      new_id += this->GetInstallFilename(this->Target, config,
-                                         this->ImportLibrary, true);
+      new_id += this->GetInstallFilename(this->Target, config, NameSO);
       }
     }
 

Index: cmExportBuildFileGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmExportBuildFileGenerator.cxx,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- cmExportBuildFileGenerator.cxx	1 Feb 2008 13:56:00 -0000	1.5
+++ cmExportBuildFileGenerator.cxx	6 Feb 2008 19:20:35 -0000	1.6
@@ -33,8 +33,20 @@
       tei != this->Exports->end(); ++tei)
     {
     cmTarget* te = *tei;
-    this->ExportedTargets.insert(te);
-    this->GenerateImportTargetCode(os, te);
+    if(this->ExportedTargets.insert(te).second)
+      {
+      this->GenerateImportTargetCode(os, te);
+      }
+    else
+      {
+      if(this->ExportCommand && this->ExportCommand->ErrorMessage.empty())
+        {
+        cmOStringStream e;
+        e << "given target \"" << te->GetName() << "\" more than once.";
+        this->ExportCommand->ErrorMessage = e.str();
+        }
+      return false;
+      }
     }
 
   // Generate import file content for each configuration.
@@ -93,12 +105,21 @@
   {
   std::string prop = "IMPORTED_LOCATION";
   prop += suffix;
-  std::string value = target->GetFullPath(config, false);
-  if(target->IsAppBundleOnApple())
+  std::string value;
+  if(target->IsFrameworkOnApple())
+    {
+    value = target->GetFullPath(config, false);
+    }
+  else if(target->IsAppBundleOnApple())
     {
+    value = target->GetFullPath(config, false);
     value += ".app/Contents/MacOS/";
     value += target->GetFullName(config, false);
     }
+  else
+    {
+    value = target->GetFullPath(config, false, true);
+    }
   properties[prop] = value;
   }
 

Index: cmExportInstallFileGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmExportInstallFileGenerator.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- cmExportInstallFileGenerator.cxx	1 Feb 2008 19:35:14 -0000	1.7
+++ cmExportInstallFileGenerator.cxx	6 Feb 2008 19:20:35 -0000	1.8
@@ -36,8 +36,19 @@
       tei != this->ExportSet->end(); ++tei)
     {
     cmTargetExport* te = *tei;
-    this->ExportedTargets.insert(te->Target);
-    this->GenerateImportTargetCode(os, te->Target);
+    if(this->ExportedTargets.insert(te->Target).second)
+      {
+      this->GenerateImportTargetCode(os, te->Target);
+      }
+    else
+      {
+      cmOStringStream e;
+      e << "INSTALL(EXPORT \"" << this->Name << "\" ...) "
+        << "includes target \"" << te->Target->GetName()
+        << "\" more than once in the export set.";
+      cmSystemTools::Error(e.str().c_str());
+      return false;
+      }
     }
 
   // Now load per-configuration properties for them.
@@ -204,11 +215,8 @@
     return;
     }
 
-  {
-  // Construct the property name.
-  std::string prop = (itgen->IsImportLibrary()?
-                      "IMPORTED_IMPLIB" : "IMPORTED_LOCATION");
-  prop += suffix;
+  // Get the target to be installed.
+  cmTarget* target = itgen->GetTarget();
 
   // Construct the installed location of the target.
   std::string dest = itgen->GetDestination();
@@ -225,25 +233,47 @@
   value += dest;
   value += "/";
 
-  // Append the installed file name.
-  std::string fname = itgen->GetInstallFilename(config);
-  value += fname;
-
-  // Fix name for frameworks and bundles.
-  if(itgen->GetTarget()->IsFrameworkOnApple())
+  if(itgen->IsImportLibrary())
     {
-    value += ".framework/";
-    value += fname;
+    // Construct the property name.
+    std::string prop = "IMPORTED_IMPLIB";
+    prop += suffix;
+
+    // Append the installed file name.
+    value += itgen->GetInstallFilename(target, config,
+                                       cmInstallTargetGenerator::NameImplib);
+
+    // Store the property.
+    properties[prop] = value;
     }
-  else if(itgen->GetTarget()->IsAppBundleOnApple())
+  else
     {
-    value += ".app/Contents/MacOS/";
-    value += fname;
-    }
+    // Construct the property name.
+    std::string prop = "IMPORTED_LOCATION";
+    prop += suffix;
 
-  // Store the property.
-  properties[prop] = value;
-  }
+    // Append the installed file name.
+    if(target->IsFrameworkOnApple())
+      {
+      value += itgen->GetInstallFilename(target, config);
+      value += ".framework/";
+      value += itgen->GetInstallFilename(target, config);
+      }
+    else if(target->IsAppBundleOnApple())
+      {
+      value += itgen->GetInstallFilename(target, config);
+      value += ".app/Contents/MacOS/";
+      value += itgen->GetInstallFilename(target, config);
+      }
+    else
+      {
+      value += itgen->GetInstallFilename(target, config,
+                                         cmInstallTargetGenerator::NameReal);
+      }
+
+    // Store the property.
+    properties[prop] = value;
+    }
 }
 
 //----------------------------------------------------------------------------

Index: cmExportCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmExportCommand.cxx,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- cmExportCommand.cxx	30 Jan 2008 22:25:52 -0000	1.10
+++ cmExportCommand.cxx	6 Feb 2008 19:20:35 -0000	1.11
@@ -169,7 +169,7 @@
     }
 
   // Generate the import file.
-  if(!ebfg.GenerateImportFile())
+  if(!ebfg.GenerateImportFile() && this->ErrorMessage.empty())
     {
     this->SetError("could not write export file.");
     return false;



More information about the Cmake-commits mailing list