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