Selaa lähdekoodia

ENH: Teach UntarFile to preserve file timestamps

After extracting the tarball in a temporary directory we copy the tree
to the destination directory.  The 'cmake -E copy_directory' command
does not preserve file timestamps, so we use file(COPY) instead.
Brad King 16 vuotta sitten
vanhempi
sitoutus
0d40703f49
1 muutettua tiedostoa jossa 3 lisäystä ja 19 poistoa
  1. 3 19
      Modules/UntarFile.cmake

+ 3 - 19
Modules/UntarFile.cmake

@@ -66,31 +66,15 @@ endif()
 # Analyze what came out of the tar file:
 #
 file(GLOB contents "${ut_dir}/*")
-
-set(is_one_directory 0)
 list(LENGTH contents n)
-if(n EQUAL 1)
-  if(IS_DIRECTORY "${contents}")
-    set(is_one_directory 1)
-  endif()
+if(NOT n EQUAL 1 OR NOT IS_DIRECTORY "${contents}")
+  set(contents "${ut_dir}")
 endif()
 
 
 # Copy "the one" directory to the final directory:
 #
-if(is_one_directory EQUAL 1)
-  #message(STATUS "info: (1) copying '${contents}' to '${directory}'...")
-  execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${contents}" "${directory}"
-    RESULT_VARIABLE rv)
-else()
-  #message(STATUS "info: (more) copying '${ut_dir}' to '${directory}'...")
-  execute_process(COMMAND ${CMAKE_COMMAND} -E copy_directory "${ut_dir}" "${directory}"
-    RESULT_VARIABLE rv)
-endif()
-
-if(NOT rv EQUAL 0)
-  message(FATAL_ERROR "error: copy_directory failed after untar in '${ut_dir}'")
-endif()
+file(COPY "${contents}/" DESTINATION ${directory})
 
 
 # Clean up: