소스 검색

Use RENAME, not COPY, to extract .tar.gz files.

  Use ABSOLUTE file name for the RENAME operation.
  (Thanks to Marcus for figuring out that it doesn't
   work on Linux without the ABSOLUTE bit.)
David Cole 15 년 전
부모
커밋
f5e8ce522e
1개의 변경된 파일10개의 추가작업 그리고 9개의 파일을 삭제
  1. 10 9
      Modules/ExternalProject.cmake

+ 10 - 9
Modules/ExternalProject.cmake

@@ -243,7 +243,7 @@ message(STATUS \"downloading... done\")
 endfunction(_ep_write_downloadfile_script)
 
 
-function(_ep_write_extractfile_script script_filename filename tmp directory)
+function(_ep_write_extractfile_script script_filename filename directory)
   set(args "")
 
   if(filename MATCHES ".tar$")
@@ -267,7 +267,6 @@ function(_ep_write_extractfile_script script_filename filename tmp directory)
 "# Make file names absolute:
 #
 get_filename_component(filename \"${filename}\" ABSOLUTE)
-get_filename_component(tmp \"${tmp}\" ABSOLUTE)
 get_filename_component(directory \"${directory}\" ABSOLUTE)
 
 message(STATUS \"extracting...
@@ -276,11 +275,11 @@ message(STATUS \"extracting...
 
 # Prepare a space for extracting:
 #
-set(i 1)
-while(EXISTS \"\${tmp}/extract\${i}\")
+set(i 1234)
+while(EXISTS \"\${directory}/../ex\${i}\")
   math(EXPR i \"\${i} + 1\")
 endwhile()
-set(ut_dir \"\${tmp}/extract\${i}\")
+set(ut_dir \"\${directory}/../ex\${i}\")
 file(MAKE_DIRECTORY \"\${ut_dir}\")
 
 # Extract it:
@@ -305,10 +304,12 @@ if(NOT n EQUAL 1 OR NOT IS_DIRECTORY \"\${contents}\")
   set(contents \"\${ut_dir}\")
 endif()
 
-# Copy \"the one\" directory to the final directory:
+# Move \"the one\" directory to the final directory:
 #
-message(STATUS \"extracting... [copy]\")
-file(COPY \"\${contents}/\" DESTINATION \${directory})
+message(STATUS \"extracting... [rename]\")
+file(REMOVE_RECURSE \${directory})
+get_filename_component(contents \${contents} ABSOLUTE)
+file(RENAME \${contents} \${directory})
 
 # Clean up:
 #
@@ -710,7 +711,7 @@ function(_ep_add_download_command name)
         set(comment "Performing download step (extract) for '${name}'")
       endif()
       # TODO: Support other archive formats.
-      _ep_write_extractfile_script("${stamp_dir}/extract-${name}.cmake" "${file}" "${tmp_dir}" "${source_dir}")
+      _ep_write_extractfile_script("${stamp_dir}/extract-${name}.cmake" "${file}" "${source_dir}")
       list(APPEND cmd ${CMAKE_COMMAND} -P ${stamp_dir}/extract-${name}.cmake)
     endif()
   else()