Mercurial > hg > orthanc
annotate OrthancFramework/Resources/CMake/DownloadPackage.cmake @ 5858:66fd63b8601e find-refactoring tip
StorageAccessOnFind: cont
author | Alain Mazy <am@orthanc.team> |
---|---|
date | Mon, 04 Nov 2024 22:34:14 +0100 |
parents | f7adfb22e20e |
children |
rev | line source |
---|---|
4120
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4115
diff
changeset
|
1 # Orthanc - A Lightweight, RESTful DICOM Store |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4115
diff
changeset
|
2 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4115
diff
changeset
|
3 # Department, University Hospital of Liege, Belgium |
5640
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
4 # Copyright (C) 2017-2023 Osimis S.A., Belgium |
f7adfb22e20e
updated copyright, as Orthanc Team now replaces Osimis
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5485
diff
changeset
|
5 # Copyright (C) 2024-2024 Orthanc Team SRL, Belgium |
5485
48b8dae6dc77
upgrade to year 2024
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5282
diff
changeset
|
6 # Copyright (C) 2021-2024 Sebastien Jodogne, ICTEAM UCLouvain, Belgium |
4120
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4115
diff
changeset
|
7 # |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4115
diff
changeset
|
8 # This program is free software: you can redistribute it and/or |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4115
diff
changeset
|
9 # modify it under the terms of the GNU Lesser General Public License |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4115
diff
changeset
|
10 # as published by the Free Software Foundation, either version 3 of |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4115
diff
changeset
|
11 # the License, or (at your option) any later version. |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4115
diff
changeset
|
12 # |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4115
diff
changeset
|
13 # This program is distributed in the hope that it will be useful, but |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4115
diff
changeset
|
14 # WITHOUT ANY WARRANTY; without even the implied warranty of |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4115
diff
changeset
|
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4115
diff
changeset
|
16 # Lesser General Public License for more details. |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4115
diff
changeset
|
17 # |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4115
diff
changeset
|
18 # You should have received a copy of the GNU Lesser General Public |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4115
diff
changeset
|
19 # License along with this program. If not, see |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4115
diff
changeset
|
20 # <http://www.gnu.org/licenses/>. |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4115
diff
changeset
|
21 |
304842a0d152
adding missing license headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
4115
diff
changeset
|
22 |
735 | 23 macro(GetUrlFilename TargetVariable Url) |
24 string(REGEX REPLACE "^.*/" "" ${TargetVariable} "${Url}") | |
25 endmacro() | |
26 | |
27 | |
28 macro(GetUrlExtension TargetVariable Url) | |
29 #string(REGEX REPLACE "^.*/[^.]*\\." "" TMP "${Url}") | |
30 string(REGEX REPLACE "^.*\\." "" TMP "${Url}") | |
31 string(TOLOWER "${TMP}" "${TargetVariable}") | |
32 endmacro() | |
33 | |
34 | |
1537
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1111
diff
changeset
|
35 |
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1111
diff
changeset
|
36 ## |
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1111
diff
changeset
|
37 ## Setup the patch command-line tool |
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1111
diff
changeset
|
38 ## |
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1111
diff
changeset
|
39 |
2130
72cb107a7346
option ORTHANC_DISABLE_PATCH
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2111
diff
changeset
|
40 if (NOT ORTHANC_DISABLE_PATCH) |
72cb107a7346
option ORTHANC_DISABLE_PATCH
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2111
diff
changeset
|
41 if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") |
72cb107a7346
option ORTHANC_DISABLE_PATCH
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2111
diff
changeset
|
42 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
|
43 if (NOT EXISTS ${PATCH_EXECUTABLE}) |
72cb107a7346
option ORTHANC_DISABLE_PATCH
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2111
diff
changeset
|
44 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
|
45 endif() |
2111 | 46 |
2130
72cb107a7346
option ORTHANC_DISABLE_PATCH
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2111
diff
changeset
|
47 else () |
72cb107a7346
option ORTHANC_DISABLE_PATCH
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2111
diff
changeset
|
48 find_program(PATCH_EXECUTABLE patch) |
72cb107a7346
option ORTHANC_DISABLE_PATCH
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2111
diff
changeset
|
49 if (${PATCH_EXECUTABLE} MATCHES "PATCH_EXECUTABLE-NOTFOUND") |
72cb107a7346
option ORTHANC_DISABLE_PATCH
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2111
diff
changeset
|
50 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
|
51 endif() |
1537
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1111
diff
changeset
|
52 endif() |
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1111
diff
changeset
|
53 endif() |
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1111
diff
changeset
|
54 |
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1111
diff
changeset
|
55 |
fbf763bb1fa3
error detection in patches
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1111
diff
changeset
|
56 |
735 | 57 ## |
58 ## Check the existence of the required decompression tools | |
59 ## | |
60 | |
61 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
|
62 find_program(ZIP_EXECUTABLE 7z |
929bf8c2123d
Fixes for Visual Studio 2013 64bit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
735
diff
changeset
|
63 PATHS |
929bf8c2123d
Fixes for Visual Studio 2013 64bit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
735
diff
changeset
|
64 "$ENV{ProgramFiles}/7-Zip" |
929bf8c2123d
Fixes for Visual Studio 2013 64bit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
735
diff
changeset
|
65 "$ENV{ProgramW6432}/7-Zip" |
929bf8c2123d
Fixes for Visual Studio 2013 64bit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
735
diff
changeset
|
66 ) |
929bf8c2123d
Fixes for Visual Studio 2013 64bit
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
735
diff
changeset
|
67 |
735 | 68 if (${ZIP_EXECUTABLE} MATCHES "ZIP_EXECUTABLE-NOTFOUND") |
69 message(FATAL_ERROR "Please install the '7-zip' software (http://www.7-zip.org/)") | |
70 endif() | |
71 | |
72 else() | |
73 find_program(UNZIP_EXECUTABLE unzip) | |
74 if (${UNZIP_EXECUTABLE} MATCHES "UNZIP_EXECUTABLE-NOTFOUND") | |
75 message(FATAL_ERROR "Please install the 'unzip' package") | |
76 endif() | |
77 | |
78 find_program(TAR_EXECUTABLE tar) | |
79 if (${TAR_EXECUTABLE} MATCHES "TAR_EXECUTABLE-NOTFOUND") | |
80 message(FATAL_ERROR "Please install the 'tar' package") | |
81 endif() | |
3242
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 find_program(GUNZIP_EXECUTABLE gunzip) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
84 if (${GUNZIP_EXECUTABLE} MATCHES "GUNZIP_EXECUTABLE-NOTFOUND") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
85 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
|
86 endif() |
735 | 87 endif() |
88 | |
89 | |
3242
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
90 macro(DownloadFile MD5 Url) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
91 GetUrlFilename(TMP_FILENAME "${Url}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
92 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
93 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
|
94 if (NOT EXISTS "${TMP_PATH}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
95 message("Downloading ${Url}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
96 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
97 # 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
|
98 # 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
|
99 # user know." |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
100 # 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
|
101 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
|
102 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
|
103 endif() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
104 |
5282
13815a13b5c9
implemented retries in DownloadPackage.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
105 foreach (retry RANGE 1 5) # Retries 5 times |
13815a13b5c9
implemented retries in DownloadPackage.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
106 if ("${MD5}" STREQUAL "no-check") |
13815a13b5c9
implemented retries in DownloadPackage.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
107 message(WARNING "Not checking the MD5 of: ${Url}") |
13815a13b5c9
implemented retries in DownloadPackage.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
108 file(DOWNLOAD "${Url}" "${TMP_PATH}" |
13815a13b5c9
implemented retries in DownloadPackage.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
109 SHOW_PROGRESS TIMEOUT 30 INACTIVITY_TIMEOUT 10 |
13815a13b5c9
implemented retries in DownloadPackage.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
110 STATUS Failure) |
13815a13b5c9
implemented retries in DownloadPackage.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
111 else() |
13815a13b5c9
implemented retries in DownloadPackage.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
112 file(DOWNLOAD "${Url}" "${TMP_PATH}" |
13815a13b5c9
implemented retries in DownloadPackage.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
113 SHOW_PROGRESS TIMEOUT 30 INACTIVITY_TIMEOUT 10 |
13815a13b5c9
implemented retries in DownloadPackage.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
114 EXPECTED_MD5 "${MD5}" STATUS Failure) |
13815a13b5c9
implemented retries in DownloadPackage.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
115 endif() |
3242
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
116 |
5282
13815a13b5c9
implemented retries in DownloadPackage.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
117 list(GET Failure 0 Status) |
13815a13b5c9
implemented retries in DownloadPackage.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
118 if (Status EQUAL 0) |
13815a13b5c9
implemented retries in DownloadPackage.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
119 break() # Successful download |
13815a13b5c9
implemented retries in DownloadPackage.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
120 endif() |
13815a13b5c9
implemented retries in DownloadPackage.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
121 endforeach() |
13815a13b5c9
implemented retries in DownloadPackage.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
122 |
3242
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
123 if (NOT Status EQUAL 0) |
5282
13815a13b5c9
implemented retries in DownloadPackage.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
5185
diff
changeset
|
124 file(REMOVE ${TMP_PATH}) |
3242
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
125 message(FATAL_ERROR "Cannot download file: ${Url}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
126 endif() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
127 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
128 else() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
129 message("Using local copy of ${Url}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
130 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
131 if ("${MD5}" STREQUAL "no-check") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
132 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
|
133 else() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
134 file(MD5 ${TMP_PATH} ActualMD5) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
135 if (NOT "${ActualMD5}" STREQUAL "${MD5}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
136 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
|
137 endif() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
138 endif() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
139 endif() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
140 endmacro() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
141 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
142 |
735 | 143 macro(DownloadPackage MD5 Url TargetDirectory) |
144 if (NOT IS_DIRECTORY "${TargetDirectory}") | |
3242
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
145 DownloadFile("${MD5}" "${Url}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
146 |
735 | 147 GetUrlExtension(TMP_EXTENSION "${Url}") |
148 #message(${TMP_EXTENSION}) | |
149 message("Uncompressing ${TMP_FILENAME}") | |
150 | |
151 if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") | |
152 # How to silently extract files using 7-zip | |
153 # http://superuser.com/questions/331148/7zip-command-line-extract-silently-quietly | |
154 | |
2001
1d3a7c7d84c1
download of xz packages
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1543
diff
changeset
|
155 if (("${TMP_EXTENSION}" STREQUAL "gz") OR |
1d3a7c7d84c1
download of xz packages
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1543
diff
changeset
|
156 ("${TMP_EXTENSION}" STREQUAL "tgz") OR |
1d3a7c7d84c1
download of xz packages
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1543
diff
changeset
|
157 ("${TMP_EXTENSION}" STREQUAL "xz")) |
735 | 158 execute_process( |
159 COMMAND ${ZIP_EXECUTABLE} e -y ${TMP_PATH} | |
160 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | |
161 RESULT_VARIABLE Failure | |
162 OUTPUT_QUIET | |
163 ) | |
164 | |
165 if (Failure) | |
166 message(FATAL_ERROR "Error while running the uncompression tool") | |
167 endif() | |
168 | |
169 if ("${TMP_EXTENSION}" STREQUAL "tgz") | |
170 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
|
171 elseif ("${TMP_EXTENSION}" STREQUAL "gz") |
735 | 172 string(REGEX REPLACE ".gz$" "" TMP_FILENAME2 "${TMP_FILENAME}") |
2001
1d3a7c7d84c1
download of xz packages
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1543
diff
changeset
|
173 elseif ("${TMP_EXTENSION}" STREQUAL "xz") |
1d3a7c7d84c1
download of xz packages
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1543
diff
changeset
|
174 string(REGEX REPLACE ".xz" "" TMP_FILENAME2 "${TMP_FILENAME}") |
735 | 175 endif() |
176 | |
177 execute_process( | |
178 COMMAND ${ZIP_EXECUTABLE} x -y ${TMP_FILENAME2} | |
179 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | |
180 RESULT_VARIABLE Failure | |
181 OUTPUT_QUIET | |
182 ) | |
183 elseif ("${TMP_EXTENSION}" STREQUAL "zip") | |
184 execute_process( | |
185 COMMAND ${ZIP_EXECUTABLE} x -y ${TMP_PATH} | |
186 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | |
187 RESULT_VARIABLE Failure | |
188 OUTPUT_QUIET | |
189 ) | |
190 else() | |
3242
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
191 message(FATAL_ERROR "Unsupported package extension: ${TMP_EXTENSION}") |
735 | 192 endif() |
193 | |
194 else() | |
195 if ("${TMP_EXTENSION}" STREQUAL "zip") | |
196 execute_process( | |
197 COMMAND sh -c "${UNZIP_EXECUTABLE} -q ${TMP_PATH}" | |
198 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | |
199 RESULT_VARIABLE Failure | |
200 ) | |
201 elseif (("${TMP_EXTENSION}" STREQUAL "gz") OR ("${TMP_EXTENSION}" STREQUAL "tgz")) | |
202 #message("tar xvfz ${TMP_PATH}") | |
203 execute_process( | |
204 COMMAND sh -c "${TAR_EXECUTABLE} xfz ${TMP_PATH}" | |
205 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | |
206 RESULT_VARIABLE Failure | |
207 ) | |
208 elseif ("${TMP_EXTENSION}" STREQUAL "bz2") | |
209 execute_process( | |
210 COMMAND sh -c "${TAR_EXECUTABLE} xfj ${TMP_PATH}" | |
211 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | |
212 RESULT_VARIABLE Failure | |
213 ) | |
2002 | 214 elseif ("${TMP_EXTENSION}" STREQUAL "xz") |
215 execute_process( | |
216 COMMAND sh -c "${TAR_EXECUTABLE} xf ${TMP_PATH}" | |
217 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} | |
218 RESULT_VARIABLE Failure | |
219 ) | |
735 | 220 else() |
3242
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
221 message(FATAL_ERROR "Unsupported package extension: ${TMP_EXTENSION}") |
735 | 222 endif() |
223 endif() | |
224 | |
225 if (Failure) | |
226 message(FATAL_ERROR "Error while running the uncompression tool") | |
227 endif() | |
228 | |
229 if (NOT IS_DIRECTORY "${TargetDirectory}") | |
230 message(FATAL_ERROR "The package was not uncompressed at the proper location. Check the CMake instructions.") | |
231 endif() | |
232 endif() | |
233 endmacro() | |
3242
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
234 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
235 |
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 macro(DownloadCompressedFile MD5 Url TargetFile) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
238 if (NOT EXISTS "${TargetFile}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
239 DownloadFile("${MD5}" "${Url}") |
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 GetUrlExtension(TMP_EXTENSION "${Url}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
242 #message(${TMP_EXTENSION}) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
243 message("Uncompressing ${TMP_FILENAME}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
244 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
245 if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
246 # 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
|
247 # 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
|
248 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
249 if ("${TMP_EXTENSION}" STREQUAL "gz") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
250 execute_process( |
3423
f5fe6d08f910
improving single file uncompression on Windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3242
diff
changeset
|
251 # "-so" writes uncompressed file to stdout |
f5fe6d08f910
improving single file uncompression on Windows
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
3242
diff
changeset
|
252 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
|
253 OUTPUT_FILE "${TargetFile}" |
3242
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
254 WORKING_DIRECTORY ${CMAKE_BINARY_DIR} |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
255 RESULT_VARIABLE Failure |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
256 OUTPUT_QUIET |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
257 ) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
258 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
259 if (Failure) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
260 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
|
261 endif() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
262 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
263 else() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
264 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
|
265 endif() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
266 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
267 else() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
268 if ("${TMP_EXTENSION}" STREQUAL "gz") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
269 execute_process( |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
270 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
|
271 OUTPUT_FILE "${TargetFile}" |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
272 RESULT_VARIABLE Failure |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
273 ) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
274 else() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
275 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
|
276 endif() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
277 endif() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
278 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
279 if (Failure) |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
280 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
|
281 endif() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
282 |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
283 if (NOT EXISTS "${TargetFile}") |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
284 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
|
285 endif() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
286 endif() |
5d78df37c62f
automating compilation if icu is used
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
2890
diff
changeset
|
287 endmacro() |