diff --git a/SystemTools.cxx b/SystemTools.cxx
index 2e63bb2bc702c9c0964917d194f9c3701d1c7381..85f44cea21f40c72de1aa415df65deafa377a629 100644
--- a/SystemTools.cxx
+++ b/SystemTools.cxx
@@ -930,6 +930,10 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination)
     {
     return true;
     }
+
+  mode_t perm = 0;
+  bool perms = SystemTools::GetPermissions(source, perm);
+
   const int bufferSize = 4096;
   char buffer[bufferSize];
 
@@ -1022,6 +1026,13 @@ bool SystemTools::CopyFileAlways(const char* source, const char* destination)
     {
     return false;
     }
+  if ( perms )
+    {
+    if ( !SystemTools::SetPermissions(destination, perm) )
+      {
+      return false;
+      }
+    }
   return true;
 }
 
@@ -1886,6 +1897,40 @@ int SystemTools::GetTerminalWidth()
 #endif
   return width;
 }
+
+bool SystemTools::GetPermissions(const char* file, mode_t& mode)
+{
+  if ( !file )
+    {
+    return false;
+    }
+
+  struct stat st;
+  if ( stat(file, &st) < 0 )
+    {
+    return false;
+    }
+  mode = st.st_mode;
+  return true;
+}
+
+bool SystemTools::SetPermissions(const char* file, mode_t mode)
+{
+  if ( !file )
+    {
+    return false;
+    }
+  if ( !SystemTools::FileExists(file) )
+    {
+    return false;
+    }
+  if ( chmod(file, mode) < 0 )
+    {
+    return false;
+    }
+
+  return true;
+}
 } // namespace KWSYS_NAMESPACE
 
 #if defined(_MSC_VER) && defined(_DEBUG)
diff --git a/SystemTools.hxx.in b/SystemTools.hxx.in
index db8f6d6fea0dbe9cab40b7cae2395619e61b44fe..0561bc1225fb2bbde128ec4ded403f5451a318fe 100644
--- a/SystemTools.hxx.in
+++ b/SystemTools.hxx.in
@@ -20,6 +20,8 @@
 
 #include <@KWSYS_NAMESPACE@/Configure.h>
 
+#include <sys/types.h>
+
 /* Define these macros temporarily to keep the code readable.  */
 #if !defined (KWSYS_NAMESPACE) && !@KWSYS_NAMESPACE@_NAME_IS_KWSYS
 # define kwsys_stl @KWSYS_NAMESPACE@_stl
@@ -284,6 +286,12 @@ public:
    */
   static int GetTerminalWidth();
   
+  /**
+   * Get and set permissions of the file.
+   */
+  static bool GetPermissions(const char* file, mode_t& mode);
+  static bool SetPermissions(const char* file, mode_t mode);
+
 protected:
   // these two functions can be called from ConvertToOutputPath
   /**
@@ -299,6 +307,7 @@ protected:
    * if there are spaces in the string it is double quoted.
    */
   static kwsys_stl::string ConvertToWindowsOutputPath(const char*);
+
 };
 
 } // namespace @KWSYS_NAMESPACE@