comparison OrthancStone/Resources/Orthanc/CMake/DownloadOrthancFramework.cmake @ 1512:244ad1e4e76a

reorganization of folders
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 07 Jul 2020 16:21:02 +0200
parents Resources/Orthanc/CMake/DownloadOrthancFramework.cmake@dd1d1cc0575d
children 6e3180a1f20f
comparison
equal deleted inserted replaced
1511:9dfeee74c1e6 1512:244ad1e4e76a
1 # Orthanc - A Lightweight, RESTful DICOM Store
2 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
3 # Department, University Hospital of Liege, Belgium
4 # Copyright (C) 2017-2020 Osimis S.A., Belgium
5 #
6 # This program is free software: you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation, either version 3 of the
9 # License, or (at your option) any later version.
10 #
11 # In addition, as a special exception, the copyright holders of this
12 # program give permission to link the code of its release with the
13 # OpenSSL project's "OpenSSL" library (or with modified versions of it
14 # that use the same license as the "OpenSSL" library), and distribute
15 # the linked executables. You must obey the GNU General Public License
16 # in all respects for all of the code used other than "OpenSSL". If you
17 # modify file(s) with this exception, you may extend this exception to
18 # your version of the file(s), but you are not obligated to do so. If
19 # you do not wish to do so, delete this exception statement from your
20 # version. If you delete this exception statement from all source files
21 # in the program, then also delete it here.
22 #
23 # This program is distributed in the hope that it will be useful, but
24 # WITHOUT ANY WARRANTY; without even the implied warranty of
25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 # General Public License for more details.
27 #
28 # You should have received a copy of the GNU General Public License
29 # along with this program. If not, see <http://www.gnu.org/licenses/>.
30
31
32
33 ##
34 ## Check whether the parent script sets the mandatory variables
35 ##
36
37 if (NOT DEFINED ORTHANC_FRAMEWORK_SOURCE OR
38 (NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "system" AND
39 NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "hg" AND
40 NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "web" AND
41 NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "archive" AND
42 NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "path"))
43 message(FATAL_ERROR "The variable ORTHANC_FRAMEWORK_SOURCE must be set to \"system\", \"hg\", \"web\", \"archive\" or \"path\"")
44 endif()
45
46
47 ##
48 ## Detection of the requested version
49 ##
50
51 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "hg" OR
52 ORTHANC_FRAMEWORK_SOURCE STREQUAL "archive" OR
53 ORTHANC_FRAMEWORK_SOURCE STREQUAL "web")
54 if (NOT DEFINED ORTHANC_FRAMEWORK_VERSION)
55 message(FATAL_ERROR "The variable ORTHANC_FRAMEWORK_VERSION must be set")
56 endif()
57
58 if (DEFINED ORTHANC_FRAMEWORK_MAJOR OR
59 DEFINED ORTHANC_FRAMEWORK_MINOR OR
60 DEFINED ORTHANC_FRAMEWORK_REVISION OR
61 DEFINED ORTHANC_FRAMEWORK_MD5)
62 message(FATAL_ERROR "Some internal variable has been set")
63 endif()
64
65 set(ORTHANC_FRAMEWORK_MD5 "")
66
67 if (NOT DEFINED ORTHANC_FRAMEWORK_BRANCH)
68 if (ORTHANC_FRAMEWORK_VERSION STREQUAL "mainline")
69 set(ORTHANC_FRAMEWORK_BRANCH "default")
70 set(ORTHANC_FRAMEWORK_MAJOR 999)
71 set(ORTHANC_FRAMEWORK_MINOR 999)
72 set(ORTHANC_FRAMEWORK_REVISION 999)
73
74 else()
75 set(ORTHANC_FRAMEWORK_BRANCH "Orthanc-${ORTHANC_FRAMEWORK_VERSION}")
76
77 set(RE "^([0-9]+)\\.([0-9]+)\\.([0-9]+)$")
78 string(REGEX REPLACE ${RE} "\\1" ORTHANC_FRAMEWORK_MAJOR ${ORTHANC_FRAMEWORK_VERSION})
79 string(REGEX REPLACE ${RE} "\\2" ORTHANC_FRAMEWORK_MINOR ${ORTHANC_FRAMEWORK_VERSION})
80 string(REGEX REPLACE ${RE} "\\3" ORTHANC_FRAMEWORK_REVISION ${ORTHANC_FRAMEWORK_VERSION})
81
82 if (NOT ORTHANC_FRAMEWORK_MAJOR MATCHES "^[0-9]+$" OR
83 NOT ORTHANC_FRAMEWORK_MINOR MATCHES "^[0-9]+$" OR
84 NOT ORTHANC_FRAMEWORK_REVISION MATCHES "^[0-9]+$")
85 message("Bad version of the Orthanc framework: ${ORTHANC_FRAMEWORK_VERSION}")
86 endif()
87
88 if (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.3.1")
89 set(ORTHANC_FRAMEWORK_MD5 "dac95bd6cf86fb19deaf4e612961f378")
90 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.3.2")
91 set(ORTHANC_FRAMEWORK_MD5 "d0ccdf68e855d8224331f13774992750")
92 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.4.0")
93 set(ORTHANC_FRAMEWORK_MD5 "81e15f34d97ac32bbd7d26e85698835a")
94 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.4.1")
95 set(ORTHANC_FRAMEWORK_MD5 "9b6f6114264b17ed421b574cd6476127")
96 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.4.2")
97 set(ORTHANC_FRAMEWORK_MD5 "d1ee84927dcf668e60eb5868d24b9394")
98 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.5.0")
99 set(ORTHANC_FRAMEWORK_MD5 "4429d8d9dea4ff6648df80ec3c64d79e")
100 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.5.1")
101 set(ORTHANC_FRAMEWORK_MD5 "099671538865e5da96208b37494d6718")
102 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.5.2")
103 set(ORTHANC_FRAMEWORK_MD5 "8867050f3e9a1ce6157c1ea7a9433b1b")
104 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.5.3")
105 set(ORTHANC_FRAMEWORK_MD5 "bf2f5ed1adb8b0fc5f10d278e68e1dfe")
106 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.5.4")
107 set(ORTHANC_FRAMEWORK_MD5 "404baef5d4c43e7c5d9410edda8ef5a5")
108 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.5.5")
109 set(ORTHANC_FRAMEWORK_MD5 "cfc437e0687ae4bd725fd93dc1f08bc4")
110 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.5.6")
111 set(ORTHANC_FRAMEWORK_MD5 "3c29de1e289b5472342947168f0105c0")
112 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.5.7")
113 set(ORTHANC_FRAMEWORK_MD5 "e1b76f01116d9b5d4ac8cc39980560e3")
114 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.5.8")
115 set(ORTHANC_FRAMEWORK_MD5 "82323e8c49a667f658a3639ea4dbc336")
116 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.6.0")
117 set(ORTHANC_FRAMEWORK_MD5 "eab428d6e53f61e847fa360bb17ebe25")
118 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.6.1")
119 set(ORTHANC_FRAMEWORK_MD5 "3971f5de96ba71dc9d3f3690afeaa7c0")
120 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.7.0")
121 set(ORTHANC_FRAMEWORK_MD5 "ce5f689e852b01d3672bd3d2f952a5ef")
122 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.7.1")
123 set(ORTHANC_FRAMEWORK_MD5 "3c171217f930abe80246997bdbcaf7cc")
124
125 # Below this point are development snapshots that were used to
126 # release some plugin, before an official release of the Orthanc
127 # framework was available. Here is the command to be used to
128 # generate a proper archive:
129 #
130 # $ hg archive /tmp/Orthanc-`hg id -i | sed 's/\+//'`.tar.gz
131 #
132 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "ae0e3fd609df")
133 # DICOMweb 1.1 (framework pre-1.6.0)
134 set(ORTHANC_FRAMEWORK_MD5 "7e09e9b530a2f527854f0b782d7e0645")
135 endif()
136 endif()
137 endif()
138
139 elseif (NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "system")
140 message("Using the Orthanc framework from a path of the filesystem. Assuming mainline version.")
141 set(ORTHANC_FRAMEWORK_MAJOR 999)
142 set(ORTHANC_FRAMEWORK_MINOR 999)
143 set(ORTHANC_FRAMEWORK_REVISION 999)
144 endif()
145
146
147
148 ##
149 ## Detection of the third-party software
150 ##
151
152 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "hg")
153 find_program(ORTHANC_FRAMEWORK_HG hg)
154
155 if (${ORTHANC_FRAMEWORK_HG} MATCHES "ORTHANC_FRAMEWORK_HG-NOTFOUND")
156 message(FATAL_ERROR "Please install Mercurial")
157 endif()
158 endif()
159
160
161 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "archive" OR
162 ORTHANC_FRAMEWORK_SOURCE STREQUAL "web")
163 if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
164 find_program(ORTHANC_FRAMEWORK_7ZIP 7z
165 PATHS
166 "$ENV{ProgramFiles}/7-Zip"
167 "$ENV{ProgramW6432}/7-Zip"
168 )
169
170 if (${ORTHANC_FRAMEWORK_7ZIP} MATCHES "ORTHANC_FRAMEWORK_7ZIP-NOTFOUND")
171 message(FATAL_ERROR "Please install the '7-zip' software (http://www.7-zip.org/)")
172 endif()
173
174 else()
175 find_program(ORTHANC_FRAMEWORK_TAR tar)
176 if (${ORTHANC_FRAMEWORK_TAR} MATCHES "ORTHANC_FRAMEWORK_TAR-NOTFOUND")
177 message(FATAL_ERROR "Please install the 'tar' package")
178 endif()
179 endif()
180 endif()
181
182
183
184 ##
185 ## Case of the Orthanc framework specified as a path on the filesystem
186 ##
187
188 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "path")
189 if (NOT DEFINED ORTHANC_FRAMEWORK_ROOT)
190 message(FATAL_ERROR "The variable ORTHANC_FRAMEWORK_ROOT must provide the path to the sources of Orthanc")
191 endif()
192
193 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT})
194 message(FATAL_ERROR "Non-existing directory: ${ORTHANC_FRAMEWORK_ROOT}")
195 endif()
196
197 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT}/Resources/CMake/OrthancFrameworkParameters.cmake)
198 message(FATAL_ERROR "Directory not containing the source code of the Orthanc framework: ${ORTHANC_FRAMEWORK_ROOT}")
199 endif()
200 endif()
201
202
203
204 ##
205 ## Case of the Orthanc framework cloned using Mercurial
206 ##
207
208 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "hg")
209 if (NOT STATIC_BUILD AND NOT ALLOW_DOWNLOADS)
210 message(FATAL_ERROR "CMake is not allowed to download from Internet. Please set the ALLOW_DOWNLOADS option to ON")
211 endif()
212
213 set(ORTHANC_ROOT ${CMAKE_BINARY_DIR}/orthanc)
214
215 if (EXISTS ${ORTHANC_ROOT})
216 message("Updating the Orthanc source repository using Mercurial")
217 execute_process(
218 COMMAND ${ORTHANC_FRAMEWORK_HG} pull
219 WORKING_DIRECTORY ${ORTHANC_ROOT}
220 RESULT_VARIABLE Failure
221 )
222 else()
223 message("Forking the Orthanc source repository using Mercurial")
224 execute_process(
225 COMMAND ${ORTHANC_FRAMEWORK_HG} clone "https://hg.orthanc-server.com/orthanc/"
226 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
227 RESULT_VARIABLE Failure
228 )
229 endif()
230
231 if (Failure OR NOT EXISTS ${ORTHANC_ROOT})
232 message(FATAL_ERROR "Cannot fork the Orthanc repository")
233 endif()
234
235 message("Setting branch of the Orthanc repository to: ${ORTHANC_FRAMEWORK_BRANCH}")
236
237 execute_process(
238 COMMAND ${ORTHANC_FRAMEWORK_HG} update -c ${ORTHANC_FRAMEWORK_BRANCH}
239 WORKING_DIRECTORY ${ORTHANC_ROOT}
240 RESULT_VARIABLE Failure
241 )
242
243 if (Failure)
244 message(FATAL_ERROR "Error while running Mercurial")
245 endif()
246
247 unset(ORTHANC_FRAMEWORK_ROOT CACHE)
248 set(ORTHANC_FRAMEWORK_ROOT "${ORTHANC_ROOT}/OrthancFramework" CACHE
249 STRING "Path to the Orthanc framework source directory")
250
251 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT}/Resources/CMake/OrthancFrameworkParameters.cmake)
252 message(FATAL_ERROR "Directory not containing the source code of the Orthanc framework: ${ORTHANC_ROOT}")
253 endif()
254
255 unset(ORTHANC_ROOT)
256 endif()
257
258
259
260 ##
261 ## Case of the Orthanc framework provided as a source archive on the
262 ## filesystem
263 ##
264
265 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "archive")
266 if (NOT DEFINED ORTHANC_FRAMEWORK_ARCHIVE)
267 message(FATAL_ERROR "The variable ORTHANC_FRAMEWORK_ARCHIVE must provide the path to the sources of Orthanc")
268 endif()
269 endif()
270
271
272
273 ##
274 ## Case of the Orthanc framework downloaded from the Web
275 ##
276
277 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "web")
278 if (DEFINED ORTHANC_FRAMEWORK_URL)
279 string(REGEX REPLACE "^.*/" "" ORTHANC_FRAMEMORK_FILENAME "${ORTHANC_FRAMEWORK_URL}")
280 else()
281 # Default case: Download from the official Web site
282 set(ORTHANC_FRAMEMORK_FILENAME Orthanc-${ORTHANC_FRAMEWORK_VERSION}.tar.gz)
283 set(ORTHANC_FRAMEWORK_URL "http://orthanc.osimis.io/ThirdPartyDownloads/orthanc-framework/${ORTHANC_FRAMEMORK_FILENAME}")
284 endif()
285
286 set(ORTHANC_FRAMEWORK_ARCHIVE "${CMAKE_SOURCE_DIR}/ThirdPartyDownloads/${ORTHANC_FRAMEMORK_FILENAME}")
287
288 if (NOT EXISTS "${ORTHANC_FRAMEWORK_ARCHIVE}")
289 if (NOT STATIC_BUILD AND NOT ALLOW_DOWNLOADS)
290 message(FATAL_ERROR "CMake is not allowed to download from Internet. Please set the ALLOW_DOWNLOADS option to ON")
291 endif()
292
293 message("Downloading: ${ORTHANC_FRAMEWORK_URL}")
294
295 file(DOWNLOAD
296 "${ORTHANC_FRAMEWORK_URL}" "${ORTHANC_FRAMEWORK_ARCHIVE}"
297 SHOW_PROGRESS EXPECTED_MD5 "${ORTHANC_FRAMEWORK_MD5}"
298 TIMEOUT 60
299 INACTIVITY_TIMEOUT 60
300 )
301 else()
302 message("Using local copy of: ${ORTHANC_FRAMEWORK_URL}")
303 endif()
304 endif()
305
306
307
308
309 ##
310 ## Uncompressing the Orthanc framework, if it was retrieved from a
311 ## source archive on the filesystem, or from the official Web site
312 ##
313
314 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "archive" OR
315 ORTHANC_FRAMEWORK_SOURCE STREQUAL "web")
316
317 if (NOT DEFINED ORTHANC_FRAMEWORK_ARCHIVE OR
318 NOT DEFINED ORTHANC_FRAMEWORK_VERSION OR
319 NOT DEFINED ORTHANC_FRAMEWORK_MD5)
320 message(FATAL_ERROR "Internal error")
321 endif()
322
323 if (ORTHANC_FRAMEWORK_MD5 STREQUAL "")
324 message(FATAL_ERROR "Unknown release of Orthanc: ${ORTHANC_FRAMEWORK_VERSION}")
325 endif()
326
327 file(MD5 ${ORTHANC_FRAMEWORK_ARCHIVE} ActualMD5)
328
329 if (NOT "${ActualMD5}" STREQUAL "${ORTHANC_FRAMEWORK_MD5}")
330 message(FATAL_ERROR "The MD5 hash of the Orthanc archive is invalid: ${ORTHANC_FRAMEWORK_ARCHIVE}")
331 endif()
332
333 set(ORTHANC_ROOT "${CMAKE_BINARY_DIR}/Orthanc-${ORTHANC_FRAMEWORK_VERSION}")
334
335 if (NOT IS_DIRECTORY "${ORTHANC_ROOT}")
336 if (NOT ORTHANC_FRAMEWORK_ARCHIVE MATCHES ".tar.gz$")
337 message(FATAL_ERROR "Archive should have the \".tar.gz\" extension: ${ORTHANC_FRAMEWORK_ARCHIVE}")
338 endif()
339
340 message("Uncompressing: ${ORTHANC_FRAMEWORK_ARCHIVE}")
341
342 if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
343 # How to silently extract files using 7-zip
344 # http://superuser.com/questions/331148/7zip-command-line-extract-silently-quietly
345
346 execute_process(
347 COMMAND ${ORTHANC_FRAMEWORK_7ZIP} e -y ${ORTHANC_FRAMEWORK_ARCHIVE}
348 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
349 RESULT_VARIABLE Failure
350 OUTPUT_QUIET
351 )
352
353 if (Failure)
354 message(FATAL_ERROR "Error while running the uncompression tool")
355 endif()
356
357 get_filename_component(TMP_FILENAME "${ORTHANC_FRAMEWORK_ARCHIVE}" NAME)
358 string(REGEX REPLACE ".gz$" "" TMP_FILENAME2 "${TMP_FILENAME}")
359
360 execute_process(
361 COMMAND ${ORTHANC_FRAMEWORK_7ZIP} x -y ${TMP_FILENAME2}
362 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
363 RESULT_VARIABLE Failure
364 OUTPUT_QUIET
365 )
366
367 else()
368 execute_process(
369 COMMAND sh -c "${ORTHANC_FRAMEWORK_TAR} xfz ${ORTHANC_FRAMEWORK_ARCHIVE}"
370 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
371 RESULT_VARIABLE Failure
372 )
373 endif()
374
375 if (Failure)
376 message(FATAL_ERROR "Error while running the uncompression tool")
377 endif()
378
379 if (NOT IS_DIRECTORY "${ORTHANC_ROOT}")
380 message(FATAL_ERROR "The Orthanc framework was not uncompressed at the proper location. Check the CMake instructions.")
381 endif()
382 endif()
383
384 unset(ORTHANC_FRAMEWORK_ROOT CACHE)
385 set(ORTHANC_FRAMEWORK_ROOT "${ORTHANC_ROOT}/OrthancFramework" CACHE
386 STRING "Path to the Orthanc framework source directory")
387
388 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT}/Resources/CMake/OrthancFrameworkParameters.cmake)
389 message(FATAL_ERROR "Directory not containing the source code of the Orthanc framework: ${ORTHANC_ROOT}")
390 endif()
391
392 unset(ORTHANC_ROOT)
393 endif()
394
395
396
397 ##
398 ## Case of the Orthanc framework installed as a shared library in a
399 ## GNU/Linux distribution (typically Debian). New in Orthanc 1.7.2.
400 ##
401
402 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "system")
403 set(ORTHANC_FRAMEWORK_LIBDIR "" CACHE PATH "")
404
405 if (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND
406 CMAKE_COMPILER_IS_GNUCXX) # MinGW
407 set(DYNAMIC_MINGW_STDLIB ON) # Disable static linking against libc (to throw exceptions)
408 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libstdc++")
409 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++")
410 endif()
411
412 include(CheckIncludeFile)
413 include(CheckIncludeFileCXX)
414 include(FindPythonInterp)
415 include(${CMAKE_CURRENT_LIST_DIR}/Compiler.cmake)
416 include(${CMAKE_CURRENT_LIST_DIR}/DownloadPackage.cmake)
417 include(${CMAKE_CURRENT_LIST_DIR}/AutoGeneratedCode.cmake)
418 set(EMBED_RESOURCES_PYTHON ${CMAKE_CURRENT_LIST_DIR}/EmbedResources.py)
419
420 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" OR
421 ORTHANC_FRAMEWORK_STATIC)
422 include_directories(${ORTHANC_FRAMEWORK_ROOT}/..)
423 else()
424 # Look for mandatory dependency JsonCpp (cf. JsonCppConfiguration.cmake)
425 find_path(JSONCPP_INCLUDE_DIR json/reader.h
426 /usr/include/jsoncpp
427 /usr/local/include/jsoncpp
428 )
429
430 message("JsonCpp include dir: ${JSONCPP_INCLUDE_DIR}")
431 include_directories(${JSONCPP_INCLUDE_DIR})
432 link_libraries(jsoncpp)
433
434 CHECK_INCLUDE_FILE_CXX(${JSONCPP_INCLUDE_DIR}/json/reader.h HAVE_JSONCPP_H)
435 if (NOT HAVE_JSONCPP_H)
436 message(FATAL_ERROR "Please install the libjsoncpp-dev package")
437 endif()
438
439 # Look for mandatory dependency Boost (cf. BoostConfiguration.cmake)
440 include(FindBoost)
441 find_package(Boost COMPONENTS filesystem thread system date_time regex ${ORTHANC_BOOST_COMPONENTS})
442
443 if (NOT Boost_FOUND)
444 message(FATAL_ERROR "Unable to locate Boost on this system")
445 endif()
446
447 include_directories(${Boost_INCLUDE_DIRS})
448 link_libraries(${Boost_LIBRARIES})
449
450 # Optional component - Lua
451 if (ENABLE_LUA)
452 include(FindLua)
453
454 if (NOT LUA_FOUND)
455 message(FATAL_ERROR "Please install the liblua-dev package")
456 endif()
457
458 include_directories(${LUA_INCLUDE_DIR})
459 link_libraries(${LUA_LIBRARIES})
460 endif()
461
462 # Optional component - SQLite
463 if (ENABLE_SQLITE)
464 CHECK_INCLUDE_FILE(sqlite3.h HAVE_SQLITE_H)
465 if (NOT HAVE_SQLITE_H)
466 message(FATAL_ERROR "Please install the libsqlite3-dev package")
467 endif()
468 link_libraries(sqlite3)
469 endif()
470
471 # Optional component - Pugixml
472 if (ENABLE_PUGIXML)
473 CHECK_INCLUDE_FILE_CXX(pugixml.hpp HAVE_PUGIXML_H)
474 if (NOT HAVE_PUGIXML_H)
475 message(FATAL_ERROR "Please install the libpugixml-dev package")
476 endif()
477 link_libraries(pugixml)
478 endif()
479
480 # Optional component - DCMTK
481 if (ENABLE_DCMTK)
482 include(FindDCMTK)
483 include_directories(${DCMTK_INCLUDE_DIRS})
484 link_libraries(${DCMTK_LIBRARIES})
485 endif()
486 endif()
487
488 # Look for Orthanc framework shared library
489 include(CheckCXXSymbolExists)
490
491 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
492 set(ORTHANC_FRAMEWORK_INCLUDE_DIR ${ORTHANC_FRAMEWORK_ROOT})
493 else()
494 find_path(ORTHANC_FRAMEWORK_INCLUDE_DIR OrthancFramework.h
495 /usr/include/orthanc-framework
496 /usr/local/include/orthanc-framework
497 ${ORTHANC_FRAMEWORK_ROOT}
498 )
499 endif()
500
501 if (${ORTHANC_FRAMEWORK_INCLUDE_DIR} STREQUAL "ORTHANC_FRAMEWORK_INCLUDE_DIR-NOTFOUND")
502 message(FATAL_ERROR "Cannot locate the OrthancFramework.h header")
503 endif()
504
505 message("Orthanc framework include dir: ${ORTHANC_FRAMEWORK_INCLUDE_DIR}")
506 include_directories(${ORTHANC_FRAMEWORK_INCLUDE_DIR})
507
508 if ("${ORTHANC_FRAMEWORK_LIBDIR}" STREQUAL "")
509 set(ORTHANC_FRAMEWORK_LIBRARIES OrthancFramework)
510 else()
511 if (MSVC)
512 set(Suffix ".lib")
513 set(Prefix "")
514 else()
515 list(GET CMAKE_FIND_LIBRARY_PREFIXES 0 Prefix)
516 list(GET CMAKE_FIND_LIBRARY_SUFFIXES 0 Suffix)
517 endif()
518 set(ORTHANC_FRAMEWORK_LIBRARIES ${ORTHANC_FRAMEWORK_LIBDIR}/${Prefix}OrthancFramework${Suffix})
519 endif()
520
521 set(CMAKE_REQUIRED_INCLUDES "${ORTHANC_FRAMEWORK_INCLUDE_DIR}")
522 set(CMAKE_REQUIRED_LIBRARIES "${ORTHANC_FRAMEWORK_LIBRARIES}")
523
524 check_cxx_symbol_exists("Orthanc::InitializeFramework" "OrthancFramework.h" HAVE_ORTHANC_FRAMEWORK)
525 if (NOT HAVE_ORTHANC_FRAMEWORK)
526 message(FATAL_ERROR "Cannot find the Orthanc framework")
527 endif()
528
529 unset(CMAKE_REQUIRED_INCLUDES)
530 unset(CMAKE_REQUIRED_LIBRARIES)
531
532 if (NOT "${ORTHANC_FRAMEWORK_ROOT}" STREQUAL "")
533 include_directories(${ORTHANC_FRAMEWORK_ROOT})
534 endif()
535 endif()