瀏覽代碼

file(INSTALL): Do not pre-create DESTINATION for DIRECTORY

When installing a DIRECTORY, do not pre-create the DESTINATION.  The
cmFileCopier::InstallDirectory method will create the directory anyway.
Give it a chance to detect whether the directory already exists or not.
Brad King 11 年之前
父節點
當前提交
f701b0b7f7
共有 1 個文件被更改,包括 13 次插入10 次删除
  1. 13 10
      Source/cmFileCommand.cxx

+ 13 - 10
Source/cmFileCommand.cxx

@@ -2057,23 +2057,26 @@ bool cmFileInstaller::HandleInstallDestination()
     this->DestDirLength = int(sdestdir.size());
     this->DestDirLength = int(sdestdir.size());
     }
     }
 
 
-  if ( !cmSystemTools::FileExists(destination.c_str()) )
+  if(this->InstallType != cmInstallType_DIRECTORY)
     {
     {
-    if ( !cmSystemTools::MakeDirectory(destination.c_str()) )
+    if ( !cmSystemTools::FileExists(destination.c_str()) )
       {
       {
-      std::string errstring = "cannot create directory: " + destination +
+      if ( !cmSystemTools::MakeDirectory(destination.c_str()) )
+        {
+        std::string errstring = "cannot create directory: " + destination +
           ". Maybe need administrative privileges.";
           ". Maybe need administrative privileges.";
+        this->FileCommand->SetError(errstring);
+        return false;
+        }
+      }
+    if ( !cmSystemTools::FileIsDirectory(destination.c_str()) )
+      {
+      std::string errstring = "INSTALL destination: " + destination +
+        " is not a directory.";
       this->FileCommand->SetError(errstring);
       this->FileCommand->SetError(errstring);
       return false;
       return false;
       }
       }
     }
     }
-  if ( !cmSystemTools::FileIsDirectory(destination.c_str()) )
-    {
-    std::string errstring = "INSTALL destination: " + destination +
-        " is not a directory.";
-    this->FileCommand->SetError(errstring);
-    return false;
-    }
   return true;
   return true;
 }
 }