Mercurial > hg > orthanc
annotate Resources/CMake/DownloadPackage.cmake @ 3725:8060880d5e66
fix openssl
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 06 Mar 2020 10:56:24 +0100 |
parents | f5fe6d08f910 |
children | ffd20cdfa82c |
rev | line source |
---|---|
735 | 1 macro(GetUrlFilename TargetVariable Url) |
2 string(REGEX REPLACE "^.*/" "" ${TargetVariable} "${Url}") | |
3 endmacro() | |
4 | |
5 | |
6 macro(GetUrlExtension TargetVariable Url) | |
7 #string(REGEX REPLACE "^.*/[^.]*\\." "" TMP "${Url}") | |
8 string(REGEX REPLACE "^.*\\." "" TMP "${Url}") | |
9 string(TOLOWER "${TMP}" "${TargetVariable}") | |
10 endmacro() | |
11 | |
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 | 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 | 35 ## |
36 ## Check the existence of the required decompression tools | |
37 ## | |
38 | |
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 | 46 if (${ZIP_EXECUTABLE} MATCHES "ZIP_EXECUTABLE-NOTFOUND") |
47 message(FATAL_ERROR "Please install the '7-zip' software (http://www.7-zip.org/)") | |
48 endif() | |
49 | |
50 else() | |
51 find_program(UNZIP_EXECUTABLE unzip) | |
52 if (${UNZIP_EXECUTABLE} MATCHES "UNZIP_EXECUTABLE-NOTFOUND") | |
53 message(FATAL_ERROR "Please install the 'unzip' package") | |
54 endif() | |
55 | |
56 find_program(TAR_EXECUTABLE tar) | |
57 if (${TAR_EXECUTABLE} MATCHES "TAR_EXECUTABLE-NOTFOUND") | |
58 message(FATAL_ERROR "Please install the 'tar' package") | |
59 endif() | |
3242
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
60 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
61 find_program(GUNZIP_EXECUTABLE gunzip) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
62 if (${GUNZIP_EXECUTABLE} MATCHES "GUNZIP_EXECUTABLE-NOTFOUND") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
63 message(FATAL_ERROR "Please install the 'gzip' package") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
64 endif() |
735 | 65 endif() |
66 | |
67 | |
3242
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
68 macro(DownloadFile MD5 Url) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
69 GetUrlFilename(TMP_FILENAME "${Url}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
70 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
71 set(TMP_PATH "${CMAKE_SOURCE_DIR}/ThirdPartyDownloads/${TMP_FILENAME}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
72 if (NOT EXISTS "${TMP_PATH}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
73 message("Downloading ${Url}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
74 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
75 # This fixes issue 6: "I think cmake shouldn't download the |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
76 # packages which are not in the system, it should stop and let |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
77 # user know." |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
78 # https://code.google.com/p/orthanc/issues/detail?id=6 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
79 if (NOT STATIC_BUILD AND NOT ALLOW_DOWNLOADS) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
80 message(FATAL_ERROR "CMake is not allowed to download from Internet. Please set the ALLOW_DOWNLOADS option to ON") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
81 endif() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
82 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
83 if ("${MD5}" STREQUAL "no-check") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
84 message(WARNING "Not checking the MD5 of: ${Url}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
85 file(DOWNLOAD "${Url}" "${TMP_PATH}" |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
86 SHOW_PROGRESS TIMEOUT 300 INACTIVITY_TIMEOUT 60 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
87 STATUS Failure) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
88 else() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
89 file(DOWNLOAD "${Url}" "${TMP_PATH}" |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
90 SHOW_PROGRESS TIMEOUT 300 INACTIVITY_TIMEOUT 60 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
91 EXPECTED_MD5 "${MD5}" STATUS Failure) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
92 endif() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
93 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
94 list(GET Failure 0 Status) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
95 if (NOT Status EQUAL 0) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
96 message(FATAL_ERROR "Cannot download file: ${Url}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
97 endif() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
98 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
99 else() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
100 message("Using local copy of ${Url}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
101 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
102 if ("${MD5}" STREQUAL "no-check") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
103 message(WARNING "Not checking the MD5 of: ${Url}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
104 else() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
105 file(MD5 ${TMP_PATH} ActualMD5) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
106 if (NOT "${ActualMD5}" STREQUAL "${MD5}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
107 message(FATAL_ERROR "The MD5 hash of a previously download file is invalid: ${TMP_PATH}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
108 endif() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
109 endif() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
110 endif() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
111 endmacro() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
112 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
113 |
735 | 114 macro(DownloadPackage MD5 Url TargetDirectory) |
115 if (NOT IS_DIRECTORY "${TargetDirectory}") | |
3242
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
116 DownloadFile("${MD5}" "${Url}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
117 |
735 | 118 GetUrlExtension(TMP_EXTENSION "${Url}") |
119 #message(${TMP_EXTENSION}) | |
120 message("Uncompressing ${TMP_FILENAME}") | |
121 | |
122 if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") | |
123 # How to silently extract files using 7-zip | |
124 # http://superuser.com/questions/331148/7zip-command-line-extract-silently-quietly | |
125 | |
2001
1d3a7c7d84c1
download of xz packages
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1543
diff
changeset
|
126 if (("${TMP_EXTENSION}" STREQUAL "gz") OR |
1d3a7c7d84c1
download of xz packages
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1543
diff
changeset
|
127 ("${TMP_EXTENSION}" STREQUAL "tgz") OR |
1d3a7c7d84c1
download of xz packages
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1543
diff
changeset
|
128 ("${TMP_EXTENSION}" STREQUAL "xz")) |
735 | 129 execute_process( |
130 COMMAND ${ZIP_EXECUTABLE} e -y ${TMP_PATH} | |
131 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | |
132 RESULT_VARIABLE Failure | |
133 OUTPUT_QUIET | |
134 ) | |
135 | |
136 if (Failure) | |
137 message(FATAL_ERROR "Error while running the uncompression tool") | |
138 endif() | |
139 | |
140 if ("${TMP_EXTENSION}" STREQUAL "tgz") | |
141 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
|
142 elseif ("${TMP_EXTENSION}" STREQUAL "gz") |
735 | 143 string(REGEX REPLACE ".gz$" "" TMP_FILENAME2 "${TMP_FILENAME}") |
2001
1d3a7c7d84c1
download of xz packages
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1543
diff
changeset
|
144 elseif ("${TMP_EXTENSION}" STREQUAL "xz") |
1d3a7c7d84c1
download of xz packages
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1543
diff
changeset
|
145 string(REGEX REPLACE ".xz" "" TMP_FILENAME2 "${TMP_FILENAME}") |
735 | 146 endif() |
147 | |
148 execute_process( | |
149 COMMAND ${ZIP_EXECUTABLE} x -y ${TMP_FILENAME2} | |
150 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | |
151 RESULT_VARIABLE Failure | |
152 OUTPUT_QUIET | |
153 ) | |
154 elseif ("${TMP_EXTENSION}" STREQUAL "zip") | |
155 execute_process( | |
156 COMMAND ${ZIP_EXECUTABLE} x -y ${TMP_PATH} | |
157 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | |
158 RESULT_VARIABLE Failure | |
159 OUTPUT_QUIET | |
160 ) | |
161 else() | |
3242
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
162 message(FATAL_ERROR "Unsupported package extension: ${TMP_EXTENSION}") |
735 | 163 endif() |
164 | |
165 else() | |
166 if ("${TMP_EXTENSION}" STREQUAL "zip") | |
167 execute_process( | |
168 COMMAND sh -c "${UNZIP_EXECUTABLE} -q ${TMP_PATH}" | |
169 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | |
170 RESULT_VARIABLE Failure | |
171 ) | |
172 elseif (("${TMP_EXTENSION}" STREQUAL "gz") OR ("${TMP_EXTENSION}" STREQUAL "tgz")) | |
173 #message("tar xvfz ${TMP_PATH}") | |
174 execute_process( | |
175 COMMAND sh -c "${TAR_EXECUTABLE} xfz ${TMP_PATH}" | |
176 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | |
177 RESULT_VARIABLE Failure | |
178 ) | |
179 elseif ("${TMP_EXTENSION}" STREQUAL "bz2") | |
180 execute_process( | |
181 COMMAND sh -c "${TAR_EXECUTABLE} xfj ${TMP_PATH}" | |
182 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | |
183 RESULT_VARIABLE Failure | |
184 ) | |
2002 | 185 elseif ("${TMP_EXTENSION}" STREQUAL "xz") |
186 execute_process( | |
187 COMMAND sh -c "${TAR_EXECUTABLE} xf ${TMP_PATH}" | |
188 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | |
189 RESULT_VARIABLE Failure | |
190 ) | |
735 | 191 else() |
3242
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
192 message(FATAL_ERROR "Unsupported package extension: ${TMP_EXTENSION}") |
735 | 193 endif() |
194 endif() | |
195 | |
196 if (Failure) | |
197 message(FATAL_ERROR "Error while running the uncompression tool") | |
198 endif() | |
199 | |
200 if (NOT IS_DIRECTORY "${TargetDirectory}") | |
201 message(FATAL_ERROR "The package was not uncompressed at the proper location. Check the CMake instructions.") | |
202 endif() | |
203 endif() | |
204 endmacro() | |
3242
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
205 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
206 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
207 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
208 macro(DownloadCompressedFile MD5 Url TargetFile) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
209 message(${MD5}) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
210 message(${Url}) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
211 message(${TargetFile}) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
212 if (NOT EXISTS "${TargetFile}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
213 DownloadFile("${MD5}" "${Url}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
214 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
215 GetUrlExtension(TMP_EXTENSION "${Url}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
216 #message(${TMP_EXTENSION}) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
217 message("Uncompressing ${TMP_FILENAME}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
218 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
219 if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
220 # How to silently extract files using 7-zip |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
221 # http://superuser.com/questions/331148/7zip-command-line-extract-silently-quietly |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
222 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
223 if ("${TMP_EXTENSION}" STREQUAL "gz") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
224 execute_process( |
3423
f5fe6d08f910
improving single file uncompression on Windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3242
diff
changeset
|
225 # "-so" writes uncompressed file to stdout |
f5fe6d08f910
improving single file uncompression on Windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3242
diff
changeset
|
226 COMMAND ${ZIP_EXECUTABLE} e -so -y ${TMP_PATH} |
f5fe6d08f910
improving single file uncompression on Windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3242
diff
changeset
|
227 OUTPUT_FILE "${TargetFile}" |
3242
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
228 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
229 RESULT_VARIABLE Failure |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
230 OUTPUT_QUIET |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
231 ) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
232 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
233 if (Failure) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
234 message(FATAL_ERROR "Error while running the uncompression tool") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
235 endif() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
236 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
237 else() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
238 message(FATAL_ERROR "Unsupported file extension: ${TMP_EXTENSION}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
239 endif() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
240 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
241 else() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
242 if ("${TMP_EXTENSION}" STREQUAL "gz") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
243 execute_process( |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
244 COMMAND sh -c "${GUNZIP_EXECUTABLE} -c ${TMP_PATH}" |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
245 OUTPUT_FILE "${TargetFile}" |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
246 RESULT_VARIABLE Failure |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
247 ) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
248 else() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
249 message(FATAL_ERROR "Unsupported file extension: ${TMP_EXTENSION}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
250 endif() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
251 endif() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
252 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
253 if (Failure) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
254 message(FATAL_ERROR "Error while running the uncompression tool") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
255 endif() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
256 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
257 if (NOT EXISTS "${TargetFile}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
258 message(FATAL_ERROR "The file was not uncompressed at the proper location. Check the CMake instructions.") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
259 endif() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
260 endif() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
261 endmacro() |