From 0d40703f49604d498788d6f757bfdcaf76930a21 Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 29 Apr 2009 15:07:09 -0400 Subject: [PATCH] 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. --- Modules/UntarFile.cmake | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/Modules/UntarFile.cmake b/Modules/UntarFile.cmake index 0b0e4030b..9f8e4df6a 100644 --- a/Modules/UntarFile.cmake +++ b/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: