comparison Common/Resources/DownloadOrthancFramework.cmake @ 15:2a02b21f0a19

migration + storage structure
author Alain Mazy
date Tue, 01 Sep 2020 13:08:49 +0200
parents fc26a8fc54d5
children f55b2afdf53d
comparison
equal deleted inserted replaced
14:234946ea2038 15:2a02b21f0a19
2 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics 2 # Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
3 # Department, University Hospital of Liege, Belgium 3 # Department, University Hospital of Liege, Belgium
4 # Copyright (C) 2017-2020 Osimis S.A., Belgium 4 # Copyright (C) 2017-2020 Osimis S.A., Belgium
5 # 5 #
6 # This program is free software: you can redistribute it and/or 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 7 # modify it under the terms of the GNU Lesser General Public License
8 # published by the Free Software Foundation, either version 3 of the 8 # as published by the Free Software Foundation, either version 3 of
9 # License, or (at your option) any later version. 9 # the License, or (at your option) any later version.
10 # 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 11 # This program is distributed in the hope that it will be useful, but
24 # WITHOUT ANY WARRANTY; without even the implied warranty of 12 # WITHOUT ANY WARRANTY; without even the implied warranty of
25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 # General Public License for more details. 14 # Lesser General Public License for more details.
27 # 15 #
28 # You should have received a copy of the GNU General Public License 16 # You should have received a copy of the GNU Lesser General Public
29 # along with this program. If not, see <http://www.gnu.org/licenses/>. 17 # License along with this program. If not, see
18 # <http://www.gnu.org/licenses/>.
30 19
31 20
32 21
33 ## 22 ##
34 ## Check whether the parent script sets the mandatory variables 23 ## Check whether the parent script sets the mandatory variables
35 ## 24 ##
36 25
37 if (NOT DEFINED ORTHANC_FRAMEWORK_SOURCE OR 26 if (NOT DEFINED ORTHANC_FRAMEWORK_SOURCE OR
38 (NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "hg" AND 27 (NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "system" AND
28 NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "hg" AND
39 NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "web" AND 29 NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "web" AND
40 NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "archive" AND 30 NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "archive" AND
41 NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "path")) 31 NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "path"))
42 message(FATAL_ERROR "The variable ORTHANC_FRAMEWORK_SOURCE must be set to \"hg\", \"web\", \"archive\" or \"path\"") 32 message(FATAL_ERROR "The variable ORTHANC_FRAMEWORK_SOURCE must be set to \"system\", \"hg\", \"web\", \"archive\" or \"path\"")
43 endif() 33 endif()
44 34
45 35
46 ## 36 ##
47 ## Detection of the requested version 37 ## Detection of the requested version
116 set(ORTHANC_FRAMEWORK_MD5 "eab428d6e53f61e847fa360bb17ebe25") 106 set(ORTHANC_FRAMEWORK_MD5 "eab428d6e53f61e847fa360bb17ebe25")
117 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.6.1") 107 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.6.1")
118 set(ORTHANC_FRAMEWORK_MD5 "3971f5de96ba71dc9d3f3690afeaa7c0") 108 set(ORTHANC_FRAMEWORK_MD5 "3971f5de96ba71dc9d3f3690afeaa7c0")
119 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.7.0") 109 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.7.0")
120 set(ORTHANC_FRAMEWORK_MD5 "ce5f689e852b01d3672bd3d2f952a5ef") 110 set(ORTHANC_FRAMEWORK_MD5 "ce5f689e852b01d3672bd3d2f952a5ef")
111 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.7.1")
112 set(ORTHANC_FRAMEWORK_MD5 "3c171217f930abe80246997bdbcaf7cc")
113 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.7.2")
114 set(ORTHANC_FRAMEWORK_MD5 "328f94dcbd78c169655a13f7ad58a2c2")
115 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.7.3")
116 set(ORTHANC_FRAMEWORK_MD5 "3f1ba9502ec7c5449971d3b56087bcde")
121 117
122 # Below this point are development snapshots that were used to 118 # Below this point are development snapshots that were used to
123 # release some plugin, before an official release of the Orthanc 119 # release some plugin, before an official release of the Orthanc
124 # framework was available. Here is the command to be used to 120 # framework was available. Here is the command to be used to
125 # generate a proper archive: 121 # generate a proper archive:
130 # DICOMweb 1.1 (framework pre-1.6.0) 126 # DICOMweb 1.1 (framework pre-1.6.0)
131 set(ORTHANC_FRAMEWORK_MD5 "7e09e9b530a2f527854f0b782d7e0645") 127 set(ORTHANC_FRAMEWORK_MD5 "7e09e9b530a2f527854f0b782d7e0645")
132 endif() 128 endif()
133 endif() 129 endif()
134 endif() 130 endif()
135 else() 131
132 elseif (ORTHANC_FRAMEWORK_SOURCE STREQUAL "path")
136 message("Using the Orthanc framework from a path of the filesystem. Assuming mainline version.") 133 message("Using the Orthanc framework from a path of the filesystem. Assuming mainline version.")
137 set(ORTHANC_FRAMEWORK_MAJOR 999) 134 set(ORTHANC_FRAMEWORK_MAJOR 999)
138 set(ORTHANC_FRAMEWORK_MINOR 999) 135 set(ORTHANC_FRAMEWORK_MINOR 999)
139 set(ORTHANC_FRAMEWORK_REVISION 999) 136 set(ORTHANC_FRAMEWORK_REVISION 999)
140 endif() 137 endif()
180 ## 177 ##
181 ## Case of the Orthanc framework specified as a path on the filesystem 178 ## Case of the Orthanc framework specified as a path on the filesystem
182 ## 179 ##
183 180
184 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "path") 181 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "path")
185 if (NOT DEFINED ORTHANC_FRAMEWORK_ROOT) 182 if (NOT DEFINED ORTHANC_FRAMEWORK_ROOT OR
183 ORTHANC_FRAMEWORK_ROOT STREQUAL "")
186 message(FATAL_ERROR "The variable ORTHANC_FRAMEWORK_ROOT must provide the path to the sources of Orthanc") 184 message(FATAL_ERROR "The variable ORTHANC_FRAMEWORK_ROOT must provide the path to the sources of Orthanc")
187 endif() 185 endif()
188 186
189 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT}) 187 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT})
190 message(FATAL_ERROR "Non-existing directory: ${ORTHANC_FRAMEWORK_ROOT}") 188 message(FATAL_ERROR "Non-existing directory: ${ORTHANC_FRAMEWORK_ROOT}")
191 endif() 189 endif()
192
193 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT}/Resources/CMake/OrthancFrameworkParameters.cmake)
194 message(FATAL_ERROR "Directory not containing the source code of Orthanc: ${ORTHANC_FRAMEWORK_ROOT}")
195 endif()
196
197 set(ORTHANC_ROOT ${ORTHANC_FRAMEWORK_ROOT})
198 endif() 190 endif()
199 191
200 192
201 193
202 ## 194 ##
249 ## Case of the Orthanc framework provided as a source archive on the 241 ## Case of the Orthanc framework provided as a source archive on the
250 ## filesystem 242 ## filesystem
251 ## 243 ##
252 244
253 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "archive") 245 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "archive")
254 if (NOT DEFINED ORTHANC_FRAMEWORK_ARCHIVE) 246 if (NOT DEFINED ORTHANC_FRAMEWORK_ARCHIVE OR
247 ORTHANC_FRAMEWORK_ARCHIVE STREQUAL "")
255 message(FATAL_ERROR "The variable ORTHANC_FRAMEWORK_ARCHIVE must provide the path to the sources of Orthanc") 248 message(FATAL_ERROR "The variable ORTHANC_FRAMEWORK_ARCHIVE must provide the path to the sources of Orthanc")
256 endif() 249 endif()
257 endif() 250 endif()
258 251
259 252
368 message(FATAL_ERROR "The Orthanc framework was not uncompressed at the proper location. Check the CMake instructions.") 361 message(FATAL_ERROR "The Orthanc framework was not uncompressed at the proper location. Check the CMake instructions.")
369 endif() 362 endif()
370 endif() 363 endif()
371 endif() 364 endif()
372 365
366
367
368 ##
369 ## Determine the path to the sources of the Orthanc framework
370 ##
371
372 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "archive" OR
373 ORTHANC_FRAMEWORK_SOURCE STREQUAL "hg" OR
374 ORTHANC_FRAMEWORK_SOURCE STREQUAL "web")
375 if (NOT DEFINED ORTHANC_ROOT OR
376 NOT DEFINED ORTHANC_FRAMEWORK_MAJOR OR
377 NOT DEFINED ORTHANC_FRAMEWORK_MINOR OR
378 NOT DEFINED ORTHANC_FRAMEWORK_REVISION)
379 message(FATAL_ERROR "Internal error in the DownloadOrthancFramework.cmake file")
380 endif()
381
382 unset(ORTHANC_FRAMEWORK_ROOT CACHE)
383
384 if ("${ORTHANC_FRAMEWORK_MAJOR}.${ORTHANC_FRAMEWORK_MINOR}.${ORTHANC_FRAMEWORK_REVISION}" VERSION_LESS "1.7.2")
385 set(ORTHANC_FRAMEWORK_ROOT "${ORTHANC_ROOT}/Core" CACHE
386 STRING "Path to the Orthanc framework source directory")
387 set(ENABLE_PLUGINS_VERSION_SCRIPT OFF)
388 else()
389 set(ORTHANC_FRAMEWORK_ROOT "${ORTHANC_ROOT}/OrthancFramework/Sources" CACHE
390 STRING "Path to the Orthanc framework source directory")
391 endif()
392
393 unset(ORTHANC_ROOT)
394 endif()
395
396 if (NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "system")
397 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT}/OrthancException.h OR
398 NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT}/../Resources/CMake/OrthancFrameworkParameters.cmake)
399 message(FATAL_ERROR "Directory not containing the source code of the Orthanc framework: ${ORTHANC_FRAMEWORK_ROOT}")
400 endif()
401 endif()
402
403
404
405 ##
406 ## Case of the Orthanc framework installed as a shared library in a
407 ## GNU/Linux distribution (typically Debian). New in Orthanc 1.7.2.
408 ##
409
410 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "system")
411 set(ORTHANC_FRAMEWORK_LIBDIR "" CACHE PATH "")
412
413 if (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND
414 CMAKE_COMPILER_IS_GNUCXX) # MinGW
415 set(DYNAMIC_MINGW_STDLIB ON) # Disable static linking against libc (to throw exceptions)
416 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libstdc++")
417 set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libstdc++")
418 endif()
419
420 include(CheckIncludeFile)
421 include(CheckIncludeFileCXX)
422 include(FindPythonInterp)
423 include(${CMAKE_CURRENT_LIST_DIR}/Compiler.cmake)
424 include(${CMAKE_CURRENT_LIST_DIR}/DownloadPackage.cmake)
425 include(${CMAKE_CURRENT_LIST_DIR}/AutoGeneratedCode.cmake)
426 set(EMBED_RESOURCES_PYTHON ${CMAKE_CURRENT_LIST_DIR}/EmbedResources.py)
427
428 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" OR
429 ORTHANC_FRAMEWORK_STATIC)
430 include_directories(${ORTHANC_FRAMEWORK_ROOT}/..)
431 else()
432 # Look for mandatory dependency JsonCpp (cf. JsonCppConfiguration.cmake)
433 find_path(JSONCPP_INCLUDE_DIR json/reader.h
434 /usr/include/jsoncpp
435 /usr/local/include/jsoncpp
436 )
437
438 message("JsonCpp include dir: ${JSONCPP_INCLUDE_DIR}")
439 include_directories(${JSONCPP_INCLUDE_DIR})
440 link_libraries(jsoncpp)
441
442 CHECK_INCLUDE_FILE_CXX(${JSONCPP_INCLUDE_DIR}/json/reader.h HAVE_JSONCPP_H)
443 if (NOT HAVE_JSONCPP_H)
444 message(FATAL_ERROR "Please install the libjsoncpp-dev package")
445 endif()
446
447 # Switch to the C++11 standard if the version of JsonCpp is 1.y.z
448 # (same as variable JSONCPP_CXX11 in the source code of Orthanc)
449 if (EXISTS ${JSONCPP_INCLUDE_DIR}/json/version.h)
450 file(STRINGS
451 "${JSONCPP_INCLUDE_DIR}/json/version.h"
452 JSONCPP_VERSION_MAJOR1 REGEX
453 ".*define JSONCPP_VERSION_MAJOR.*")
454
455 if (NOT JSONCPP_VERSION_MAJOR1)
456 message(FATAL_ERROR "Unable to extract the major version of JsonCpp")
457 endif()
458
459 string(REGEX REPLACE
460 ".*JSONCPP_VERSION_MAJOR.*([0-9]+)$" "\\1"
461 JSONCPP_VERSION_MAJOR ${JSONCPP_VERSION_MAJOR1})
462 message("JsonCpp major version: ${JSONCPP_VERSION_MAJOR}")
463
464 if (JSONCPP_VERSION_MAJOR GREATER 0)
465 message("Switching to C++11 standard, as version of JsonCpp is >= 1.0.0")
466 if (CMAKE_COMPILER_IS_GNUCXX)
467 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
468 elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
469 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
470 endif()
471 endif()
472 else()
473 message("Unable to detect the major version of JsonCpp, assuming < 1.0.0")
474 endif()
475
476 # Look for mandatory dependency Boost (cf. BoostConfiguration.cmake)
477 include(FindBoost)
478 find_package(Boost COMPONENTS filesystem thread system date_time regex ${ORTHANC_BOOST_COMPONENTS})
479
480 if (NOT Boost_FOUND)
481 message(FATAL_ERROR "Unable to locate Boost on this system")
482 endif()
483
484 include_directories(${Boost_INCLUDE_DIRS})
485 link_libraries(${Boost_LIBRARIES})
486
487 # Optional component - Lua
488 if (ENABLE_LUA)
489 include(FindLua)
490
491 if (NOT LUA_FOUND)
492 message(FATAL_ERROR "Please install the liblua-dev package")
493 endif()
494
495 include_directories(${LUA_INCLUDE_DIR})
496 link_libraries(${LUA_LIBRARIES})
497 endif()
498
499 # Optional component - SQLite
500 if (ENABLE_SQLITE)
501 CHECK_INCLUDE_FILE(sqlite3.h HAVE_SQLITE_H)
502 if (NOT HAVE_SQLITE_H)
503 message(FATAL_ERROR "Please install the libsqlite3-dev package")
504 endif()
505 link_libraries(sqlite3)
506 endif()
507
508 # Optional component - Pugixml
509 if (ENABLE_PUGIXML)
510 CHECK_INCLUDE_FILE_CXX(pugixml.hpp HAVE_PUGIXML_H)
511 if (NOT HAVE_PUGIXML_H)
512 message(FATAL_ERROR "Please install the libpugixml-dev package")
513 endif()
514 link_libraries(pugixml)
515 endif()
516
517 # Optional component - DCMTK
518 if (ENABLE_DCMTK)
519 include(FindDCMTK)
520 include_directories(${DCMTK_INCLUDE_DIRS})
521 link_libraries(${DCMTK_LIBRARIES})
522 endif()
523 endif()
524
525 # Look for Orthanc framework shared library
526 include(CheckCXXSymbolExists)
527
528 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
529 set(ORTHANC_FRAMEWORK_INCLUDE_DIR ${ORTHANC_FRAMEWORK_ROOT})
530 else()
531 find_path(ORTHANC_FRAMEWORK_INCLUDE_DIR OrthancFramework.h
532 /usr/include/orthanc-framework
533 /usr/local/include/orthanc-framework
534 ${ORTHANC_FRAMEWORK_ROOT}
535 )
536 endif()
537
538 if (${ORTHANC_FRAMEWORK_INCLUDE_DIR} STREQUAL "ORTHANC_FRAMEWORK_INCLUDE_DIR-NOTFOUND")
539 message(FATAL_ERROR "Cannot locate the OrthancFramework.h header")
540 endif()
541
542 message("Orthanc framework include dir: ${ORTHANC_FRAMEWORK_INCLUDE_DIR}")
543 include_directories(${ORTHANC_FRAMEWORK_INCLUDE_DIR})
544
545 if ("${ORTHANC_FRAMEWORK_LIBDIR}" STREQUAL "")
546 set(ORTHANC_FRAMEWORK_LIBRARIES OrthancFramework)
547 else()
548 if (MSVC)
549 set(Suffix ".lib")
550 set(Prefix "")
551 else()
552 list(GET CMAKE_FIND_LIBRARY_PREFIXES 0 Prefix)
553 list(GET CMAKE_FIND_LIBRARY_SUFFIXES 0 Suffix)
554 endif()
555 set(ORTHANC_FRAMEWORK_LIBRARIES ${ORTHANC_FRAMEWORK_LIBDIR}/${Prefix}OrthancFramework${Suffix})
556 endif()
557
558 set(CMAKE_REQUIRED_INCLUDES "${ORTHANC_FRAMEWORK_INCLUDE_DIR}")
559 set(CMAKE_REQUIRED_LIBRARIES "${ORTHANC_FRAMEWORK_LIBRARIES}")
560
561 check_cxx_symbol_exists("Orthanc::InitializeFramework" "OrthancFramework.h" HAVE_ORTHANC_FRAMEWORK)
562 if (NOT HAVE_ORTHANC_FRAMEWORK)
563 message(FATAL_ERROR "Cannot find the Orthanc framework")
564 endif()
565
566 unset(CMAKE_REQUIRED_INCLUDES)
567 unset(CMAKE_REQUIRED_LIBRARIES)
568 endif()