Browse Source

ENH: don't add package target if no package file is around

Bill Hoffman 19 years ago
parent
commit
0952ff6f4b
1 changed files with 16 additions and 9 deletions
  1. 16 9
      Source/cmGlobalGenerator.cxx

+ 16 - 9
Source/cmGlobalGenerator.cxx

@@ -1309,10 +1309,13 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
     {
     depends.push_back("preinstall");
     }
-  (*targets)[this->GetPackageTargetName()]
-    = this->CreateGlobalTarget(this->GetPackageTargetName(),
-      "Run CPack packaging tool...", &cpackCommandLines, depends);
-
+  if(cmSystemTools::FileExists(configFile.c_str()))
+    {
+    (*targets)[this->GetPackageTargetName()]
+      = this->CreateGlobalTarget(this->GetPackageTargetName(),
+                                 "Run CPack packaging tool...",
+                                 &cpackCommandLines, depends);
+    }
   // CPack source
   const char* packageSourceTargetName = this->GetPackageSourceTargetName();
   if ( packageSourceTargetName )
@@ -1324,11 +1327,15 @@ void cmGlobalGenerator::CreateDefaultGlobalTargets(cmTargets* targets)
     singleLine.push_back("--config");
     configFile = mf->GetStartOutputDirectory();;
     configFile += "/CPackSourceConfig.cmake";
-    singleLine.push_back(configFile);
-    cpackCommandLines.push_back(singleLine);
-    (*targets)[packageSourceTargetName]
-      = this->CreateGlobalTarget(packageSourceTargetName,
-        "Run CPack packaging tool for source...", &cpackCommandLines, depends);
+    if(cmSystemTools::FileExists(configFile.c_str()))
+      {
+      singleLine.push_back(configFile);
+      cpackCommandLines.push_back(singleLine);
+      (*targets)[packageSourceTargetName]
+        = this->CreateGlobalTarget(packageSourceTargetName,
+                                   "Run CPack packaging tool for source...",
+                                   &cpackCommandLines, depends);
+      }
     }
 
   // Test