comparison Resources/CMake/DownloadOrthancFramework.cmake @ 4042:f5c86a00cae0

moving DownloadOrthancFramework.cmake to Resources/CMake/
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 10 Jun 2020 16:44:29 +0200
parents Resources/DownloadOrthancFramework.cmake@5e26d004838c
children 6c6239aec462
comparison
equal deleted inserted replaced
4041:ffd20cdfa82c 4042:f5c86a00cae0
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 Orthanc: ${ORTHANC_FRAMEWORK_ROOT}")
199 endif()
200
201 set(ORTHANC_ROOT ${ORTHANC_FRAMEWORK_ROOT})
202 endif()
203
204
205
206 ##
207 ## Case of the Orthanc framework cloned using Mercurial
208 ##
209
210 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "hg")
211 if (NOT STATIC_BUILD AND NOT ALLOW_DOWNLOADS)
212 message(FATAL_ERROR "CMake is not allowed to download from Internet. Please set the ALLOW_DOWNLOADS option to ON")
213 endif()
214
215 set(ORTHANC_ROOT ${CMAKE_BINARY_DIR}/orthanc)
216
217 if (EXISTS ${ORTHANC_ROOT})
218 message("Updating the Orthanc source repository using Mercurial")
219 execute_process(
220 COMMAND ${ORTHANC_FRAMEWORK_HG} pull
221 WORKING_DIRECTORY ${ORTHANC_ROOT}
222 RESULT_VARIABLE Failure
223 )
224 else()
225 message("Forking the Orthanc source repository using Mercurial")
226 execute_process(
227 COMMAND ${ORTHANC_FRAMEWORK_HG} clone "https://hg.orthanc-server.com/orthanc/"
228 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
229 RESULT_VARIABLE Failure
230 )
231 endif()
232
233 if (Failure OR NOT EXISTS ${ORTHANC_ROOT})
234 message(FATAL_ERROR "Cannot fork the Orthanc repository")
235 endif()
236
237 message("Setting branch of the Orthanc repository to: ${ORTHANC_FRAMEWORK_BRANCH}")
238
239 execute_process(
240 COMMAND ${ORTHANC_FRAMEWORK_HG} update -c ${ORTHANC_FRAMEWORK_BRANCH}
241 WORKING_DIRECTORY ${ORTHANC_ROOT}
242 RESULT_VARIABLE Failure
243 )
244
245 if (Failure)
246 message(FATAL_ERROR "Error while running Mercurial")
247 endif()
248 endif()
249
250
251
252 ##
253 ## Case of the Orthanc framework provided as a source archive on the
254 ## filesystem
255 ##
256
257 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "archive")
258 if (NOT DEFINED ORTHANC_FRAMEWORK_ARCHIVE)
259 message(FATAL_ERROR "The variable ORTHANC_FRAMEWORK_ARCHIVE must provide the path to the sources of Orthanc")
260 endif()
261 endif()
262
263
264
265 ##
266 ## Case of the Orthanc framework downloaded from the Web
267 ##
268
269 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "web")
270 if (DEFINED ORTHANC_FRAMEWORK_URL)
271 string(REGEX REPLACE "^.*/" "" ORTHANC_FRAMEMORK_FILENAME "${ORTHANC_FRAMEWORK_URL}")
272 else()
273 # Default case: Download from the official Web site
274 set(ORTHANC_FRAMEMORK_FILENAME Orthanc-${ORTHANC_FRAMEWORK_VERSION}.tar.gz)
275 set(ORTHANC_FRAMEWORK_URL "http://orthanc.osimis.io/ThirdPartyDownloads/orthanc-framework/${ORTHANC_FRAMEMORK_FILENAME}")
276 endif()
277
278 set(ORTHANC_FRAMEWORK_ARCHIVE "${CMAKE_SOURCE_DIR}/ThirdPartyDownloads/${ORTHANC_FRAMEMORK_FILENAME}")
279
280 if (NOT EXISTS "${ORTHANC_FRAMEWORK_ARCHIVE}")
281 if (NOT STATIC_BUILD AND NOT ALLOW_DOWNLOADS)
282 message(FATAL_ERROR "CMake is not allowed to download from Internet. Please set the ALLOW_DOWNLOADS option to ON")
283 endif()
284
285 message("Downloading: ${ORTHANC_FRAMEWORK_URL}")
286
287 file(DOWNLOAD
288 "${ORTHANC_FRAMEWORK_URL}" "${ORTHANC_FRAMEWORK_ARCHIVE}"
289 SHOW_PROGRESS EXPECTED_MD5 "${ORTHANC_FRAMEWORK_MD5}"
290 TIMEOUT 60
291 INACTIVITY_TIMEOUT 60
292 )
293 else()
294 message("Using local copy of: ${ORTHANC_FRAMEWORK_URL}")
295 endif()
296 endif()
297
298
299
300
301 ##
302 ## Uncompressing the Orthanc framework, if it was retrieved from a
303 ## source archive on the filesystem, or from the official Web site
304 ##
305
306 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "archive" OR
307 ORTHANC_FRAMEWORK_SOURCE STREQUAL "web")
308
309 if (NOT DEFINED ORTHANC_FRAMEWORK_ARCHIVE OR
310 NOT DEFINED ORTHANC_FRAMEWORK_VERSION OR
311 NOT DEFINED ORTHANC_FRAMEWORK_MD5)
312 message(FATAL_ERROR "Internal error")
313 endif()
314
315 if (ORTHANC_FRAMEWORK_MD5 STREQUAL "")
316 message(FATAL_ERROR "Unknown release of Orthanc: ${ORTHANC_FRAMEWORK_VERSION}")
317 endif()
318
319 file(MD5 ${ORTHANC_FRAMEWORK_ARCHIVE} ActualMD5)
320
321 if (NOT "${ActualMD5}" STREQUAL "${ORTHANC_FRAMEWORK_MD5}")
322 message(FATAL_ERROR "The MD5 hash of the Orthanc archive is invalid: ${ORTHANC_FRAMEWORK_ARCHIVE}")
323 endif()
324
325 set(ORTHANC_ROOT "${CMAKE_BINARY_DIR}/Orthanc-${ORTHANC_FRAMEWORK_VERSION}")
326
327 if (NOT IS_DIRECTORY "${ORTHANC_ROOT}")
328 if (NOT ORTHANC_FRAMEWORK_ARCHIVE MATCHES ".tar.gz$")
329 message(FATAL_ERROR "Archive should have the \".tar.gz\" extension: ${ORTHANC_FRAMEWORK_ARCHIVE}")
330 endif()
331
332 message("Uncompressing: ${ORTHANC_FRAMEWORK_ARCHIVE}")
333
334 if ("${CMAKE_HOST_SYSTEM_NAME}" STREQUAL "Windows")
335 # How to silently extract files using 7-zip
336 # http://superuser.com/questions/331148/7zip-command-line-extract-silently-quietly
337
338 execute_process(
339 COMMAND ${ORTHANC_FRAMEWORK_7ZIP} e -y ${ORTHANC_FRAMEWORK_ARCHIVE}
340 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
341 RESULT_VARIABLE Failure
342 OUTPUT_QUIET
343 )
344
345 if (Failure)
346 message(FATAL_ERROR "Error while running the uncompression tool")
347 endif()
348
349 get_filename_component(TMP_FILENAME "${ORTHANC_FRAMEWORK_ARCHIVE}" NAME)
350 string(REGEX REPLACE ".gz$" "" TMP_FILENAME2 "${TMP_FILENAME}")
351
352 execute_process(
353 COMMAND ${ORTHANC_FRAMEWORK_7ZIP} x -y ${TMP_FILENAME2}
354 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
355 RESULT_VARIABLE Failure
356 OUTPUT_QUIET
357 )
358
359 else()
360 execute_process(
361 COMMAND sh -c "${ORTHANC_FRAMEWORK_TAR} xfz ${ORTHANC_FRAMEWORK_ARCHIVE}"
362 WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
363 RESULT_VARIABLE Failure
364 )
365 endif()
366
367 if (Failure)
368 message(FATAL_ERROR "Error while running the uncompression tool")
369 endif()
370
371 if (NOT IS_DIRECTORY "${ORTHANC_ROOT}")
372 message(FATAL_ERROR "The Orthanc framework was not uncompressed at the proper location. Check the CMake instructions.")
373 endif()
374 endif()
375 endif()
376
377
378
379 ##
380 ## Case of the Orthanc framework installed as a shared library in a
381 ## GNU/Linux distribution (typically Debian)
382 ##
383
384 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "system")
385 set(ORTHANC_FRAMEWORK_LIBDIR "" CACHE PATH "")
386
387 if (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND
388 CMAKE_COMPILER_IS_GNUCXX) # MinGW
389 set(DYNAMIC_MINGW_STDLIB ON) # Disable static linking against libc (to throw exceptions)
390 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libstdc++")
391 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++")
392 endif()
393
394 include(CheckIncludeFile)
395 include(CheckIncludeFileCXX)
396 include(FindPythonInterp)
397 include(${CMAKE_CURRENT_LIST_DIR}/Compiler.cmake)
398 include(${CMAKE_CURRENT_LIST_DIR}/DownloadPackage.cmake)
399 include(${CMAKE_CURRENT_LIST_DIR}/AutoGeneratedCode.cmake)
400 set(EMBED_RESOURCES_PYTHON ${CMAKE_CURRENT_LIST_DIR}/EmbedResources.py)
401
402 if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
403 # Look for mandatory dependency JsonCpp (cf. JsonCppConfiguration.cmake)
404 find_path(JSONCPP_INCLUDE_DIR json/reader.h
405 /usr/include/jsoncpp
406 /usr/local/include/jsoncpp
407 )
408
409 message("JsonCpp include dir: ${JSONCPP_INCLUDE_DIR}")
410 include_directories(${JSONCPP_INCLUDE_DIR})
411 link_libraries(jsoncpp)
412
413 CHECK_INCLUDE_FILE_CXX(${JSONCPP_INCLUDE_DIR}/json/reader.h HAVE_JSONCPP_H)
414 if (NOT HAVE_JSONCPP_H)
415 message(FATAL_ERROR "Please install the libjsoncpp-dev package")
416 endif()
417
418 # Look for mandatory dependency Boost (cf. BoostConfiguration.cmake)
419 include(FindBoost)
420 find_package(Boost COMPONENTS filesystem thread system date_time regex)
421
422 if (NOT Boost_FOUND)
423 message(FATAL_ERROR "Unable to locate Boost on this system")
424 endif()
425
426 include_directories(${Boost_INCLUDE_DIRS})
427 link_libraries(${Boost_LIBRARIES})
428
429 # Optional component - Lua
430 if (ENABLE_LUA)
431 include(FindLua)
432
433 if (NOT LUA_FOUND)
434 message(FATAL_ERROR "Please install the liblua-dev package")
435 endif()
436
437 include_directories(${LUA_INCLUDE_DIR})
438 link_libraries(${LUA_LIBRARIES})
439 endif()
440
441 # Optional component - SQLite
442 if (ENABLE_SQLITE)
443 CHECK_INCLUDE_FILE(sqlite3.h HAVE_SQLITE_H)
444 if (NOT HAVE_SQLITE_H)
445 message(FATAL_ERROR "Please install the libsqlite3-dev package")
446 endif()
447 link_libraries(sqlite3)
448 endif()
449 endif()
450
451 # Optional component - Google Test
452 if (ENABLE_GOOGLE_TEST)
453 set(USE_SYSTEM_GOOGLE_TEST ON CACHE BOOL "Use the system version of Google Test")
454 set(USE_GOOGLE_TEST_DEBIAN_PACKAGE OFF CACHE BOOL "Use the sources of Google Test shipped with libgtest-dev (Debian only)")
455 mark_as_advanced(USE_GOOGLE_TEST_DEBIAN_PACKAGE)
456 include(${CMAKE_CURRENT_LIST_DIR}/GoogleTestConfiguration.cmake)
457 endif()
458
459 # Look for Orthanc framework shared library
460 include(CheckCXXSymbolExists)
461
462 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
463 set(ORTHANC_FRAMEWORK_INCLUDE_DIR ${ORTHANC_FRAMEWORK_ROOT})
464 include_directories(${ORTHANC_FRAMEWORK_ROOT}/..)
465 else()
466 find_path(ORTHANC_FRAMEWORK_INCLUDE_DIR OrthancFramework.h
467 /usr/include/orthanc-framework
468 /usr/local/include/orthanc-framework
469 ${ORTHANC_FRAMEWORK_ROOT}
470 )
471 endif()
472
473 message("Orthanc framework include dir: ${ORTHANC_FRAMEWORK_INCLUDE_DIR}")
474 include_directories(${ORTHANC_FRAMEWORK_INCLUDE_DIR})
475
476 set(CMAKE_REQUIRED_INCLUDES "${ORTHANC_FRAMEWORK_INCLUDE_DIR}")
477
478 if (NOT "${ORTHANC_FRAMEWORK_LIBDIR}" STREQUAL "")
479 set(CMAKE_REQUIRED_LIBRARIES "-L${ORTHANC_FRAMEWORK_LIBDIR} -lOrthancFramework")
480 else()
481 set(CMAKE_REQUIRED_LIBRARIES "OrthancFramework")
482 endif()
483
484 check_cxx_symbol_exists("Orthanc::InitializeFramework" "OrthancFramework.h" HAVE_ORTHANC_FRAMEWORK)
485 if(NOT HAVE_ORTHANC_FRAMEWORK)
486 message(FATAL_ERROR "Cannot find the Orthanc framework")
487 endif()
488
489 if (NOT "${ORTHANC_FRAMEWORK_ROOT}" STREQUAL "")
490 include_directories(${ORTHANC_FRAMEWORK_ROOT})
491 endif()
492
493 if (NOT "${ORTHANC_FRAMEWORK_LIBDIR}" STREQUAL "")
494 link_directories(${ORTHANC_FRAMEWORK_LIBDIR})
495 endif()
496 endif()