comparison Resources/CMake/DownloadPackage.cmake @ 2:67a6978503b7

fixing Windows build
author Jodogne@Laptop
date Thu, 19 Jul 2012 22:33:27 +0200
parents 3959d33612cc
children 29bfa3095207
comparison
equal deleted inserted replaced
0:3959d33612cc 2:67a6978503b7
47 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} 47 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
48 ) 48 )
49 else() 49 else()
50 message(FATAL_ERROR "Unknown package format.") 50 message(FATAL_ERROR "Unknown package format.")
51 endif() 51 endif()
52
53 elseif ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
54 FIND_PROGRAM(ZIP_EXECUTABLE 7z PATHS "$ENV{ProgramFiles}/7-Zip")
55
56 if (("${TMP_EXTENSION}" STREQUAL "gz") OR ("${TMP_EXTENSION}" STREQUAL "tgz"))
57 execute_process(
58 COMMAND ${ZIP_EXECUTABLE} e ${TMP_PATH}
59 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
60 )
61 set(ARGS ${UncompressArguments})
62 SEPARATE_ARGUMENTS(ARGS)
63 list(LENGTH ARGS TMP_LENGTH)
64
65 if ("${TMP_EXTENSION}" STREQUAL "tgz")
66 string(REGEX REPLACE ".tgz$" ".tar" TMP_FILENAME2 "${TMP_FILENAME}")
67 else()
68 string(REGEX REPLACE ".gz$" "" TMP_FILENAME2 "${TMP_FILENAME}")
69 endif()
70
71 if (TMP_LENGTH EQUAL 0)
72 execute_process(
73 COMMAND ${ZIP_EXECUTABLE} x ${TMP_FILENAME2}
74 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
75 )
76 else()
77 foreach(SUBDIR ${ARGS})
78 execute_process(
79 COMMAND ${ZIP_EXECUTABLE} x "-i!${SUBDIR}" "${TMP_FILENAME2}"
80 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
81 )
82 endforeach()
83 endif()
84 elseif ("${TMP_EXTENSION}" STREQUAL "zip")
85 execute_process(
86 COMMAND ${ZIP_EXECUTABLE} x ${TMP_PATH}
87 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
88 )
89 else()
90 message(FATAL_ERROR "Support your platform here")
91 endif()
52 else() 92 else()
53 message(FATAL_ERROR "Support your platform here") 93 message(FATAL_ERROR "Support your platform here")
54 endif() 94 endif()
55 95
56 if (NOT IS_DIRECTORY "${TargetDirectory}") 96 if (NOT IS_DIRECTORY "${TargetDirectory}")