[cmake-commits] alex committed cmGlobalGenerator.cxx 1.173 1.173.2.1 cmInstallTargetGenerator.cxx 1.28.2.1 1.28.2.2 cmInstallTargetGenerator.h 1.9 1.9.2.1 cmLocalGenerator.cxx 1.212 1.212.2.1 cmLocalGenerator.h 1.78 1.78.2.1

cmake-commits at cmake.org cmake-commits at cmake.org
Mon May 14 16:28:09 EDT 2007


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

Modified Files:
      Tag: CMake-CrossCompileBasic
	cmGlobalGenerator.cxx cmInstallTargetGenerator.cxx 
	cmInstallTargetGenerator.h cmLocalGenerator.cxx 
	cmLocalGenerator.h 
Log Message:

ENH: move stripping from cpack to cmake/install time, fully configurable via
the CMAKE_STRIP_FILE rule, currently only implemented for the GNU toolchain.
Now cpack should work also for cross compiling (since it doesn't have to
know the executable suffix anymore).

stripping can be enabled/disabled via the cache variable CMAKE_INSTALL_DO_STRIP.

Even if this is disabled, the cmake_install.cmake files still contain the
strip rules, so by running cmake -DCMAKE_INSTALL_DO_STRIP=1
cmake_install.cmake you can install with stripping also in this case.

Alex


Index: cmLocalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.cxx,v
retrieving revision 1.212
retrieving revision 1.212.2.1
diff -u -d -r1.212 -r1.212.2.1
--- cmLocalGenerator.cxx	18 Apr 2007 13:56:06 -0000	1.212
+++ cmLocalGenerator.cxx	14 May 2007 20:28:07 -0000	1.212.2.1
@@ -924,6 +924,13 @@
       return replaceValues.TargetInstallNameDir;
       }
     }
+  if(replaceValues.BinaryFullInstallPath)
+    {
+    if(variable == "BINARY_FULL_INSTALL_PATH")
+      {
+      return replaceValues.BinaryFullInstallPath;
+      }
+    }
   if(replaceValues.LinkLibraries)
     {
     if(variable == "LINK_LIBRARIES")

Index: cmInstallTargetGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmInstallTargetGenerator.cxx,v
retrieving revision 1.28.2.1
retrieving revision 1.28.2.2
diff -u -d -r1.28.2.1 -r1.28.2.2
--- cmInstallTargetGenerator.cxx	14 May 2007 15:08:00 -0000	1.28.2.1
+++ cmInstallTargetGenerator.cxx	14 May 2007 20:28:07 -0000	1.28.2.2
@@ -178,6 +178,8 @@
     {
     this->AddInstallNamePatchRule(os, destination.c_str());
     }
+
+    this->AddStripRule(os, destination, fromFile);
 }
 
 //----------------------------------------------------------------------------
@@ -418,8 +420,9 @@
     component_test += this->Component;
     component_test += ")$\"";
     os << "IF(" << component_test << ")\n";
-    os << "  EXECUTE_PROCESS(COMMAND ";
+    os << "  EXECUTE_PROCESS(COMMAND \"";
     os <<this->Target->GetMakefile()->GetDefinition("CMAKE_INSTALL_NAME_TOOL");
+    os << "\"";
     if(!new_id.empty())
       {
       os << "\n    -id \"" << new_id << "\"";
@@ -435,3 +438,45 @@
     os << "ENDIF(" << component_test << ")\n";
     }
 }
+
+void cmInstallTargetGenerator::AddStripRule(std::ostream& os, 
+                                            const std::string& destination,
+                                            const std::string& fromFile)
+{
+
+  // Don't handle OSX Bundles.
+  if(this->Target->GetMakefile()->IsOn("APPLE") &&
+     this->Target->GetPropertyAsBool("MACOSX_BUNDLE"))
+    {
+    return;
+    }
+
+  std::string stripRule = this->Target->GetMakefile()->GetSafeDefinition("CMAKE_STRIP_BINARY");
+  if (!stripRule.size()>0)
+    {
+    return;
+    }
+
+  if(! this->Target->GetMakefile()->IsSet("CMAKE_STRIP"))
+    {
+    return;
+    }
+
+  std::string destinationFilename = "\"";
+  destinationFilename += destination;
+  destinationFilename += "/";
+  destinationFilename += cmSystemTools::GetFilenameName(fromFile);
+  destinationFilename += "\"";
+
+  cmLocalGenerator::RuleVariables vars;
+  vars.BinaryFullInstallPath = destinationFilename.c_str();
+
+  this->Target->GetMakefile()->
+      GetLocalGenerator()->ExpandRuleVariables(stripRule, vars);
+  
+  os << "IF(CMAKE_INSTALL_DO_STRIP)\n";
+  os << "  EXECUTE_PROCESS(COMMAND ";
+  os << stripRule;
+  os << " )\n";
+  os << "ENDIF(CMAKE_INSTALL_DO_STRIP)\n";
+}

Index: cmLocalGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmLocalGenerator.h,v
retrieving revision 1.78
retrieving revision 1.78.2.1
diff -u -d -r1.78 -r1.78.2.1
--- cmLocalGenerator.h	16 Mar 2007 14:34:25 -0000	1.78
+++ cmLocalGenerator.h	14 May 2007 20:28:07 -0000	1.78.2.1
@@ -187,6 +187,7 @@
     const char* ObjectsQuoted;
     const char* TargetSOName;
     const char* TargetInstallNameDir;
+    const char* BinaryFullInstallPath;
     const char* LinkFlags;
     const char* LanguageCompileFlags;
   };
@@ -222,6 +223,9 @@
   std::string ConvertToRelativePath(const std::vector<std::string>& local,
                                     const char* remote);
 
+  // Expand rule variables in CMake of the type found in language rules
+  void ExpandRuleVariables(std::string& string,
+                           const RuleVariables& replaceValues);
 protected:
 
   /** Construct a comment for a custom command.  */
@@ -238,9 +242,6 @@
   ///! put all the libraries for a target on into the given stream
   virtual void OutputLinkLibraries(std::ostream&, cmTarget&, bool relink);
 
-  // Expand rule variables in CMake of the type found in language rules
-  void ExpandRuleVariables(std::string& string,
-                           const RuleVariables& replaceValues);
   // Expand rule variables in a single string
   std::string ExpandRuleVariable(std::string const& variable,
                                  const RuleVariables& replaceValues);

Index: cmGlobalGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmGlobalGenerator.cxx,v
retrieving revision 1.173
retrieving revision 1.173.2.1
diff -u -d -r1.173 -r1.173.2.1
--- cmGlobalGenerator.cxx	24 Apr 2007 16:30:25 -0000	1.173
+++ cmGlobalGenerator.cxx	14 May 2007 20:28:07 -0000	1.173.2.1
@@ -1416,6 +1416,10 @@
       cfgArg += mf->GetDefinition("CMAKE_CFG_INTDIR");
       singleLine.push_back(cfgArg);
       }
+    if(mf->IsOn("CMAKE_INSTALL_DO_STRIP"))
+      {
+      singleLine.push_back("-DCMAKE_INSTALL_DO_STRIP=1");
+      }
     singleLine.push_back("-P");
     singleLine.push_back("cmake_install.cmake");
     cpackCommandLines.push_back(singleLine);

Index: cmInstallTargetGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/cmInstallTargetGenerator.h,v
retrieving revision 1.9
retrieving revision 1.9.2.1
diff -u -d -r1.9 -r1.9.2.1
--- cmInstallTargetGenerator.h	5 Oct 2006 15:31:56 -0000	1.9
+++ cmInstallTargetGenerator.h	14 May 2007 20:28:07 -0000	1.9.2.1
@@ -45,6 +45,8 @@
   std::string GetScriptReference(cmTarget* target, const char* place,
                                  bool useSOName);
   void AddInstallNamePatchRule(std::ostream& os, const char* destination);
+  void AddStripRule(std::ostream& os, const std::string& destination,
+                    const std::string& fromFile);
   cmTarget* Target;
   std::string Destination;
   bool ImportLibrary;



More information about the Cmake-commits mailing list