changeset 4428:a9a596ed988d

autodetection of SSL_CTX_get0_param()
author Sebastien Jodogne <s.jodogne@gmail.com>
date Thu, 31 Dec 2020 16:42:46 +0100
parents 30efda56500d
children 48ff722fad1f
files OrthancFramework/Resources/CMake/DcmtkConfiguration.cmake OrthancFramework/Resources/CMake/OrthancFrameworkConfiguration.cmake
diffstat 2 files changed, 23 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/OrthancFramework/Resources/CMake/DcmtkConfiguration.cmake	Thu Dec 31 15:16:18 2020 +0100
+++ b/OrthancFramework/Resources/CMake/DcmtkConfiguration.cmake	Thu Dec 31 16:42:46 2020 +0100
@@ -140,10 +140,27 @@
     include_directories(
       ${DCMTK_SOURCES_DIR}/dcmtls/include
       )
-    # The function "SSL_CTX_get0_param()" is available on OpenSSL
-    # 1.1.x that is used for static builds => TODO autodetect
-    set_source_files_properties(${DCMTK_SOURCES}
-      PROPERTIES COMPILE_DEFINITIONS "WITH_OPENSSL;HAVE_SSL_CTX_GET0_PARAM")
+
+    if (STATIC_BUILD OR NOT USE_SYSTEM_OPENSSL)
+      # The function "SSL_CTX_get0_param()" is available on both
+      # OpenSSL 1.0.x and 1.1.x that are used for static builds
+      set(HAVE_SSL_CTX_GET0_PARAM ON)
+    else()
+      # The call below requires "OpenSslConfiguration.cmake" to have
+      # been included beforehand (which is automatically done if using
+      # "OrthancFrameworkConfiguration.cmake")
+      CHECK_LIBRARY_EXISTS(ssl "SSL_CTX_get0_param" "" HAVE_SSL_CTX_GET0_PARAM)
+    endif()
+
+    if (HAVE_SSL_CTX_GET0_PARAM)
+      message("Have SSL_CTX_get0_param(): yes")
+      set_source_files_properties(${DCMTK_SOURCES}
+        PROPERTIES COMPILE_DEFINITIONS "WITH_OPENSSL;HAVE_SSL_CTX_GET0_PARAM")
+    else()
+      message("Have SSL_CTX_get0_param(): no")
+      set_source_files_properties(${DCMTK_SOURCES}
+        PROPERTIES COMPILE_DEFINITIONS "WITH_OPENSSL")
+    endif()      
   endif()
   
   
--- a/OrthancFramework/Resources/CMake/OrthancFrameworkConfiguration.cmake	Thu Dec 31 15:16:18 2020 +0100
+++ b/OrthancFramework/Resources/CMake/OrthancFrameworkConfiguration.cmake	Thu Dec 31 16:42:46 2020 +0100
@@ -494,6 +494,8 @@
     message(FATAL_ERROR "DICOM module must be enabled if enabling DCMTK support")
   endif()
 
+  # WARNING - MUST be after "OpenSslConfiguration.cmake", otherwise
+  # DICOM TLS will not be corrected detected
   include(${CMAKE_CURRENT_LIST_DIR}/DcmtkConfiguration.cmake)
 
   add_definitions(-DORTHANC_ENABLE_DCMTK=1)