Mercurial > hg > orthanc
comparison OrthancFramework/Resources/CMake/DownloadOrthancFramework.cmake @ 4531:d64e6f401a8a
additional option in DownloadOrthancFramework: ORTHANC_FRAMEWORK_ADDITIONAL_LIBRARIES
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 25 Feb 2021 12:15:18 +0100 |
parents | e40148c916b8 |
children | d9700b9f4ad9 |
comparison
equal
deleted
inserted
replaced
4530:e40148c916b8 | 4531:d64e6f401a8a |
---|---|
427 ## | 427 ## |
428 | 428 |
429 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "system") | 429 if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "system") |
430 set(ORTHANC_FRAMEWORK_LIBDIR "" CACHE PATH "") | 430 set(ORTHANC_FRAMEWORK_LIBDIR "" CACHE PATH "") |
431 set(ORTHANC_FRAMEWORK_USE_SHARED ON CACHE BOOL "Whether to use the shared library or the static library") | 431 set(ORTHANC_FRAMEWORK_USE_SHARED ON CACHE BOOL "Whether to use the shared library or the static library") |
432 set(ORTHANC_FRAMEWORK_ADDITIONAL_LIBRARIES "" CACHE STRING "Additional libraries to link against, separated by whitespaces, typically needed if using the static library (a typical value is \"uuid curl civetweb\")") | |
432 | 433 |
433 if (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND | 434 if (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND |
434 CMAKE_COMPILER_IS_GNUCXX) # MinGW | 435 CMAKE_COMPILER_IS_GNUCXX) # MinGW |
435 set(DYNAMIC_MINGW_STDLIB ON) # Disable static linking against libc (to throw exceptions) | 436 set(DYNAMIC_MINGW_STDLIB ON) # Disable static linking against libc (to throw exceptions) |
436 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libstdc++") | 437 set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -static-libstdc++") |
458 endif() | 459 endif() |
459 set(ORTHANC_FRAMEWORK_LIBRARIES | 460 set(ORTHANC_FRAMEWORK_LIBRARIES |
460 ${ORTHANC_FRAMEWORK_LIBDIR}/${Prefix}OrthancFramework${Suffix}) | 461 ${ORTHANC_FRAMEWORK_LIBDIR}/${Prefix}OrthancFramework${Suffix}) |
461 endif() | 462 endif() |
462 | 463 |
464 if (NOT ORTHANC_FRAMEWORK_ADDITIONAL_LIBRARIES STREQUAL "") | |
465 # https://stackoverflow.com/a/5272993/881731 | |
466 string(REPLACE " " ";" tmp ${ORTHANC_FRAMEWORK_ADDITIONAL_LIBRARIES}) | |
467 list(APPEND ORTHANC_FRAMEWORK_LIBRARIES ${tmp}) | |
468 endif() | |
469 | |
463 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" OR | 470 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" OR |
464 ORTHANC_FRAMEWORK_STATIC) | 471 ORTHANC_FRAMEWORK_STATIC) |
465 include_directories(${ORTHANC_FRAMEWORK_ROOT}/..) | 472 include_directories(${ORTHANC_FRAMEWORK_ROOT}/..) |
466 else() | 473 else() |
467 # Look for mandatory dependency JsonCpp (cf. JsonCppConfiguration.cmake) | 474 # Look for mandatory dependency JsonCpp (cf. JsonCppConfiguration.cmake) |
520 | 527 |
521 include_directories(${Boost_INCLUDE_DIRS}) | 528 include_directories(${Boost_INCLUDE_DIRS}) |
522 list(APPEND ORTHANC_FRAMEWORK_LIBRARIES ${Boost_LIBRARIES}) | 529 list(APPEND ORTHANC_FRAMEWORK_LIBRARIES ${Boost_LIBRARIES}) |
523 | 530 |
524 # Optional component - Lua | 531 # Optional component - Lua |
525 if (ENABLE_LUA) | 532 if (ENABLE_LUA OR |
533 NOT ORTHANC_FRAMEWORK_USE_SHARED) | |
526 include(FindLua) | 534 include(FindLua) |
527 | 535 |
528 if (NOT LUA_FOUND) | 536 if (NOT LUA_FOUND) |
529 message(FATAL_ERROR "Please install the liblua-dev package") | 537 message(FATAL_ERROR "Please install the liblua-dev package") |
530 endif() | 538 endif() |
532 include_directories(${LUA_INCLUDE_DIR}) | 540 include_directories(${LUA_INCLUDE_DIR}) |
533 list(APPEND ORTHANC_FRAMEWORK_LIBRARIES ${LUA_LIBRARIES}) | 541 list(APPEND ORTHANC_FRAMEWORK_LIBRARIES ${LUA_LIBRARIES}) |
534 endif() | 542 endif() |
535 | 543 |
536 # Optional component - SQLite | 544 # Optional component - SQLite |
537 if (ENABLE_SQLITE) | 545 if (ENABLE_SQLITE OR |
546 NOT ORTHANC_FRAMEWORK_USE_SHARED) | |
538 CHECK_INCLUDE_FILE(sqlite3.h HAVE_SQLITE_H) | 547 CHECK_INCLUDE_FILE(sqlite3.h HAVE_SQLITE_H) |
539 if (NOT HAVE_SQLITE_H) | 548 if (NOT HAVE_SQLITE_H) |
540 message(FATAL_ERROR "Please install the libsqlite3-dev package") | 549 message(FATAL_ERROR "Please install the libsqlite3-dev package") |
541 endif() | 550 endif() |
542 list(APPEND ORTHANC_FRAMEWORK_LIBRARIES sqlite3) | 551 list(APPEND ORTHANC_FRAMEWORK_LIBRARIES sqlite3) |
543 endif() | 552 endif() |
544 | 553 |
545 # Optional component - Pugixml | 554 # Optional component - Pugixml |
546 if (ENABLE_PUGIXML) | 555 if (ENABLE_PUGIXML OR |
556 NOT ORTHANC_FRAMEWORK_USE_SHARED) | |
547 CHECK_INCLUDE_FILE_CXX(pugixml.hpp HAVE_PUGIXML_H) | 557 CHECK_INCLUDE_FILE_CXX(pugixml.hpp HAVE_PUGIXML_H) |
548 if (NOT HAVE_PUGIXML_H) | 558 if (NOT HAVE_PUGIXML_H) |
549 message(FATAL_ERROR "Please install the libpugixml-dev package") | 559 message(FATAL_ERROR "Please install the libpugixml-dev package") |
550 endif() | 560 endif() |
551 list(APPEND ORTHANC_FRAMEWORK_LIBRARIES pugixml) | 561 list(APPEND ORTHANC_FRAMEWORK_LIBRARIES pugixml) |
552 endif() | 562 endif() |
553 | 563 |
554 # Optional component - DCMTK | 564 # Optional component - DCMTK |
555 if (ENABLE_DCMTK) | 565 if (ENABLE_DCMTK OR |
566 NOT ORTHANC_FRAMEWORK_USE_SHARED) | |
556 include(FindDCMTK NO_MODULE) | 567 include(FindDCMTK NO_MODULE) |
557 list(APPEND ORTHANC_FRAMEWORK_LIBRARIES ${DCMTK_LIBRARIES}) | 568 list(APPEND ORTHANC_FRAMEWORK_LIBRARIES ${DCMTK_LIBRARIES}) |
558 include_directories(${DCMTK_INCLUDE_DIRS}) | 569 include_directories(${DCMTK_INCLUDE_DIRS}) |
559 endif() | 570 endif() |
560 | 571 |
561 # Optional component - OpenSSL | 572 # Optional component - OpenSSL |
562 if (ENABLE_SSL) | 573 if (ENABLE_SSL OR |
574 NOT ORTHANC_FRAMEWORK_USE_SHARED) | |
563 include(FindOpenSSL) | 575 include(FindOpenSSL) |
564 if (NOT ${OPENSSL_FOUND}) | 576 if (NOT ${OPENSSL_FOUND}) |
565 message(FATAL_ERROR "Unable to find OpenSSL") | 577 message(FATAL_ERROR "Unable to find OpenSSL") |
566 endif() | 578 endif() |
567 include_directories(${OPENSSL_INCLUDE_DIR}) | 579 include_directories(${OPENSSL_INCLUDE_DIR}) |
568 list(APPEND ORTHANC_FRAMEWORK_LIBRARIES ${OPENSSL_LIBRARIES}) | 580 list(APPEND ORTHANC_FRAMEWORK_LIBRARIES ${OPENSSL_LIBRARIES}) |
569 endif() | 581 endif() |
570 endif() | 582 endif() |
571 | 583 |
572 if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" AND | |
573 NOT ORTHANC_FRAMEWORK_USE_SHARED) | |
574 # Static library has more dependencies | |
575 | |
576 # Mandatory dependency: libuuid | |
577 CHECK_INCLUDE_FILE(uuid/uuid.h HAVE_UUID_H) | |
578 if (NOT HAVE_UUID_H) | |
579 message(FATAL_ERROR "Please install uuid-dev, e2fsprogs (OpenBSD) or e2fsprogs-libuuid (FreeBSD)") | |
580 endif() | |
581 | |
582 find_library(LIBUUID uuid | |
583 PATHS | |
584 /usr/lib | |
585 /usr/local/lib | |
586 ) | |
587 | |
588 check_library_exists(${LIBUUID} uuid_generate_random "" HAVE_LIBUUID) | |
589 if (NOT HAVE_LIBUUID) | |
590 message(FATAL_ERROR "Unable to find the uuid library") | |
591 endif() | |
592 | |
593 list(APPEND ORTHANC_FRAMEWORK_LIBRARIES ${LIBUUID}) | |
594 | |
595 # Optional component - libcurl | |
596 if (ENABLE_WEB_CLIENT) | |
597 include(FindCURL) | |
598 include_directories(${CURL_INCLUDE_DIRS}) | |
599 list(APPEND ORTHANC_FRAMEWORK_LIBRARIES ${CURL_LIBRARIES}) | |
600 endif() | |
601 | |
602 # Optional component - civetweb | |
603 if (ENABLE_WEB_SERVER) | |
604 CHECK_INCLUDE_FILE_CXX(civetweb.h HAVE_CIVETWEB_H) | |
605 if (NOT HAVE_CIVETWEB_H) | |
606 message(FATAL_ERROR "Please install the libcivetweb-dev package") | |
607 endif() | |
608 list(APPEND ORTHANC_FRAMEWORK_LIBRARIES civetweb) | |
609 endif() | |
610 endif() | |
611 | |
612 # Look for Orthanc framework shared library | 584 # Look for Orthanc framework shared library |
613 include(CheckCXXSymbolExists) | 585 include(CheckCXXSymbolExists) |
614 | 586 |
615 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") | 587 if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows") |
616 set(ORTHANC_FRAMEWORK_INCLUDE_DIR ${ORTHANC_FRAMEWORK_ROOT}) | 588 set(ORTHANC_FRAMEWORK_INCLUDE_DIR ${ORTHANC_FRAMEWORK_ROOT}) |