diff 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
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)