annotate Resources/CMake/DownloadPackage.cmake @ 3137:5a3b961e9524

New configuration option: 'TcpNoDelay' to disable Nagle's algorithm in HTTP server
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 17 Jan 2019 18:24:23 +0100
parents f5ce33d3295c
children 5d78df37c62f
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
1 macro(GetUrlFilename TargetVariable Url)
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
2 string(REGEX REPLACE "^.*/" "" ${TargetVariable} "${Url}")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
3 endmacro()
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
4
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
5
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
6 macro(GetUrlExtension TargetVariable Url)
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
7 #string(REGEX REPLACE "^.*/[^.]*\\." "" TMP "${Url}")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
8 string(REGEX REPLACE "^.*\\." "" TMP "${Url}")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
9 string(TOLOWER "${TMP}" "${TargetVariable}")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
10 endmacro()
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
11
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
12
1537
fbf763bb1fa3 error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1111
diff changeset
13
fbf763bb1fa3 error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1111
diff changeset
14 ##
fbf763bb1fa3 error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1111
diff changeset
15 ## Setup the patch command-line tool
fbf763bb1fa3 error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1111
diff changeset
16 ##
fbf763bb1fa3 error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1111
diff changeset
17
2130
72cb107a7346 option ORTHANC_DISABLE_PATCH
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2111
diff changeset
18 if (NOT ORTHANC_DISABLE_PATCH)
72cb107a7346 option ORTHANC_DISABLE_PATCH
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2111
diff changeset
19 if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
72cb107a7346 option ORTHANC_DISABLE_PATCH
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2111
diff changeset
20 set(PATCH_EXECUTABLE ${CMAKE_CURRENT_LIST_DIR}/../ThirdParty/patch/patch.exe)
72cb107a7346 option ORTHANC_DISABLE_PATCH
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2111
diff changeset
21 if (NOT EXISTS ${PATCH_EXECUTABLE})
72cb107a7346 option ORTHANC_DISABLE_PATCH
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2111
diff changeset
22 message(FATAL_ERROR "Unable to find the patch.exe tool that is shipped with Orthanc")
72cb107a7346 option ORTHANC_DISABLE_PATCH
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2111
diff changeset
23 endif()
2111
64d0224595cc more generic path
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2002
diff changeset
24
2130
72cb107a7346 option ORTHANC_DISABLE_PATCH
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2111
diff changeset
25 else ()
72cb107a7346 option ORTHANC_DISABLE_PATCH
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2111
diff changeset
26 find_program(PATCH_EXECUTABLE patch)
72cb107a7346 option ORTHANC_DISABLE_PATCH
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2111
diff changeset
27 if (${PATCH_EXECUTABLE} MATCHES "PATCH_EXECUTABLE-NOTFOUND")
72cb107a7346 option ORTHANC_DISABLE_PATCH
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2111
diff changeset
28 message(FATAL_ERROR "Please install the 'patch' standard command-line tool")
72cb107a7346 option ORTHANC_DISABLE_PATCH
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2111
diff changeset
29 endif()
1537
fbf763bb1fa3 error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1111
diff changeset
30 endif()
fbf763bb1fa3 error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1111
diff changeset
31 endif()
fbf763bb1fa3 error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1111
diff changeset
32
fbf763bb1fa3 error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1111
diff changeset
33
fbf763bb1fa3 error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1111
diff changeset
34
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
35 ##
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
36 ## Check the existence of the required decompression tools
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
37 ##
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
38
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
39 if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
1111
929bf8c2123d Fixes for Visual Studio 2013 64bit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 735
diff changeset
40 find_program(ZIP_EXECUTABLE 7z
929bf8c2123d Fixes for Visual Studio 2013 64bit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 735
diff changeset
41 PATHS
929bf8c2123d Fixes for Visual Studio 2013 64bit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 735
diff changeset
42 "$ENV{ProgramFiles}/7-Zip"
929bf8c2123d Fixes for Visual Studio 2013 64bit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 735
diff changeset
43 "$ENV{ProgramW6432}/7-Zip"
929bf8c2123d Fixes for Visual Studio 2013 64bit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 735
diff changeset
44 )
929bf8c2123d Fixes for Visual Studio 2013 64bit
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 735
diff changeset
45
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
46 if (${ZIP_EXECUTABLE} MATCHES "ZIP_EXECUTABLE-NOTFOUND")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
47 message(FATAL_ERROR "Please install the '7-zip' software (http://www.7-zip.org/)")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
48 endif()
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
49
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
50 else()
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
51 find_program(UNZIP_EXECUTABLE unzip)
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
52 if (${UNZIP_EXECUTABLE} MATCHES "UNZIP_EXECUTABLE-NOTFOUND")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
53 message(FATAL_ERROR "Please install the 'unzip' package")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
54 endif()
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
55
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
56 find_program(TAR_EXECUTABLE tar)
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
57 if (${TAR_EXECUTABLE} MATCHES "TAR_EXECUTABLE-NOTFOUND")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
58 message(FATAL_ERROR "Please install the 'tar' package")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
59 endif()
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
60 endif()
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
61
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
62
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
63 macro(DownloadPackage MD5 Url TargetDirectory)
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
64 if (NOT IS_DIRECTORY "${TargetDirectory}")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
65 GetUrlFilename(TMP_FILENAME "${Url}")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
66
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
67 set(TMP_PATH "${CMAKE_SOURCE_DIR}/ThirdPartyDownloads/${TMP_FILENAME}")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
68 if (NOT EXISTS "${TMP_PATH}")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
69 message("Downloading ${Url}")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
70
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
71 # This fixes issue 6: "I think cmake shouldn't download the
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
72 # packages which are not in the system, it should stop and let
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
73 # user know."
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
74 # https://code.google.com/p/orthanc/issues/detail?id=6
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
75 if (NOT STATIC_BUILD AND NOT ALLOW_DOWNLOADS)
2855
706da802f1e3 fix checking of MD5 in CMake, new option "no-check" for MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2852
diff changeset
76 message(FATAL_ERROR "CMake is not allowed to download from Internet. Please set the ALLOW_DOWNLOADS option to ON")
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
77 endif()
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
78
2855
706da802f1e3 fix checking of MD5 in CMake, new option "no-check" for MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2852
diff changeset
79 if ("${MD5}" STREQUAL "no-check")
706da802f1e3 fix checking of MD5 in CMake, new option "no-check" for MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2852
diff changeset
80 message(WARNING "Not checking the MD5 of: ${Url}")
2890
f5ce33d3295c increased DownloadPackage Timeout since we've seen that 60sec is not always enough
am@osimis.io
parents: 2855
diff changeset
81 file(DOWNLOAD "${Url}" "${TMP_PATH}" SHOW_PROGRESS TIMEOUT 300 INACTIVITY_TIMEOUT 60)
2855
706da802f1e3 fix checking of MD5 in CMake, new option "no-check" for MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2852
diff changeset
82 else()
2890
f5ce33d3295c increased DownloadPackage Timeout since we've seen that 60sec is not always enough
am@osimis.io
parents: 2855
diff changeset
83 file(DOWNLOAD "${Url}" "${TMP_PATH}" SHOW_PROGRESS TIMEOUT 300 INACTIVITY_TIMEOUT 60 EXPECTED_MD5 "${MD5}")
2852
d4f44a8028a1 allow passing FALSE as expeted MD5 in DownloadPackage when we don't wan't to check the MD5
am@osimis.io
parents: 2530
diff changeset
84 endif()
d4f44a8028a1 allow passing FALSE as expeted MD5 in DownloadPackage when we don't wan't to check the MD5
am@osimis.io
parents: 2530
diff changeset
85
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
86 else()
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
87 message("Using local copy of ${Url}")
2530
3eda46f91834 check md5 of previously downloaded files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2154
diff changeset
88
2855
706da802f1e3 fix checking of MD5 in CMake, new option "no-check" for MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2852
diff changeset
89 if ("${MD5}" STREQUAL "no-check")
706da802f1e3 fix checking of MD5 in CMake, new option "no-check" for MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2852
diff changeset
90 message(WARNING "Not checking the MD5 of: ${Url}")
706da802f1e3 fix checking of MD5 in CMake, new option "no-check" for MD5
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2852
diff changeset
91 else()
2852
d4f44a8028a1 allow passing FALSE as expeted MD5 in DownloadPackage when we don't wan't to check the MD5
am@osimis.io
parents: 2530
diff changeset
92 file(MD5 ${TMP_PATH} ActualMD5)
d4f44a8028a1 allow passing FALSE as expeted MD5 in DownloadPackage when we don't wan't to check the MD5
am@osimis.io
parents: 2530
diff changeset
93 if (NOT "${ActualMD5}" STREQUAL "${MD5}")
d4f44a8028a1 allow passing FALSE as expeted MD5 in DownloadPackage when we don't wan't to check the MD5
am@osimis.io
parents: 2530
diff changeset
94 message(FATAL_ERROR "The MD5 hash of a previously download file is invalid: ${TMP_PATH}")
d4f44a8028a1 allow passing FALSE as expeted MD5 in DownloadPackage when we don't wan't to check the MD5
am@osimis.io
parents: 2530
diff changeset
95 endif()
2530
3eda46f91834 check md5 of previously downloaded files
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2154
diff changeset
96 endif()
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
97 endif()
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
98
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
99 GetUrlExtension(TMP_EXTENSION "${Url}")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
100 #message(${TMP_EXTENSION})
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
101 message("Uncompressing ${TMP_FILENAME}")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
102
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
103 if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
104 # How to silently extract files using 7-zip
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
105 # http://superuser.com/questions/331148/7zip-command-line-extract-silently-quietly
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
106
2001
1d3a7c7d84c1 download of xz packages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1543
diff changeset
107 if (("${TMP_EXTENSION}" STREQUAL "gz") OR
1d3a7c7d84c1 download of xz packages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1543
diff changeset
108 ("${TMP_EXTENSION}" STREQUAL "tgz") OR
1d3a7c7d84c1 download of xz packages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1543
diff changeset
109 ("${TMP_EXTENSION}" STREQUAL "xz"))
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
110 execute_process(
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
111 COMMAND ${ZIP_EXECUTABLE} e -y ${TMP_PATH}
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
112 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
113 RESULT_VARIABLE Failure
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
114 OUTPUT_QUIET
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
115 )
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
116
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
117 if (Failure)
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
118 message(FATAL_ERROR "Error while running the uncompression tool")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
119 endif()
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
120
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
121 if ("${TMP_EXTENSION}" STREQUAL "tgz")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
122 string(REGEX REPLACE ".tgz$" ".tar" TMP_FILENAME2 "${TMP_FILENAME}")
2001
1d3a7c7d84c1 download of xz packages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1543
diff changeset
123 elseif ("${TMP_EXTENSION}" STREQUAL "gz")
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
124 string(REGEX REPLACE ".gz$" "" TMP_FILENAME2 "${TMP_FILENAME}")
2001
1d3a7c7d84c1 download of xz packages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1543
diff changeset
125 elseif ("${TMP_EXTENSION}" STREQUAL "xz")
1d3a7c7d84c1 download of xz packages
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 1543
diff changeset
126 string(REGEX REPLACE ".xz" "" TMP_FILENAME2 "${TMP_FILENAME}")
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
127 endif()
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
128
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
129 execute_process(
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
130 COMMAND ${ZIP_EXECUTABLE} x -y ${TMP_FILENAME2}
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
131 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
132 RESULT_VARIABLE Failure
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
133 OUTPUT_QUIET
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
134 )
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
135 elseif ("${TMP_EXTENSION}" STREQUAL "zip")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
136 execute_process(
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
137 COMMAND ${ZIP_EXECUTABLE} x -y ${TMP_PATH}
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
138 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
139 RESULT_VARIABLE Failure
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
140 OUTPUT_QUIET
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
141 )
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
142 else()
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
143 message(FATAL_ERROR "Support your platform here")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
144 endif()
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
145
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
146 else()
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
147 if ("${TMP_EXTENSION}" STREQUAL "zip")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
148 execute_process(
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
149 COMMAND sh -c "${UNZIP_EXECUTABLE} -q ${TMP_PATH}"
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
150 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
151 RESULT_VARIABLE Failure
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
152 )
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
153 elseif (("${TMP_EXTENSION}" STREQUAL "gz") OR ("${TMP_EXTENSION}" STREQUAL "tgz"))
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
154 #message("tar xvfz ${TMP_PATH}")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
155 execute_process(
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
156 COMMAND sh -c "${TAR_EXECUTABLE} xfz ${TMP_PATH}"
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
157 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
158 RESULT_VARIABLE Failure
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
159 )
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
160 elseif ("${TMP_EXTENSION}" STREQUAL "bz2")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
161 execute_process(
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
162 COMMAND sh -c "${TAR_EXECUTABLE} xfj ${TMP_PATH}"
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
163 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
164 RESULT_VARIABLE Failure
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
165 )
2002
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2001
diff changeset
166 elseif ("${TMP_EXTENSION}" STREQUAL "xz")
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2001
diff changeset
167 execute_process(
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2001
diff changeset
168 COMMAND sh -c "${TAR_EXECUTABLE} xf ${TMP_PATH}"
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2001
diff changeset
169 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2001
diff changeset
170 RESULT_VARIABLE Failure
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 2001
diff changeset
171 )
735
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
172 else()
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
173 message(FATAL_ERROR "Unknown package format.")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
174 endif()
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
175 endif()
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
176
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
177 if (Failure)
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
178 message(FATAL_ERROR "Error while running the uncompression tool")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
179 endif()
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
180
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
181 if (NOT IS_DIRECTORY "${TargetDirectory}")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
182 message(FATAL_ERROR "The package was not uncompressed at the proper location. Check the CMake instructions.")
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
183 endif()
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
184 endif()
ee0d5abf7958 dos2unix
Sebastien Jodogne <s.jodogne@gmail.com>
parents: 634
diff changeset
185 endmacro()