Mercurial > hg > orthanc-wsi
comparison Resources/Orthanc/CMake/DownloadOrthancFramework.cmake @ 238:476d5204d08b
sync
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 14 May 2021 07:37:08 +0200 |
parents | 1e864138f0da |
children | 5ed8d1cee52d |
comparison
equal
deleted
inserted
replaced
237:c2863f5204a8 | 238:476d5204d08b |
---|---|
120 set(ORTHANC_FRAMEWORK_MD5 "f8ec7554ef5d23ea4ce474b1e8214de9") | 120 set(ORTHANC_FRAMEWORK_MD5 "f8ec7554ef5d23ea4ce474b1e8214de9") |
121 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.8.1") | 121 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.8.1") |
122 set(ORTHANC_FRAMEWORK_MD5 "db094f96399cbe8b9bbdbce34884c220") | 122 set(ORTHANC_FRAMEWORK_MD5 "db094f96399cbe8b9bbdbce34884c220") |
123 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.8.2") | 123 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.8.2") |
124 set(ORTHANC_FRAMEWORK_MD5 "8bfa10e66c9931e74111be0bfb1f4548") | 124 set(ORTHANC_FRAMEWORK_MD5 "8bfa10e66c9931e74111be0bfb1f4548") |
125 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.9.0") | |
126 set(ORTHANC_FRAMEWORK_MD5 "cea0b02ce184671eaf1bd668beefbf28") | |
127 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.9.1") | |
128 set(ORTHANC_FRAMEWORK_MD5 "08eebc66ef93c3b40115c38501db5fbd") | |
129 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.9.2") | |
130 set(ORTHANC_FRAMEWORK_MD5 "3ea66c09f64aca990016683b6375734e") | |
131 elseif (ORTHANC_FRAMEWORK_VERSION STREQUAL "1.9.3") | |
132 set(ORTHANC_FRAMEWORK_MD5 "9b86e6f00e03278293cd15643cc0233f") | |
125 | 133 |
126 # Below this point are development snapshots that were used to | 134 # Below this point are development snapshots that were used to |
127 # release some plugin, before an official release of the Orthanc | 135 # release some plugin, before an official release of the Orthanc |
128 # framework was available. Here is the command to be used to | 136 # framework was available. Here is the command to be used to |
129 # generate a proper archive: | 137 # generate a proper archive: |
424 ## GNU/Linux distribution (typically Debian). New in Orthanc 1.7.2. | 432 ## GNU/Linux distribution (typically Debian). New in Orthanc 1.7.2. |
425 ## | 433 ## |
426 | 434 |
427 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "system") | 435 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "system") |
428 set(ORTHANC_FRAMEWORK_LIBDIR "" CACHE PATH "") | 436 set(ORTHANC_FRAMEWORK_LIBDIR "" CACHE PATH "") |
437 set(ORTHANC_FRAMEWORK_USE_SHARED ON CACHE BOOL "Whether to use the shared library or the static library") | |
438 set(ORTHANC_FRAMEWORK_ADDITIONAL_LIBRARIES "" CACHE STRING "Additional libraries to link against, separated by whitespaces, typically needed if using the static library (a common minimal value is \"boost_filesystem boost_iostreams boost_locale boost_regex boost_thread jsoncpp pugixml uuid\")") | |
429 | 439 |
430 if (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND | 440 if (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND |
431 CMAKE_COMPILER_IS_GNUCXX) # MinGW | 441 CMAKE_COMPILER_IS_GNUCXX) # MinGW |
432 set(DYNAMIC_MINGW_STDLIB ON) # Disable static linking against libc (to throw exceptions) | 442 set(DYNAMIC_MINGW_STDLIB ON) # Disable static linking against libc (to throw exceptions) |
433 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libstdc++") | 443 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libstdc++") |
440 include(${CMAKE_CURRENT_LIST_DIR}/Compiler.cmake) | 450 include(${CMAKE_CURRENT_LIST_DIR}/Compiler.cmake) |
441 include(${CMAKE_CURRENT_LIST_DIR}/DownloadPackage.cmake) | 451 include(${CMAKE_CURRENT_LIST_DIR}/DownloadPackage.cmake) |
442 include(${CMAKE_CURRENT_LIST_DIR}/AutoGeneratedCode.cmake) | 452 include(${CMAKE_CURRENT_LIST_DIR}/AutoGeneratedCode.cmake) |
443 set(EMBED_RESOURCES_PYTHON ${CMAKE_CURRENT_LIST_DIR}/EmbedResources.py) | 453 set(EMBED_RESOURCES_PYTHON ${CMAKE_CURRENT_LIST_DIR}/EmbedResources.py) |
444 | 454 |
445 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" OR | 455 if (ORTHANC_FRAMEWORK_USE_SHARED) |
446 ORTHANC_FRAMEWORK_STATIC) | 456 list(GET CMAKE_FIND_LIBRARY_PREFIXES 0 Prefix) |
447 include_directories(${ORTHANC_FRAMEWORK_ROOT}/..) | 457 list(GET CMAKE_FIND_LIBRARY_SUFFIXES 0 Suffix) |
448 else() | 458 else() |
449 # Look for mandatory dependency JsonCpp (cf. JsonCppConfiguration.cmake) | 459 list(GET CMAKE_FIND_LIBRARY_PREFIXES 0 Prefix) |
460 list(GET CMAKE_FIND_LIBRARY_SUFFIXES 1 Suffix) | |
461 endif() | |
462 | |
463 # The "OrthancFramework" library must be the first one to be included | |
464 if ("${ORTHANC_FRAMEWORK_LIBDIR}" STREQUAL "") | |
465 set(ORTHANC_FRAMEWORK_LIBRARIES ${Prefix}OrthancFramework${Suffix}) | |
466 else () | |
467 set(ORTHANC_FRAMEWORK_LIBRARIES ${ORTHANC_FRAMEWORK_LIBDIR}/${Prefix}OrthancFramework${Suffix}) | |
468 endif() | |
469 | |
470 if (NOT ORTHANC_FRAMEWORK_ADDITIONAL_LIBRARIES STREQUAL "") | |
471 # https://stackoverflow.com/a/5272993/881731 | |
472 string(REPLACE " " ";" tmp ${ORTHANC_FRAMEWORK_ADDITIONAL_LIBRARIES}) | |
473 list(APPEND ORTHANC_FRAMEWORK_LIBRARIES ${tmp}) | |
474 endif() | |
475 | |
476 # Look for the version of the mandatory dependency JsonCpp (cf. JsonCppConfiguration.cmake) | |
477 if (CMAKE_CROSSCOMPILING) | |
478 set(JSONCPP_INCLUDE_DIR ${ORTHANC_FRAMEWORK_ROOT}/..) | |
479 else() | |
450 find_path(JSONCPP_INCLUDE_DIR json/reader.h | 480 find_path(JSONCPP_INCLUDE_DIR json/reader.h |
481 ${ORTHANC_FRAMEWORK_ROOT}/.. | |
451 /usr/include/jsoncpp | 482 /usr/include/jsoncpp |
452 /usr/local/include/jsoncpp | 483 /usr/local/include/jsoncpp |
453 ) | 484 ) |
454 | 485 endif() |
455 message("JsonCpp include dir: ${JSONCPP_INCLUDE_DIR}") | 486 |
456 include_directories(${JSONCPP_INCLUDE_DIR}) | 487 message("JsonCpp include dir: ${JSONCPP_INCLUDE_DIR}") |
457 link_libraries(jsoncpp) | 488 include_directories(${JSONCPP_INCLUDE_DIR}) |
458 | 489 |
459 CHECK_INCLUDE_FILE_CXX(${JSONCPP_INCLUDE_DIR}/json/reader.h HAVE_JSONCPP_H) | 490 CHECK_INCLUDE_FILE_CXX(${JSONCPP_INCLUDE_DIR}/json/reader.h HAVE_JSONCPP_H) |
460 if (NOT HAVE_JSONCPP_H) | 491 if (NOT HAVE_JSONCPP_H) |
461 message(FATAL_ERROR "Please install the libjsoncpp-dev package") | 492 message(FATAL_ERROR "Please install the libjsoncpp-dev package") |
462 endif() | 493 endif() |
463 | 494 |
464 # Switch to the C++11 standard if the version of JsonCpp is 1.y.z | 495 # Switch to the C++11 standard if the version of JsonCpp is 1.y.z |
465 # (same as variable JSONCPP_CXX11 in the source code of Orthanc) | 496 # (same as variable JSONCPP_CXX11 in the source code of Orthanc) |
466 if (EXISTS ${JSONCPP_INCLUDE_DIR}/json/version.h) | 497 if (EXISTS ${JSONCPP_INCLUDE_DIR}/json/version.h) |
467 file(STRINGS | 498 file(STRINGS |
468 "${JSONCPP_INCLUDE_DIR}/json/version.h" | 499 "${JSONCPP_INCLUDE_DIR}/json/version.h" |
469 JSONCPP_VERSION_MAJOR1 REGEX | 500 JSONCPP_VERSION_MAJOR1 REGEX |
470 ".*define JSONCPP_VERSION_MAJOR.*") | 501 ".*define JSONCPP_VERSION_MAJOR.*") |
471 | 502 |
472 if (NOT JSONCPP_VERSION_MAJOR1) | 503 if (NOT JSONCPP_VERSION_MAJOR1) |
473 message(FATAL_ERROR "Unable to extract the major version of JsonCpp") | 504 message(FATAL_ERROR "Unable to extract the major version of JsonCpp") |
505 endif() | |
506 | |
507 string(REGEX REPLACE | |
508 ".*JSONCPP_VERSION_MAJOR.*([0-9]+)$" "\\1" | |
509 JSONCPP_VERSION_MAJOR ${JSONCPP_VERSION_MAJOR1}) | |
510 message("JsonCpp major version: ${JSONCPP_VERSION_MAJOR}") | |
511 | |
512 if (JSONCPP_VERSION_MAJOR GREATER 0) | |
513 message("Switching to C++11 standard, as version of JsonCpp is >= 1.0.0") | |
514 if (CMAKE_COMPILER_IS_GNUCXX) | |
515 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") | |
516 elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") | |
517 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | |
474 endif() | 518 endif() |
475 | 519 endif() |
476 string(REGEX REPLACE | 520 else() |
477 ".*JSONCPP_VERSION_MAJOR.*([0-9]+)$" "\\1" | 521 message("Unable to detect the major version of JsonCpp, assuming < 1.0.0") |
478 JSONCPP_VERSION_MAJOR ${JSONCPP_VERSION_MAJOR1}) | 522 endif() |
479 message("JsonCpp major version: ${JSONCPP_VERSION_MAJOR}") | 523 |
480 | |
481 if (JSONCPP_VERSION_MAJOR GREATER 0) | |
482 message("Switching to C++11 standard, as version of JsonCpp is >= 1.0.0") | |
483 if (CMAKE_COMPILER_IS_GNUCXX) | |
484 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") | |
485 elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") | |
486 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") | |
487 endif() | |
488 endif() | |
489 else() | |
490 message("Unable to detect the major version of JsonCpp, assuming < 1.0.0") | |
491 endif() | |
492 | |
493 # Look for mandatory dependency Boost (cf. BoostConfiguration.cmake) | |
494 include(FindBoost) | |
495 find_package(Boost COMPONENTS filesystem thread system date_time regex ${ORTHANC_BOOST_COMPONENTS}) | |
496 | |
497 if (NOT Boost_FOUND) | |
498 message(FATAL_ERROR "Unable to locate Boost on this system") | |
499 endif() | |
500 | |
501 include_directories(${Boost_INCLUDE_DIRS}) | |
502 link_libraries(${Boost_LIBRARIES}) | |
503 | |
504 # Optional component - Lua | |
505 if (ENABLE_LUA) | |
506 include(FindLua) | |
507 | |
508 if (NOT LUA_FOUND) | |
509 message(FATAL_ERROR "Please install the liblua-dev package") | |
510 endif() | |
511 | |
512 include_directories(${LUA_INCLUDE_DIR}) | |
513 link_libraries(${LUA_LIBRARIES}) | |
514 endif() | |
515 | |
516 # Optional component - SQLite | |
517 if (ENABLE_SQLITE) | |
518 CHECK_INCLUDE_FILE(sqlite3.h HAVE_SQLITE_H) | |
519 if (NOT HAVE_SQLITE_H) | |
520 message(FATAL_ERROR "Please install the libsqlite3-dev package") | |
521 endif() | |
522 link_libraries(sqlite3) | |
523 endif() | |
524 | |
525 # Optional component - Pugixml | |
526 if (ENABLE_PUGIXML) | |
527 CHECK_INCLUDE_FILE_CXX(pugixml.hpp HAVE_PUGIXML_H) | |
528 if (NOT HAVE_PUGIXML_H) | |
529 message(FATAL_ERROR "Please install the libpugixml-dev package") | |
530 endif() | |
531 link_libraries(pugixml) | |
532 endif() | |
533 | |
534 # Optional component - DCMTK | |
535 if (ENABLE_DCMTK) | |
536 include(FindDCMTK) | |
537 include_directories(${DCMTK_INCLUDE_DIRS}) | |
538 link_libraries(${DCMTK_LIBRARIES}) | |
539 endif() | |
540 | |
541 # Optional component - OpenSSL | |
542 if (ENABLE_SSL) | |
543 include(FindOpenSSL) | |
544 if (NOT ${OPENSSL_FOUND}) | |
545 message(FATAL_ERROR "Unable to find OpenSSL") | |
546 endif() | |
547 include_directories(${OPENSSL_INCLUDE_DIR}) | |
548 link_libraries(${OPENSSL_LIBRARIES}) | |
549 endif() | |
550 endif() | |
551 | |
552 # Look for Orthanc framework shared library | 524 # Look for Orthanc framework shared library |
553 include(CheckCXXSymbolExists) | 525 include(CheckCXXSymbolExists) |
554 | 526 |
555 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") | 527 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") |
556 set(ORTHANC_FRAMEWORK_INCLUDE_DIR ${ORTHANC_FRAMEWORK_ROOT}) | 528 set(ORTHANC_FRAMEWORK_INCLUDE_DIR ${ORTHANC_FRAMEWORK_ROOT}) |
566 message(FATAL_ERROR "Cannot locate the OrthancFramework.h header") | 538 message(FATAL_ERROR "Cannot locate the OrthancFramework.h header") |
567 endif() | 539 endif() |
568 | 540 |
569 message("Orthanc framework include dir: ${ORTHANC_FRAMEWORK_INCLUDE_DIR}") | 541 message("Orthanc framework include dir: ${ORTHANC_FRAMEWORK_INCLUDE_DIR}") |
570 include_directories(${ORTHANC_FRAMEWORK_INCLUDE_DIR}) | 542 include_directories(${ORTHANC_FRAMEWORK_INCLUDE_DIR}) |
571 | 543 |
572 if ("${ORTHANC_FRAMEWORK_LIBDIR}" STREQUAL "") | 544 if (ORTHANC_FRAMEWORK_USE_SHARED) |
573 set(ORTHANC_FRAMEWORK_LIBRARIES OrthancFramework) | 545 set(CMAKE_REQUIRED_INCLUDES "${ORTHANC_FRAMEWORK_INCLUDE_DIR}") |
574 else() | 546 set(CMAKE_REQUIRED_LIBRARIES "${ORTHANC_FRAMEWORK_LIBRARIES}") |
575 if (MSVC) | 547 |
576 set(Suffix ".lib") | 548 check_cxx_symbol_exists("Orthanc::InitializeFramework" "OrthancFramework.h" HAVE_ORTHANC_FRAMEWORK) |
577 set(Prefix "") | 549 if (NOT HAVE_ORTHANC_FRAMEWORK) |
578 else() | 550 message(FATAL_ERROR "Cannot find the Orthanc framework") |
579 list(GET CMAKE_FIND_LIBRARY_PREFIXES 0 Prefix) | 551 endif() |
580 list(GET CMAKE_FIND_LIBRARY_SUFFIXES 0 Suffix) | 552 |
581 endif() | 553 unset(CMAKE_REQUIRED_INCLUDES) |
582 set(ORTHANC_FRAMEWORK_LIBRARIES ${ORTHANC_FRAMEWORK_LIBDIR}/${Prefix}OrthancFramework${Suffix}) | 554 unset(CMAKE_REQUIRED_LIBRARIES) |
583 endif() | 555 endif() |
584 | 556 endif() |
585 set(CMAKE_REQUIRED_INCLUDES "${ORTHANC_FRAMEWORK_INCLUDE_DIR}") | |
586 set(CMAKE_REQUIRED_LIBRARIES "${ORTHANC_FRAMEWORK_LIBRARIES}") | |
587 | |
588 check_cxx_symbol_exists("Orthanc::InitializeFramework" "OrthancFramework.h" HAVE_ORTHANC_FRAMEWORK) | |
589 if (NOT HAVE_ORTHANC_FRAMEWORK) | |
590 message(FATAL_ERROR "Cannot find the Orthanc framework") | |
591 endif() | |
592 | |
593 unset(CMAKE_REQUIRED_INCLUDES) | |
594 unset(CMAKE_REQUIRED_LIBRARIES) | |
595 endif() |