[cmake-commits] alex committed cmInstallCommand.cxx 1.21 1.22 cmInstallCommand.h 1.17 1.18 cmInstallDirectoryGenerator.cxx 1.2 1.3 cmInstallDirectoryGenerator.h 1.2 1.3 cmInstallFilesGenerator.cxx 1.6 1.7 cmInstallFilesGenerator.h 1.6 1.7 cmInstallGenerator.h 1.8 1.9 cmInstallTargetGenerator.cxx 1.37 1.38 cmInstallTargetGenerator.h 1.13 1.14

cmake-commits at cmake.org cmake-commits at cmake.org
Tue Jun 19 11:11:08 EDT 2007


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

Modified Files:
	cmInstallCommand.cxx cmInstallCommand.h 
	cmInstallDirectoryGenerator.cxx cmInstallDirectoryGenerator.h 
	cmInstallFilesGenerator.cxx cmInstallFilesGenerator.h 
	cmInstallGenerator.h cmInstallTargetGenerator.cxx 
	cmInstallTargetGenerator.h 
Log Message:

STYLE: preparations for the INSTALL(EXPORT ...) generator
-move std::string Destination to cmInstallGenerator, since all (except
the script one) have it and add a const accessor so it can be queried
-use temporary variables in cmInstallCommand for the generators so they can be reused easier
-some more const

Alex


Index: cmInstallGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmInstallGenerator.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- cmInstallGenerator.h	21 Aug 2006 20:55:03 -0000	1.8
+++ cmInstallGenerator.h	19 Jun 2007 15:11:06 -0000	1.9
@@ -29,6 +29,7 @@
 {
 public:
   cmInstallGenerator();
+  cmInstallGenerator(const char* dest):Destination(dest?dest:"") {}
   virtual ~cmInstallGenerator();
 
   void Generate(std::ostream& os, const char* config,
@@ -47,11 +48,13 @@
     const char* literal_args = 0
     );
 
+  const char* GetDestination() const        {return this->Destination.c_str();}
 protected:
   virtual void GenerateScript(std::ostream& os)=0;
 
   const char* ConfigurationName;
   std::vector<std::string> const* ConfigurationTypes;
+  std::string Destination;
 };
 
 #endif

Index: cmInstallFilesGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmInstallFilesGenerator.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- cmInstallFilesGenerator.h	5 Oct 2006 15:31:56 -0000	1.6
+++ cmInstallFilesGenerator.h	19 Jun 2007 15:11:06 -0000	1.7
@@ -37,7 +37,6 @@
 protected:
   virtual void GenerateScript(std::ostream& os);
   std::vector<std::string> Files;
-  std::string Destination;
   bool Programs;
   std::string FilePermissions;
   std::vector<std::string> Configurations;

Index: cmInstallTargetGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmInstallTargetGenerator.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- cmInstallTargetGenerator.h	15 Jun 2007 19:33:57 -0000	1.13
+++ cmInstallTargetGenerator.h	19 Jun 2007 15:11:06 -0000	1.14
@@ -36,16 +36,19 @@
     );
   virtual ~cmInstallTargetGenerator();
 
+  std::string GetInstallFilename(const char* config) const;
   static std::string GetInstallFilename(cmTarget*target, const char* config, 
                                         bool implib, bool useSOName);
 
+  const std::vector<std::string>& GetConfigurations() const {return this->Configurations;}
+  
 protected:
   virtual void GenerateScript(std::ostream& os);
   void PrepareScriptReference(std::ostream& os, cmTarget* target,
                               const char* place, bool useConfigDir,
-                              bool useSOName);
+                              bool implib, bool useSOName);
   std::string GetScriptReference(cmTarget* target, const char* place,
-                                 bool useSOName);
+                                 bool implib, bool useSOName);
   void AddInstallNamePatchRule(std::ostream& os, const char* destination);
   void AddStripRule(std::ostream& os, 
                     cmTarget::TargetType type,
@@ -56,7 +59,6 @@
                      const std::string& quotedFullDestinationFilename);
 
   cmTarget* Target;
-  std::string Destination;
   bool ImportLibrary;
   std::string FilePermissions;
   std::vector<std::string> Configurations;

Index: cmInstallDirectoryGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmInstallDirectoryGenerator.cxx,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cmInstallDirectoryGenerator.cxx	21 Aug 2006 20:55:03 -0000	1.2
+++ cmInstallDirectoryGenerator.cxx	19 Jun 2007 15:11:06 -0000	1.3
@@ -27,7 +27,7 @@
                               std::vector<std::string> const& configurations,
                               const char* component,
                               const char* literal_args):
-  Directories(dirs), Destination(dest),
+  cmInstallGenerator(dest), Directories(dirs),
   FilePermissions(file_permissions), DirPermissions(dir_permissions),
   Configurations(configurations), Component(component),
   LiteralArguments(literal_args)

Index: cmInstallDirectoryGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmInstallDirectoryGenerator.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- cmInstallDirectoryGenerator.h	21 Aug 2006 20:55:03 -0000	1.2
+++ cmInstallDirectoryGenerator.h	19 Jun 2007 15:11:06 -0000	1.3
@@ -37,7 +37,6 @@
 protected:
   virtual void GenerateScript(std::ostream& os);
   std::vector<std::string> Directories;
-  std::string Destination;
   std::string FilePermissions;
   std::string DirPermissions;
   std::vector<std::string> Configurations;

Index: cmInstallFilesGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmInstallFilesGenerator.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- cmInstallFilesGenerator.cxx	5 Oct 2006 15:31:56 -0000	1.6
+++ cmInstallFilesGenerator.cxx	19 Jun 2007 15:11:06 -0000	1.7
@@ -27,7 +27,7 @@
                           const char* component,
                           const char* rename,
                           bool optional):
-  Files(files), Destination(dest), Programs(programs),
+  cmInstallGenerator(dest), Files(files), Programs(programs),
   FilePermissions(file_permissions), Configurations(configurations),
   Component(component), Rename(rename), Optional(optional)
 {

Index: cmInstallCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmInstallCommand.cxx,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- cmInstallCommand.cxx	22 May 2007 14:24:59 -0000	1.21
+++ cmInstallCommand.cxx	19 Jun 2007 15:11:06 -0000	1.22
@@ -410,6 +410,10 @@
     {
     // Handle each target type.
     cmTarget& target = *(*ti);
+    cmInstallTargetGenerator* archiveGenerator = 0;
+    cmInstallTargetGenerator* runtimeGenerator = 0;
+    cmInstallTargetGenerator* libraryGenerator = 0;
+
     switch(target.GetType())
       {
       case cmTarget::SHARED_LIBRARY:
@@ -424,23 +428,24 @@
           if(archive_destination)
             {
             // The import library uses the ARCHIVE properties.
-            this->Makefile->AddInstallGenerator(
-              new cmInstallTargetGenerator(target, archive_dest.c_str(), true,
+            archiveGenerator = new cmInstallTargetGenerator(target, 
+                                           archive_dest.c_str(), 
+                                           true,
                                            archive_permissions.c_str(),
                                            archive_configurations,
                                            archive_component.c_str(),
-                                           archive_optional));
+                                           archive_optional);
             }
           if(runtime_destination)
             {
             // The DLL uses the RUNTIME properties.
-            this->Makefile->AddInstallGenerator(
-              new cmInstallTargetGenerator(target, runtime_dest.c_str(),
+            runtimeGenerator = new cmInstallTargetGenerator(target, 
+                                           runtime_dest.c_str(),
                                            false,
                                            runtime_permissions.c_str(),
                                            runtime_configurations,
                                            runtime_component.c_str(),
-                                           runtime_optional));
+                                           runtime_optional);
             }
           }
         else
@@ -449,13 +454,13 @@
           if(library_destination)
             {
             // The shared library uses the LIBRARY properties.
-            this->Makefile->AddInstallGenerator(
-              new cmInstallTargetGenerator(target, library_dest.c_str(),
+            libraryGenerator = new cmInstallTargetGenerator(target, 
+                                           library_dest.c_str(),
                                            false,
                                            library_permissions.c_str(),
                                            library_configurations,
                                            library_component.c_str(),
-                                           library_optional));
+                                           library_optional);
             }
           else
             {
@@ -473,12 +478,13 @@
         // Static libraries use ARCHIVE properties.
         if(archive_destination)
           {
-          this->Makefile->AddInstallGenerator(
-            new cmInstallTargetGenerator(target, archive_dest.c_str(), false,
+          archiveGenerator = new cmInstallTargetGenerator(target, 
+                                         archive_dest.c_str(), 
+                                         false,
                                          archive_permissions.c_str(),
                                          archive_configurations,
                                          archive_component.c_str(),
-                                         archive_optional));
+                                         archive_optional);
           }
         else
           {
@@ -495,12 +501,13 @@
         // Modules use LIBRARY properties.
         if(library_destination)
           {
-          this->Makefile->AddInstallGenerator(
-            new cmInstallTargetGenerator(target, library_dest.c_str(), false,
+          libraryGenerator = new cmInstallTargetGenerator(target, 
+                                         library_dest.c_str(), 
+                                         false,
                                          library_permissions.c_str(),
                                          library_configurations,
                                          library_component.c_str(),
-                                         library_optional));
+                                         library_optional);
           }
         else
           {
@@ -517,12 +524,13 @@
         // Executables use the RUNTIME properties.
         if(runtime_destination)
           {
-          this->Makefile->AddInstallGenerator(
-            new cmInstallTargetGenerator(target, runtime_dest.c_str(), false,
+          runtimeGenerator = new cmInstallTargetGenerator(target, 
+                                         runtime_dest.c_str(), 
+                                         false,
                                          runtime_permissions.c_str(),
                                          runtime_configurations,
                                          runtime_component.c_str(),
-                                         runtime_optional));
+                                         runtime_optional);
           }
         else
           {
@@ -539,12 +547,13 @@
         if(dll_platform && archive_destination)
           {
           // The import library uses the ARCHIVE properties.
-          this->Makefile->AddInstallGenerator(
-            new cmInstallTargetGenerator(target, archive_dest.c_str(), true,
+          archiveGenerator = new cmInstallTargetGenerator(target, 
+                                         archive_dest.c_str(), 
+                                         true,
                                          archive_permissions.c_str(),
                                          archive_configurations,
                                          archive_component.c_str(),
-                                         true));
+                                         true);
           }
         }
         break;
@@ -553,6 +562,10 @@
         // Ignore the case.
         break;
       }
+    this->Makefile->AddInstallGenerator(archiveGenerator);
+    this->Makefile->AddInstallGenerator(runtimeGenerator);
+    this->Makefile->AddInstallGenerator(libraryGenerator);
+
     }
 
   // Tell the global generator about any installation component names
@@ -1114,7 +1127,7 @@
 
 //----------------------------------------------------------------------------
 void cmInstallCommand::ComputeDestination(const char* destination,
-                                          std::string& dest)
+                                          std::string& dest) const
 {
   if(destination)
     {
@@ -1142,7 +1155,7 @@
 
 //----------------------------------------------------------------------------
 bool cmInstallCommand::CheckPermissions(std::string const& arg,
-                                        std::string& permissions)
+                                        std::string& permissions) const
 {
   // Table of valid permissions.
   const char* table[] =

Index: cmInstallTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmInstallTargetGenerator.cxx,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- cmInstallTargetGenerator.cxx	15 Jun 2007 18:27:33 -0000	1.37
+++ cmInstallTargetGenerator.cxx	19 Jun 2007 15:11:06 -0000	1.38
@@ -27,7 +27,7 @@
                            const char* file_permissions,
                            std::vector<std::string> const& configurations,
                            const char* component, bool optional):
-  Target(&t), Destination(dest), ImportLibrary(implib),
+  cmInstallGenerator(dest), Target(&t), ImportLibrary(implib),
   FilePermissions(file_permissions), Configurations(configurations),
   Component(component), Optional(optional)
 {
@@ -58,11 +58,11 @@
     }
 
   // Write variable settings to do per-configuration references.
-  this->PrepareScriptReference(os, this->Target, "BUILD", true, false);
+  this->PrepareScriptReference(os, this->Target, "BUILD", true, this->ImportLibrary, false);
 
   // Create the per-configuration reference.
   std::string fromName = this->GetScriptReference(this->Target, "BUILD",
-                                                  false);
+                                                  this->ImportLibrary, false);
   std::string fromFile = fromDir;
   fromFile += fromName;
 
@@ -137,7 +137,7 @@
         // Compute the source locations of the bundle executable and
         // Info.plist file.
         this->PrepareScriptReference(os, this->Target, "INSTALL",
-                                     false, false);
+                                     false, this->ImportLibrary, false);
         fromFile += ".app";
         type = cmTarget::INSTALL_DIRECTORY;
         literal_args += " USE_SOURCE_PERMISSIONS";
@@ -188,6 +188,12 @@
   this->AddStripRule(os, type, quotedFullDestinationFilename, optional);
 }
 
+
+std::string cmInstallTargetGenerator::GetInstallFilename(const char* config) const
+{
+  return cmInstallTargetGenerator::GetInstallFilename(this->Target, config, this->ImportLibrary, false);
+}
+
 //----------------------------------------------------------------------------
 std::string cmInstallTargetGenerator::GetInstallFilename(cmTarget* target,
                                                          const char* config,
@@ -250,7 +256,7 @@
 cmInstallTargetGenerator
 ::PrepareScriptReference(std::ostream& os, cmTarget* target,
                          const char* place, bool useConfigDir,
-                         bool useSOName)
+                         bool implib, bool useSOName)
 {
   // If the target name may vary with the configuration type then
   // store all possible names ahead of time in variables.
@@ -270,11 +276,11 @@
       }
 
     fname += this->GetInstallFilename(target, i->c_str(), 
-                                      this->ImportLibrary, useSOName);
+                                      implib, useSOName);
 
     // Set a variable with the target name for this configuration.
     os << "SET(" << target->GetName() << "_" << place
-       << (this->ImportLibrary? "_IMPNAME_" : "_NAME_") << *i
+       << (implib? "_IMPNAME_" : "_NAME_") << *i
        << " \"" << fname << "\")\n";
     }
 }
@@ -282,20 +288,20 @@
 //----------------------------------------------------------------------------
 std::string cmInstallTargetGenerator::GetScriptReference(cmTarget* target,
                                                          const char* place,
-                                                         bool useSOName)
+                                                         bool implib, bool useSOName)
 {
   if(this->ConfigurationTypes->empty())
     {
     // Reference the target by its one configuration name.
     return this->GetInstallFilename(target, this->ConfigurationName, 
-                                    this->ImportLibrary, useSOName);
+                                    implib, useSOName);
     }
   else
     {
     // Reference the target using the per-configuration variable.
     std::string ref = "${";
     ref += target->GetName();
-    if(this->ImportLibrary)
+    if(implib)
       {
       ref += "_";
       ref += place;
@@ -361,13 +367,13 @@
             {
             // Map from the build-tree install_name.
             this->PrepareScriptReference(os, tgt, "REMAP_FROM",
-                                         !for_build.empty(), true);
-            for_build += this->GetScriptReference(tgt, "REMAP_FROM", true);
+                                         !for_build.empty(), false, true);
+            for_build += this->GetScriptReference(tgt, "REMAP_FROM", false, true);
 
             // Map to the install-tree install_name.
             this->PrepareScriptReference(os, tgt, "REMAP_TO",
-                                         false, true);
-            for_install += this->GetScriptReference(tgt, "REMAP_TO", true);
+                                         false, false, true);
+            for_install += this->GetScriptReference(tgt, "REMAP_TO", false, true);
 
             // Store the mapping entry.
             install_name_remap[for_build] = for_install;
@@ -378,7 +384,7 @@
     }
 
   // Edit the install_name of the target itself if necessary.
-  this->PrepareScriptReference(os, this->Target, "REMAPPED", false, true);
+  this->PrepareScriptReference(os, this->Target, "REMAPPED", false, this->ImportLibrary, true);
   std::string new_id;
   if(this->Target->GetType() == cmTarget::SHARED_LIBRARY)
     {
@@ -390,7 +396,7 @@
       {
       // Prepare to refer to the install-tree install_name.
       new_id = for_install;
-      new_id += this->GetScriptReference(this->Target, "REMAPPED", true);
+      new_id += this->GetScriptReference(this->Target, "REMAPPED", this->ImportLibrary, true);
       }
     }
 
@@ -416,7 +422,7 @@
       os << "\n    -change \"" << i->first << "\" \"" << i->second << "\"";
       }
     os << "\n    \"$ENV{DESTDIR}" << destination << "/"
-       << this->GetScriptReference(this->Target, "REMAPPED", true) << "\")\n";
+       << this->GetScriptReference(this->Target, "REMAPPED", this->ImportLibrary, true) << "\")\n";
     os << "ENDIF(" << component_test << ")\n";
     }
 }

Index: cmInstallCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmInstallCommand.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- cmInstallCommand.h	15 Jun 2007 14:34:40 -0000	1.17
+++ cmInstallCommand.h	19 Jun 2007 15:11:06 -0000	1.18
@@ -248,8 +248,8 @@
   bool HandleTargetsMode(std::vector<std::string> const& args);
   bool HandleFilesMode(std::vector<std::string> const& args);
   bool HandleDirectoryMode(std::vector<std::string> const& args);
-  void ComputeDestination(const char* destination, std::string& dest);
-  bool CheckPermissions(std::string const& arg, std::string& permissions);
+  void ComputeDestination(const char* destination, std::string& dest) const;
+  bool CheckPermissions(std::string const& arg, std::string& permissions)const;
 };
 
 



More information about the Cmake-commits mailing list