Mercurial > hg > orthanc
changeset 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 | 11bfea08341a d9700b9f4ad9 |
files | OrthancFramework/Resources/CMake/DownloadOrthancFramework.cmake OrthancFramework/SharedLibrary/CMakeLists.txt OrthancFramework/UnitTestsSources/CMakeLists.txt |
diffstat | 3 files changed, 23 insertions(+), 46 deletions(-) [+] |
line wrap: on
line diff
--- a/OrthancFramework/Resources/CMake/DownloadOrthancFramework.cmake Thu Feb 25 11:02:23 2021 +0100 +++ b/OrthancFramework/Resources/CMake/DownloadOrthancFramework.cmake Thu Feb 25 12:15:18 2021 +0100 @@ -429,6 +429,7 @@ if (ORTHANC_FRAMEWORK_SOURCE STREQUAL "system") set(ORTHANC_FRAMEWORK_LIBDIR "" CACHE PATH "") set(ORTHANC_FRAMEWORK_USE_SHARED ON CACHE BOOL "Whether to use the shared library or the static library") + 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\")") if (CMAKE_SYSTEM_NAME STREQUAL "Windows" AND CMAKE_COMPILER_IS_GNUCXX) # MinGW @@ -460,6 +461,12 @@ ${ORTHANC_FRAMEWORK_LIBDIR}/${Prefix}OrthancFramework${Suffix}) endif() + if (NOT ORTHANC_FRAMEWORK_ADDITIONAL_LIBRARIES STREQUAL "") + # https://stackoverflow.com/a/5272993/881731 + string(REPLACE " " ";" tmp ${ORTHANC_FRAMEWORK_ADDITIONAL_LIBRARIES}) + list(APPEND ORTHANC_FRAMEWORK_LIBRARIES ${tmp}) + endif() + if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" OR ORTHANC_FRAMEWORK_STATIC) include_directories(${ORTHANC_FRAMEWORK_ROOT}/..) @@ -522,7 +529,8 @@ list(APPEND ORTHANC_FRAMEWORK_LIBRARIES ${Boost_LIBRARIES}) # Optional component - Lua - if (ENABLE_LUA) + if (ENABLE_LUA OR + NOT ORTHANC_FRAMEWORK_USE_SHARED) include(FindLua) if (NOT LUA_FOUND) @@ -534,7 +542,8 @@ endif() # Optional component - SQLite - if (ENABLE_SQLITE) + if (ENABLE_SQLITE OR + NOT ORTHANC_FRAMEWORK_USE_SHARED) CHECK_INCLUDE_FILE(sqlite3.h HAVE_SQLITE_H) if (NOT HAVE_SQLITE_H) message(FATAL_ERROR "Please install the libsqlite3-dev package") @@ -543,7 +552,8 @@ endif() # Optional component - Pugixml - if (ENABLE_PUGIXML) + if (ENABLE_PUGIXML OR + NOT ORTHANC_FRAMEWORK_USE_SHARED) CHECK_INCLUDE_FILE_CXX(pugixml.hpp HAVE_PUGIXML_H) if (NOT HAVE_PUGIXML_H) message(FATAL_ERROR "Please install the libpugixml-dev package") @@ -552,14 +562,16 @@ endif() # Optional component - DCMTK - if (ENABLE_DCMTK) + if (ENABLE_DCMTK OR + NOT ORTHANC_FRAMEWORK_USE_SHARED) include(FindDCMTK NO_MODULE) list(APPEND ORTHANC_FRAMEWORK_LIBRARIES ${DCMTK_LIBRARIES}) include_directories(${DCMTK_INCLUDE_DIRS}) endif() # Optional component - OpenSSL - if (ENABLE_SSL) + if (ENABLE_SSL OR + NOT ORTHANC_FRAMEWORK_USE_SHARED) include(FindOpenSSL) if (NOT ${OPENSSL_FOUND}) message(FATAL_ERROR "Unable to find OpenSSL") @@ -569,46 +581,6 @@ endif() endif() - if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" AND - NOT ORTHANC_FRAMEWORK_USE_SHARED) - # Static library has more dependencies - - # Mandatory dependency: libuuid - CHECK_INCLUDE_FILE(uuid/uuid.h HAVE_UUID_H) - if (NOT HAVE_UUID_H) - message(FATAL_ERROR "Please install uuid-dev, e2fsprogs (OpenBSD) or e2fsprogs-libuuid (FreeBSD)") - endif() - - find_library(LIBUUID uuid - PATHS - /usr/lib - /usr/local/lib - ) - - check_library_exists(${LIBUUID} uuid_generate_random "" HAVE_LIBUUID) - if (NOT HAVE_LIBUUID) - message(FATAL_ERROR "Unable to find the uuid library") - endif() - - list(APPEND ORTHANC_FRAMEWORK_LIBRARIES ${LIBUUID}) - - # Optional component - libcurl - if (ENABLE_WEB_CLIENT) - include(FindCURL) - include_directories(${CURL_INCLUDE_DIRS}) - list(APPEND ORTHANC_FRAMEWORK_LIBRARIES ${CURL_LIBRARIES}) - endif() - - # Optional component - civetweb - if (ENABLE_WEB_SERVER) - CHECK_INCLUDE_FILE_CXX(civetweb.h HAVE_CIVETWEB_H) - if (NOT HAVE_CIVETWEB_H) - message(FATAL_ERROR "Please install the libcivetweb-dev package") - endif() - list(APPEND ORTHANC_FRAMEWORK_LIBRARIES civetweb) - endif() - endif() - # Look for Orthanc framework shared library include(CheckCXXSymbolExists)
--- a/OrthancFramework/SharedLibrary/CMakeLists.txt Thu Feb 25 11:02:23 2021 +0100 +++ b/OrthancFramework/SharedLibrary/CMakeLists.txt Thu Feb 25 12:15:18 2021 +0100 @@ -45,6 +45,7 @@ set(ORTHANC_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}" CACHE PATH "") SET(UNIT_TESTS_WITH_HTTP_CONNEXIONS ON CACHE BOOL "Allow unit tests to make HTTP requests") set(BUILD_SHARED_LIBRARY ON CACHE BOOL "Whether to build a shared library instead of a static library") +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\")") @@ -298,6 +299,10 @@ ${ORTHANC_CORE_SOURCES} ${ORTHANC_DICOM_SOURCES} ) + + # Add the "-fPIC" option to use the static library from Orthanc + # plugins (the latter being shared libraries) + set_property(TARGET OrthancFramework PROPERTY POSITION_INDEPENDENT_CODE ON) endif() endif() @@ -525,6 +530,7 @@ -DUSE_SYSTEM_BOOST:BOOL=${USE_SYSTEM_BOOST} -DUSE_SYSTEM_GOOGLE_TEST:BOOL=${USE_SYSTEM_GOOGLE_TEST} -DORTHANC_FRAMEWORK_USE_SHARED:BOOL=${BUILD_SHARED_LIBRARY} + -DORTHANC_FRAMEWORK_ADDITIONAL_LIBRARIES:STRING=${ORTHANC_FRAMEWORK_ADDITIONAL_LIBRARIES} ${Flags} )
--- a/OrthancFramework/UnitTestsSources/CMakeLists.txt Thu Feb 25 11:02:23 2021 +0100 +++ b/OrthancFramework/UnitTestsSources/CMakeLists.txt Thu Feb 25 12:15:18 2021 +0100 @@ -48,7 +48,6 @@ set(ENABLE_PUGIXML ON) set(ENABLE_SQLITE ON) set(ENABLE_WEB_CLIENT ON) -set(ENABLE_WEB_SERVER ON) if (NOT ORTHANC_FRAMEWORK_STATIC) set(USE_SYSTEM_GOOGLE_TEST ON CACHE BOOL "Use the system version of Google Test")