浏览代码

ENH: add install/strip target for makefile generators if strip was found

Alex
Alexander Neundorf 18 年之前
父节点
当前提交
df8f550029

+ 21 - 2
Source/cmGlobalGenerator.cxx

@@ -1440,16 +1440,35 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
     // install_local
     if(const char* install_local = this->GetInstallLocalTargetName())
       {
-      singleLine.insert(singleLine.begin()+1, "-DCMAKE_INSTALL_LOCAL_ONLY=1");
+      cmCustomCommandLine localCmdLine = singleLine;
+
+      localCmdLine.insert(localCmdLine.begin()+1, "-DCMAKE_INSTALL_LOCAL_ONLY=1");
       cpackCommandLines.erase(cpackCommandLines.begin(),
         cpackCommandLines.end());
-      cpackCommandLines.push_back(singleLine);
+      cpackCommandLines.push_back(localCmdLine);
 
       (*targets)[install_local] =
         this->CreateGlobalTarget(
           install_local, "Installing only the local directory...",
           &cpackCommandLines, depends);
       }
+
+    // install_strip
+    const char* install_strip = this->GetInstallStripTargetName();
+    if((install_strip !=0) && (mf->IsSet("CMAKE_STRIP")))
+      {
+      cmCustomCommandLine stripCmdLine = singleLine;
+
+      stripCmdLine.insert(stripCmdLine.begin()+1,"-DCMAKE_INSTALL_DO_STRIP=1");
+      cpackCommandLines.erase(cpackCommandLines.begin(),
+        cpackCommandLines.end());
+      cpackCommandLines.push_back(stripCmdLine);
+
+      (*targets)[install_strip] =
+        this->CreateGlobalTarget(
+          install_strip, "Installing the project stripped...",
+          &cpackCommandLines, depends);
+      }
     }
 }
 

+ 1 - 0
Source/cmGlobalGenerator.h

@@ -186,6 +186,7 @@ public:
   virtual const char* GetAllTargetName()          { return "ALL_BUILD"; }
   virtual const char* GetInstallTargetName()      { return "INSTALL"; }
   virtual const char* GetInstallLocalTargetName() { return 0; }
+  virtual const char* GetInstallStripTargetName() { return 0; }
   virtual const char* GetPreinstallTargetName()   { return 0; }
   virtual const char* GetTestTargetName()         { return "RUN_TESTS"; }
   virtual const char* GetPackageTargetName()      { return "PACKAGE"; }

+ 1 - 0
Source/cmGlobalUnixMakefileGenerator3.h

@@ -161,6 +161,7 @@ protected:
   virtual const char* GetAllTargetName()          { return "all"; }
   virtual const char* GetInstallTargetName()      { return "install"; }
   virtual const char* GetInstallLocalTargetName() { return "install/local"; }
+  virtual const char* GetInstallStripTargetName() { return "install/strip"; }
   virtual const char* GetPreinstallTargetName()   { return "preinstall"; }
   virtual const char* GetTestTargetName()         { return "test"; }
   virtual const char* GetPackageTargetName()      { return "package"; }

+ 3 - 1
Source/cmLocalUnixMakefileGenerator3.cxx

@@ -1456,7 +1456,9 @@ void cmLocalUnixMakefileGenerator3
 
       // Provide a "/fast" version of the target.
       depends.clear();
-      if((targetName == "install") || (targetName == "install_local"))
+      if((targetName == "install") 
+          || (targetName == "install_local")
+          || (targetName == "install_strip"))
         {
         // Provide a fast install target that does not depend on all
         // but has the same command.