annotate Resources/DownloadOrthancFramework.cmake @ 2531:b7ed112ce56e

DownloadOrthancFramework.cmake
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 16 Apr 2018 16:24:33 +0200
parents
children c35202c8c0db
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2531
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
1 # Orthanc - A Lightweight, RESTful DICOM Store
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
2 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
3 # Department, University Hospital of Liege, Belgium
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
4 # Copyright (C) 2017-2018 Osimis S.A., Belgium
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
5 #
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
6 # This program is free software: you can redistribute it and/or
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
7 # modify it under the terms of the GNU General Public License as
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
8 # published by the Free Software Foundation, either version 3 of the
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
9 # License, or (at your option) any later version.
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
10 #
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
11 # In addition, as a special exception, the copyright holders of this
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
12 # program give permission to link the code of its release with the
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
13 # OpenSSL project's "OpenSSL" library (or with modified versions of it
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
14 # that use the same license as the "OpenSSL" library), and distribute
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
15 # the linked executables. You must obey the GNU General Public License
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
16 # in all respects for all of the code used other than "OpenSSL". If you
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
17 # modify file(s) with this exception, you may extend this exception to
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
18 # your version of the file(s), but you are not obligated to do so. If
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
19 # you do not wish to do so, delete this exception statement from your
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
20 # version. If you delete this exception statement from all source files
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
21 # in the program, then also delete it here.
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
22 #
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
23 # This program is distributed in the hope that it will be useful, but
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
24 # WITHOUT ANY WARRANTY; without even the implied warranty of
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
26 # General Public License for more details.
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
27 #
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
28 # You should have received a copy of the GNU General Public License
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
29 # along with this program. If not, see <http://www.gnu.org/licenses/>.
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
30
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
31
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
32
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
33 ##
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
34 ## Check whether the parent script sets the mandatory variables
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
35 ##
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
36
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
37 if (NOT DEFINED ORTHANC_FRAMEWORK_SOURCE OR
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
38 (NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "hg" AND
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
39 NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "web" AND
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
40 NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "archive" AND
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
41 NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "path"))
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
42 message(FATAL_ERROR "The variable ORTHANC_FRAMEWORK_SOURCE must be set to \"hg\", \"web\", \"archive\" or \"path\"")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
43 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
44
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
45
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
46 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "hg" OR
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
47 ORTHANC_FRAMEWORK_SOURCE STREQUAL "web")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
48 if (NOT ALLOW_DOWNLOADS)
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
49 message(FATAL_ERROR "CMake is not allowed to download from Internet. Please set the ALLOW_DOWNLOADS option to ON")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
50 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
51 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
52
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
53
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
54
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
55 ##
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
56 ## Detection of the requested version
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
57 ##
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
58
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
59 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "hg" OR
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
60 ORTHANC_FRAMEWORK_SOURCE STREQUAL "web")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
61 if (NOT DEFINED ORTHANC_FRAMEWORK_VERSION)
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
62 message(FATAL_ERROR "The variable ORTHANC_FRAMEWORK_VERSION must be set")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
63 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
64
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
65 if (DEFINED ORTHANC_FRAMEWORK_MAJOR OR
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
66 DEFINED ORTHANC_FRAMEWORK_MINOR OR
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
67 DEFINED ORTHANC_FRAMEWORK_REVISION)
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
68 message(FATAL_ERROR "Some internal variable has been set")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
69 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
70
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
71 if (ORTHANC_FRAMEWORK_VERSION STREQUAL "mainline")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
72 set(ORTHANC_FRAMEWORK_BRANCH "default")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
73
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
74 else()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
75 set(ORTHANC_FRAMEWORK_BRANCH "Orthanc-${ORTHANC_FRAMEWORK_VERSION}")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
76
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
77 set(RE "^([0-9]+)\\.([0-9]+)\\.([0-9]+)$")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
78 string(REGEX REPLACE ${RE} "\\1" ORTHANC_FRAMEWORK_MAJOR ${ORTHANC_FRAMEWORK_VERSION})
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
79 string(REGEX REPLACE ${RE} "\\2" ORTHANC_FRAMEWORK_MINOR ${ORTHANC_FRAMEWORK_VERSION})
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
80 string(REGEX REPLACE ${RE} "\\3" ORTHANC_FRAMEWORK_REVISION ${ORTHANC_FRAMEWORK_VERSION})
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
81
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
82 if (NOT ORTHANC_FRAMEWORK_MAJOR MATCHES "^[0-9]+$" OR
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
83 NOT ORTHANC_FRAMEWORK_MINOR MATCHES "^[0-9]+$" OR
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
84 NOT ORTHANC_FRAMEWORK_REVISION MATCHES "^[0-9]+$")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
85 message("Bad version of the Orthanc framework: ${ORTHANC_FRAMEWORK_VERSION}")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
86 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
87 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
88 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
89
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
90
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
91
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
92 ##
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
93 ## Detection of the third-party software
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
94 ##
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
95
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
96 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "hg")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
97 find_program(ORTHANC_FRAMEWORK_HG hg)
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
98
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
99 if (${ORTHANC_FRAMEWORK_HG} MATCHES "ORTHANC_FRAMEWORK_HG-NOTFOUND")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
100 message(FATAL_ERROR "Please install Mercurial")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
101 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
102 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
103
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
104
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
105 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "archive" OR
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
106 ORTHANC_FRAMEWORK_SOURCE STREQUAL "web")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
107 if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
108 find_program(ORTHANC_FRAMEWORK_7ZIP 7z
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
109 PATHS
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
110 "$ENV{ProgramFiles}/7-Zip"
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
111 "$ENV{ProgramW6432}/7-Zip"
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
112 )
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
113
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
114 if (${ORTHANC_FRAMEWORK_7ZIP} MATCHES "ORTHANC_FRAMEWORK_7ZIP-NOTFOUND")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
115 message(FATAL_ERROR "Please install the '7-zip' software (http://www.7-zip.org/)")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
116 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
117
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
118 else()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
119 find_program(ORTHANC_FRAMEWORK_TAR tar)
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
120 if (${ORTHANC_FRAMEWORK_TAR} MATCHES "ORTHANC_FRAMEWORK_TAR-NOTFOUND")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
121 message(FATAL_ERROR "Please install the 'tar' package")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
122 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
123 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
124 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
125
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
126
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
127
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
128 ##
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
129 ## Case of the Orthanc framework specified as a path on the filesystem
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
130 ##
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
131
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
132 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "path")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
133 if (NOT DEFINED ORTHANC_FRAMEWORK_ROOT)
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
134 message(FATAL_ERROR "The variable ORTHANC_FRAMEWORK_ROOT must provide the path to the sources of Orthanc")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
135 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
136
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
137 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT})
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
138 message(FATAL_ERROR "Non-existing directory: ${ORTHANC_FRAMEWORK_ROOT}")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
139 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
140
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
141 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT}/Resources/CMake/OrthancFrameworkParameters.cmake)
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
142 message(FATAL_ERROR "Directory not containing a version of Orthanc: ${ORTHANC_FRAMEWORK_ROOT}")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
143 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
144
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
145 set(ORTHANC_ROOT ${ORTHANC_FRAMEWORK_ROOT})
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
146 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
147
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
148
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
149
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
150 ##
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
151 ## Case of the Orthanc framework cloned using Mercurial
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
152 ##
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
153
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
154 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "hg")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
155 set(ORTHANC_ROOT ${CMAKE_BINARY_DIR}/orthanc)
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
156
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
157 if (NOT EXISTS ${ORTHANC_ROOT})
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
158 message("Forking the Orthanc source repository using Mercurial")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
159
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
160 execute_process(
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
161 COMMAND ${ORTHANC_FRAMEWORK_HG} clone "https://bitbucket.org/sjodogne/orthanc"
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
162 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
163 RESULT_VARIABLE Failure
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
164 )
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
165
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
166 if (Failure OR NOT EXISTS ${ORTHANC_ROOT})
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
167 message(FATAL_ERROR "Cannot fork the Orthanc repository")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
168 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
169 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
170
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
171 message("Setting branch of the Orthanc repository to: ${ORTHANC_FRAMEWORK_BRANCH}")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
172
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
173 execute_process(
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
174 COMMAND ${ORTHANC_FRAMEWORK_HG} update -c ${ORTHANC_FRAMEWORK_BRANCH}
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
175 WORKING_DIRECTORY ${ORTHANC_ROOT}
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
176 RESULT_VARIABLE Failure
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
177 )
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
178
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
179 if (Failure)
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
180 message(FATAL_ERROR "Error while running Mercurial")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
181 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
182 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
183
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
184
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
185
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
186 ##
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
187 ## Case of the Orthanc framework provided as a source archive on the
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
188 ## filesystem
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
189 ##
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
190
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
191 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "archive")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
192 if (NOT DEFINED ORTHANC_FRAMEWORK_ARCHIVE)
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
193 message(FATAL_ERROR "The variable ORTHANC_FRAMEWORK_ARCHIVE must provide the path to the sources of Orthanc")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
194 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
195
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
196 set(RE "^.*/Orthanc-([0-9]+)\\.([0-9]+)\\.([0-9]+).tar.gz$")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
197 string(REGEX REPLACE ${RE} "\\1" ORTHANC_FRAMEWORK_MAJOR ${ORTHANC_FRAMEWORK_ARCHIVE})
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
198 string(REGEX REPLACE ${RE} "\\2" ORTHANC_FRAMEWORK_MINOR ${ORTHANC_FRAMEWORK_ARCHIVE})
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
199 string(REGEX REPLACE ${RE} "\\3" ORTHANC_FRAMEWORK_REVISION ${ORTHANC_FRAMEWORK_ARCHIVE})
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
200
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
201 if (NOT ORTHANC_FRAMEWORK_MAJOR MATCHES "^[0-9]+$" OR
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
202 NOT ORTHANC_FRAMEWORK_MINOR MATCHES "^[0-9]+$" OR
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
203 NOT ORTHANC_FRAMEWORK_REVISION MATCHES "^[0-9]+$")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
204 message("Cannot detect the version of this release of Orthanc: ${ORTHANC_FRAMEWORK_ARCHIVE}")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
205 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
206
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
207 set(ORTHANC_FRAMEWORK_VERSION ${ORTHANC_FRAMEWORK_MAJOR}.${ORTHANC_FRAMEWORK_MINOR}.${ORTHANC_FRAMEWORK_REVISION})
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
208 message("Detected version of Orthanc: ${ORTHANC_FRAMEWORK_VERSION}")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
209 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
210
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
211
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
212
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
213 ##
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
214 ## Case of the Orthanc framework downloaded from the official Web site
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
215 ##
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
216
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
217 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "web")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
218 set(ORTHANC_FRAMEMORK_FILENAME Orthanc-${ORTHANC_FRAMEWORK_VERSION}.tar.gz)
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
219 set(ORTHANC_FRAMEWORK_URL "https://www.orthanc-server.com/downloads/get.php?path=/orthanc/${ORTHANC_FRAMEMORK_FILENAME}")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
220
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
221 if (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.3.1")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
222 set(ORTHANC_FRAMEWORK_MD5 "dac95bd6cf86fb19deaf4e612961f378")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
223 else()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
224 message(FATAL_ERROR "Unknown release of Orthanc: ${ORTHANC_FRAMEWORK_VERSION}")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
225 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
226
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
227 set(ORTHANC_FRAMEWORK_ARCHIVE "${CMAKE_SOURCE_DIR}/ThirdPartyDownloads/${ORTHANC_FRAMEMORK_FILENAME}")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
228
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
229 if (NOT EXISTS "${ORTHANC_FRAMEWORK_ARCHIVE}")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
230 message("Downloading ${ORTHANC_FRAMEWORK_ARCHIVE}")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
231
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
232 file(DOWNLOAD
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
233 "${ORTHANC_FRAMEWORK_URL}" "${ORTHANC_FRAMEWORK_ARCHIVE}"
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
234 SHOW_PROGRESS EXPECTED_MD5 "${ORTHANC_FRAMEWORK_MD5}"
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
235 TIMEOUT 60
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
236 INACTIVITY_TIMEOUT 60
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
237 )
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
238 else()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
239 message("Using local copy of ${ORTHANC_FRAMEWORK_URL}")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
240
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
241 file(MD5 ${ORTHANC_FRAMEWORK_ARCHIVE} ActualMD5)
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
242 if (NOT "${ActualMD5}" STREQUAL "${ORTHANC_FRAMEWORK_MD5}")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
243 message(FATAL_ERROR "The MD5 hash of a previously download file is invalid: ${ORTHANC_FRAMEWORK_ARCHIVE}")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
244 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
245 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
246 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
247
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
248
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
249
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
250
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
251 ##
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
252 ## Uncompressing the Orthanc framework, if it was retrieved from a
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
253 ## source archive on the filesystem, or from the official Web site
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
254 ##
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
255
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
256 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "archive" OR
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
257 ORTHANC_FRAMEWORK_SOURCE STREQUAL "web")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
258
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
259 if (NOT DEFINED ORTHANC_FRAMEWORK_ARCHIVE OR
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
260 NOT DEFINED ORTHANC_FRAMEWORK_VERSION)
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
261 message(FATAL_ERROR "Internal error")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
262 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
263
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
264 set(ORTHANC_ROOT "${CMAKE_BINARY_DIR}/Orthanc-${ORTHANC_FRAMEWORK_VERSION}")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
265
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
266 if (NOT IS_DIRECTORY "${ORTHANC_ROOT}")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
267 if (NOT ORTHANC_FRAMEWORK_ARCHIVE MATCHES ".tar.gz$")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
268 message(FATAL_ERROR "Archive should have the \".tar.gz\" extension: ${ORTHANC_FRAMEWORK_ARCHIVE}")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
269 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
270
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
271 message("Uncompressing ${ORTHANC_FRAMEWORK_ARCHIVE}")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
272
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
273 if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
274 # How to silently extract files using 7-zip
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
275 # http://superuser.com/questions/331148/7zip-command-line-extract-silently-quietly
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
276
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
277 execute_process(
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
278 COMMAND ${ORTHANC_FRAMEWORK_7ZIP} e -y ${ORTHANC_FRAMEWORK_ARCHIVE}
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
279 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
280 RESULT_VARIABLE Failure
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
281 OUTPUT_QUIET
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
282 )
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
283
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
284 if (Failure)
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
285 message(FATAL_ERROR "Error while running the uncompression tool")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
286 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
287
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
288 string(REGEX REPLACE ".gz$" "" TMP "${ORTHANC_FRAMEWORK_ARCHIVE}")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
289
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
290 execute_process(
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
291 COMMAND ${ORTHANC_FRAMEWORK_7ZIP} x -y ${TMP_FILENAME2}
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
292 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
293 RESULT_VARIABLE Failure
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
294 OUTPUT_QUIET
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
295 )
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
296
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
297 else()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
298 execute_process(
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
299 COMMAND sh -c "${ORTHANC_FRAMEWORK_TAR} xfz ${ORTHANC_FRAMEWORK_ARCHIVE}"
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
300 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
301 RESULT_VARIABLE Failure
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
302 )
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
303 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
304
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
305 if (Failure)
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
306 message(FATAL_ERROR "Error while running the uncompression tool")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
307 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
308
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
309 if (NOT IS_DIRECTORY "${ORTHANC_ROOT}")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
310 message(FATAL_ERROR "The Orthanc framework was not uncompressed at the proper location. Check the CMake instructions.")
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
311 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
312 endif()
b7ed112ce56e DownloadOrthancFramework.cmake
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
diff changeset
313 endif()