Mercurial > hg > orthanc-python
comparison Resources/Orthanc/CMake/DownloadOrthancFramework.cmake @ 46:3e2ff3616e57
sync
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 04 Aug 2020 13:31:27 +0200 |
parents | 393d2da0722a |
children | 0f8c9ce124d6 |
comparison
equal
deleted
inserted
replaced
45:ee76cced46a5 | 46:3e2ff3616e57 |
---|---|
125 set(ORTHANC_FRAMEWORK_MD5 "7e09e9b530a2f527854f0b782d7e0645") | 125 set(ORTHANC_FRAMEWORK_MD5 "7e09e9b530a2f527854f0b782d7e0645") |
126 endif() | 126 endif() |
127 endif() | 127 endif() |
128 endif() | 128 endif() |
129 | 129 |
130 elseif (NOT ORTHANC_FRAMEWORK_SOURCE STREQUAL "system") | 130 elseif (ORTHANC_FRAMEWORK_SOURCE STREQUAL "path") |
131 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.") |
132 set(ORTHANC_FRAMEWORK_MAJOR 999) | 132 set(ORTHANC_FRAMEWORK_MAJOR 999) |
133 set(ORTHANC_FRAMEWORK_MINOR 999) | 133 set(ORTHANC_FRAMEWORK_MINOR 999) |
134 set(ORTHANC_FRAMEWORK_REVISION 999) | 134 set(ORTHANC_FRAMEWORK_REVISION 999) |
135 endif() | 135 endif() |
175 ## | 175 ## |
176 ## 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 |
177 ## | 177 ## |
178 | 178 |
179 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "path") | 179 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "path") |
180 if (NOT DEFINED ORTHANC_FRAMEWORK_ROOT) | 180 if (NOT DEFINED ORTHANC_FRAMEWORK_ROOT OR |
181 ORTHANC_FRAMEWORK_ROOT STREQUAL "") | |
181 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") |
182 endif() | 183 endif() |
183 | 184 |
184 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT}) | 185 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT}) |
185 message(FATAL_ERROR "Non-existing directory: ${ORTHANC_FRAMEWORK_ROOT}") | 186 message(FATAL_ERROR "Non-existing directory: ${ORTHANC_FRAMEWORK_ROOT}") |
186 endif() | |
187 | |
188 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT}/Resources/CMake/OrthancFrameworkParameters.cmake) | |
189 message(FATAL_ERROR "Directory not containing the source code of the Orthanc framework: ${ORTHANC_FRAMEWORK_ROOT}") | |
190 endif() | 187 endif() |
191 endif() | 188 endif() |
192 | 189 |
193 | 190 |
194 | 191 |
232 ) | 229 ) |
233 | 230 |
234 if (Failure) | 231 if (Failure) |
235 message(FATAL_ERROR "Error while running Mercurial") | 232 message(FATAL_ERROR "Error while running Mercurial") |
236 endif() | 233 endif() |
237 | |
238 unset(ORTHANC_FRAMEWORK_ROOT CACHE) | |
239 set(ORTHANC_FRAMEWORK_ROOT "${ORTHANC_ROOT}/OrthancFramework" CACHE | |
240 STRING "Path to the Orthanc framework source directory") | |
241 | |
242 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT}/Resources/CMake/OrthancFrameworkParameters.cmake) | |
243 message(FATAL_ERROR "Directory not containing the source code of the Orthanc framework: ${ORTHANC_ROOT}") | |
244 endif() | |
245 | |
246 unset(ORTHANC_ROOT) | |
247 endif() | 234 endif() |
248 | 235 |
249 | 236 |
250 | 237 |
251 ## | 238 ## |
252 ## 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 |
253 ## filesystem | 240 ## filesystem |
254 ## | 241 ## |
255 | 242 |
256 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "archive") | 243 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "archive") |
257 if (NOT DEFINED ORTHANC_FRAMEWORK_ARCHIVE) | 244 if (NOT DEFINED ORTHANC_FRAMEWORK_ARCHIVE OR |
245 ORTHANC_FRAMEWORK_ARCHIVE STREQUAL "") | |
258 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") |
259 endif() | 247 endif() |
260 endif() | 248 endif() |
261 | 249 |
262 | 250 |
369 | 357 |
370 if (NOT IS_DIRECTORY "${ORTHANC_ROOT}") | 358 if (NOT IS_DIRECTORY "${ORTHANC_ROOT}") |
371 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.") |
372 endif() | 360 endif() |
373 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() | |
374 | 379 |
375 unset(ORTHANC_FRAMEWORK_ROOT CACHE) | 380 unset(ORTHANC_FRAMEWORK_ROOT CACHE) |
376 set(ORTHANC_FRAMEWORK_ROOT "${ORTHANC_ROOT}/OrthancFramework" CACHE | 381 |
377 STRING "Path to the Orthanc framework source directory") | 382 if ("${ORTHANC_FRAMEWORK_MAJOR}.${ORTHANC_FRAMEWORK_MINOR}.${ORTHANC_FRAMEWORK_REVISION}" VERSION_LESS "1.7.2") |
378 | 383 set(ORTHANC_FRAMEWORK_ROOT "${ORTHANC_ROOT}/Core" CACHE |
379 if (NOT EXISTS ${ORTHANC_FRAMEWORK_ROOT}/Resources/CMake/OrthancFrameworkParameters.cmake) | 384 STRING "Path to the Orthanc framework source directory") |
380 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") | |
381 endif() | 389 endif() |
382 | 390 |
383 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() | |
384 endif() | 399 endif() |
385 | 400 |
386 | 401 |
387 | 402 |
388 ## | 403 ## |
425 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) |
426 if (NOT HAVE_JSONCPP_H) | 441 if (NOT HAVE_JSONCPP_H) |
427 message(FATAL_ERROR "Please install the libjsoncpp-dev package") | 442 message(FATAL_ERROR "Please install the libjsoncpp-dev package") |
428 endif() | 443 endif() |
429 | 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 | |
430 # Look for mandatory dependency Boost (cf. BoostConfiguration.cmake) | 474 # Look for mandatory dependency Boost (cf. BoostConfiguration.cmake) |
431 include(FindBoost) | 475 include(FindBoost) |
432 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}) |
433 | 477 |
434 if (NOT Boost_FOUND) | 478 if (NOT Boost_FOUND) |
517 message(FATAL_ERROR "Cannot find the Orthanc framework") | 561 message(FATAL_ERROR "Cannot find the Orthanc framework") |
518 endif() | 562 endif() |
519 | 563 |
520 unset(CMAKE_REQUIRED_INCLUDES) | 564 unset(CMAKE_REQUIRED_INCLUDES) |
521 unset(CMAKE_REQUIRED_LIBRARIES) | 565 unset(CMAKE_REQUIRED_LIBRARIES) |
522 | 566 endif() |
523 if (NOT "${ORTHANC_FRAMEWORK_ROOT}" STREQUAL "") | |
524 include_directories(${ORTHANC_FRAMEWORK_ROOT}) | |
525 endif() | |
526 endif() |