comparison Resources/Orthanc/CMake/DownloadOrthancFramework.cmake @ 29:a0af5a8182a8

sync, removed old patch for Orthanc framework 1.5.6
author Sebastien Jodogne <s.jodogne@gmail.com>
date Tue, 04 Aug 2020 14:26:01 +0200
parents b7e32fe4973b
children 3abebab5d004
comparison
equal deleted inserted replaced
28:b7e32fe4973b 29:a0af5a8182a8
108 set(ORTHANC_FRAMEWORK_MD5 "3971f5de96ba71dc9d3f3690afeaa7c0") 108 set(ORTHANC_FRAMEWORK_MD5 "3971f5de96ba71dc9d3f3690afeaa7c0")
109 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.7.0") 109 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.7.0")
110 set(ORTHANC_FRAMEWORK_MD5 "ce5f689e852b01d3672bd3d2f952a5ef") 110 set(ORTHANC_FRAMEWORK_MD5 "ce5f689e852b01d3672bd3d2f952a5ef")
111 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.7.1") 111 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.7.1")
112 set(ORTHANC_FRAMEWORK_MD5 "3c171217f930abe80246997bdbcaf7cc") 112 set(ORTHANC_FRAMEWORK_MD5 "3c171217f930abe80246997bdbcaf7cc")
113 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.7.2")
114 set(ORTHANC_FRAMEWORK_MD5 "328f94dcbd78c169655a13f7ad58a2c2")
113 115
114 # Below this point are development snapshots that were used to 116 # Below this point are development snapshots that were used to
115 # release some plugin, before an official release of the Orthanc 117 # release some plugin, before an official release of the Orthanc
116 # framework was available. Here is the command to be used to 118 # framework was available. Here is the command to be used to
117 # generate a proper archive: 119 # generate a proper archive:
123 set(ORTHANC_FRAMEWORK_MD5 "7e09e9b530a2f527854f0b782d7e0645") 125 set(ORTHANC_FRAMEWORK_MD5 "7e09e9b530a2f527854f0b782d7e0645")
124 endif() 126 endif()
125 endif() 127 endif()
126 endif() 128 endif()
127 129
128 elseif (NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "system") 130 elseif (ORTHANC_FRAMEWORK_SOURCE STREQUAL "path")
129 message("Using the Orthanc framework from a path of the filesystem. Assuming mainline version.") 131 message("Using the Orthanc framework from a path of the filesystem. Assuming mainline version.")
130 set(ORTHANC_FRAMEWORK_MAJOR 999) 132 set(ORTHANC_FRAMEWORK_MAJOR 999)
131 set(ORTHANC_FRAMEWORK_MINOR 999) 133 set(ORTHANC_FRAMEWORK_MINOR 999)
132 set(ORTHANC_FRAMEWORK_REVISION 999) 134 set(ORTHANC_FRAMEWORK_REVISION 999)
133 endif() 135 endif()
173 ## 175 ##
174 ## Case of the Orthanc framework specified as a path on the filesystem 176 ## Case of the Orthanc framework specified as a path on the filesystem
175 ## 177 ##
176 178
177 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "path") 179 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "path")
178 if (NOT DEFINED ORTHANC_FRAMEWORK_ROOT) 180 if (NOT DEFINED ORTHANC_FRAMEWORK_ROOT OR
181 ORTHANC_FRAMEWORK_ROOT STREQUAL "")
179 message(FATAL_ERROR "The variable ORTHANC_FRAMEWORK_ROOT must provide the path to the sources of Orthanc") 182 message(FATAL_ERROR "The variable ORTHANC_FRAMEWORK_ROOT must provide the path to the sources of Orthanc")
180 endif() 183 endif()
181 184
182 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT}) 185 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT})
183 message(FATAL_ERROR "Non-existing directory: ${ORTHANC_FRAMEWORK_ROOT}") 186 message(FATAL_ERROR "Non-existing directory: ${ORTHANC_FRAMEWORK_ROOT}")
184 endif()
185
186 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT}/Resources/CMake/OrthancFrameworkParameters.cmake)
187 message(FATAL_ERROR "Directory not containing the source code of the Orthanc framework: ${ORTHANC_FRAMEWORK_ROOT}")
188 endif() 187 endif()
189 endif() 188 endif()
190 189
191 190
192 191
230 ) 229 )
231 230
232 if (Failure) 231 if (Failure)
233 message(FATAL_ERROR "Error while running Mercurial") 232 message(FATAL_ERROR "Error while running Mercurial")
234 endif() 233 endif()
235
236 unset(ORTHANC_FRAMEWORK_ROOT CACHE)
237 set(ORTHANC_FRAMEWORK_ROOT "${ORTHANC_ROOT}/OrthancFramework" CACHE
238 STRING "Path to the Orthanc framework source directory")
239
240 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT}/Resources/CMake/OrthancFrameworkParameters.cmake)
241 message(FATAL_ERROR "Directory not containing the source code of the Orthanc framework: ${ORTHANC_ROOT}")
242 endif()
243
244 unset(ORTHANC_ROOT)
245 endif() 234 endif()
246 235
247 236
248 237
249 ## 238 ##
250 ## Case of the Orthanc framework provided as a source archive on the 239 ## Case of the Orthanc framework provided as a source archive on the
251 ## filesystem 240 ## filesystem
252 ## 241 ##
253 242
254 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "archive") 243 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "archive")
255 if (NOT DEFINED ORTHANC_FRAMEWORK_ARCHIVE) 244 if (NOT DEFINED ORTHANC_FRAMEWORK_ARCHIVE OR
245 ORTHANC_FRAMEWORK_ARCHIVE STREQUAL "")
256 message(FATAL_ERROR "The variable ORTHANC_FRAMEWORK_ARCHIVE must provide the path to the sources of Orthanc") 246 message(FATAL_ERROR "The variable ORTHANC_FRAMEWORK_ARCHIVE must provide the path to the sources of Orthanc")
257 endif() 247 endif()
258 endif() 248 endif()
259 249
260 250
367 357
368 if (NOT IS_DIRECTORY "${ORTHANC_ROOT}") 358 if (NOT IS_DIRECTORY "${ORTHANC_ROOT}")
369 message(FATAL_ERROR "The Orthanc framework was not uncompressed at the proper location. Check the CMake instructions.") 359 message(FATAL_ERROR "The Orthanc framework was not uncompressed at the proper location. Check the CMake instructions.")
370 endif() 360 endif()
371 endif() 361 endif()
362 endif()
363
364
365
366 ##
367 ## Determine the path to the sources of the Orthanc framework
368 ##
369
370 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "archive" OR
371 ORTHANC_FRAMEWORK_SOURCE STREQUAL "hg" OR
372 ORTHANC_FRAMEWORK_SOURCE STREQUAL "web")
373 if (NOT DEFINED ORTHANC_ROOT OR
374 NOT DEFINED ORTHANC_FRAMEWORK_MAJOR OR
375 NOT DEFINED ORTHANC_FRAMEWORK_MINOR OR
376 NOT DEFINED ORTHANC_FRAMEWORK_REVISION)
377 message(FATAL_ERROR "Internal error in the DownloadOrthancFramework.cmake file")
378 endif()
372 379
373 unset(ORTHANC_FRAMEWORK_ROOT CACHE) 380 unset(ORTHANC_FRAMEWORK_ROOT CACHE)
374 set(ORTHANC_FRAMEWORK_ROOT "${ORTHANC_ROOT}/OrthancFramework" CACHE 381
375 STRING "Path to the Orthanc framework source directory") 382 if ("${ORTHANC_FRAMEWORK_MAJOR}.${ORTHANC_FRAMEWORK_MINOR}.${ORTHANC_FRAMEWORK_REVISION}" VERSION_LESS "1.7.2")
376 383 set(ORTHANC_FRAMEWORK_ROOT "${ORTHANC_ROOT}/Core" CACHE
377 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT}/Resources/CMake/OrthancFrameworkParameters.cmake) 384 STRING "Path to the Orthanc framework source directory")
378 message(FATAL_ERROR "Directory not containing the source code of the Orthanc framework: ${ORTHANC_ROOT}") 385 set(ENABLE_PLUGINS_VERSION_SCRIPT OFF)
386 else()
387 set(ORTHANC_FRAMEWORK_ROOT "${ORTHANC_ROOT}/OrthancFramework/Sources" CACHE
388 STRING "Path to the Orthanc framework source directory")
379 endif() 389 endif()
380 390
381 unset(ORTHANC_ROOT) 391 unset(ORTHANC_ROOT)
392 endif()
393
394 if (NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "system")
395 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT}/OrthancException.h OR
396 NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT}/../Resources/CMake/OrthancFrameworkParameters.cmake)
397 message(FATAL_ERROR "Directory not containing the source code of the Orthanc framework: ${ORTHANC_FRAMEWORK_ROOT}")
398 endif()
382 endif() 399 endif()
383 400
384 401
385 402
386 ## 403 ##
423 CHECK_INCLUDE_FILE_CXX(${JSONCPP_INCLUDE_DIR}/json/reader.h HAVE_JSONCPP_H) 440 CHECK_INCLUDE_FILE_CXX(${JSONCPP_INCLUDE_DIR}/json/reader.h HAVE_JSONCPP_H)
424 if (NOT HAVE_JSONCPP_H) 441 if (NOT HAVE_JSONCPP_H)
425 message(FATAL_ERROR "Please install the libjsoncpp-dev package") 442 message(FATAL_ERROR "Please install the libjsoncpp-dev package")
426 endif() 443 endif()
427 444
445 # Switch to the C++11 standard if the version of JsonCpp is 1.y.z
446 # (same as variable JSONCPP_CXX11 in the source code of Orthanc)
447 if (EXISTS ${JSONCPP_INCLUDE_DIR}/json/version.h)
448 file(STRINGS
449 "${JSONCPP_INCLUDE_DIR}/json/version.h"
450 JSONCPP_VERSION_MAJOR1 REGEX
451 ".*define JSONCPP_VERSION_MAJOR.*")
452
453 if (NOT JSONCPP_VERSION_MAJOR1)
454 message(FATAL_ERROR "Unable to extract the major version of JsonCpp")
455 endif()
456
457 string(REGEX REPLACE
458 ".*JSONCPP_VERSION_MAJOR.*([0-9]+)$" "\\1"
459 JSONCPP_VERSION_MAJOR ${JSONCPP_VERSION_MAJOR1})
460 message("JsonCpp major version: ${JSONCPP_VERSION_MAJOR}")
461
462 if (JSONCPP_VERSION_MAJOR GREATER 0)
463 message("Switching to C++11 standard, as version of JsonCpp is >= 1.0.0")
464 if (CMAKE_COMPILER_IS_GNUCXX)
465 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")
466 elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
467 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
468 endif()
469 endif()
470 else()
471 message("Unable to detect the major version of JsonCpp, assuming < 1.0.0")
472 endif()
473
428 # Look for mandatory dependency Boost (cf. BoostConfiguration.cmake) 474 # Look for mandatory dependency Boost (cf. BoostConfiguration.cmake)
429 include(FindBoost) 475 include(FindBoost)
430 find_package(Boost COMPONENTS filesystem thread system date_time regex ${ORTHANC_BOOST_COMPONENTS}) 476 find_package(Boost COMPONENTS filesystem thread system date_time regex ${ORTHANC_BOOST_COMPONENTS})
431 477
432 if (NOT Boost_FOUND) 478 if (NOT Boost_FOUND)
515 message(FATAL_ERROR "Cannot find the Orthanc framework") 561 message(FATAL_ERROR "Cannot find the Orthanc framework")
516 endif() 562 endif()
517 563
518 unset(CMAKE_REQUIRED_INCLUDES) 564 unset(CMAKE_REQUIRED_INCLUDES)
519 unset(CMAKE_REQUIRED_LIBRARIES) 565 unset(CMAKE_REQUIRED_LIBRARIES)
520 566 endif()
521 if (NOT "${ORTHANC_FRAMEWORK_ROOT}" STREQUAL "")
522 include_directories(${ORTHANC_FRAMEWORK_ROOT})
523 endif()
524 endif()