diff --git a/CMake/3rdparty.cmake b/CMake/3rdparty.cmake index 50935bb44b..0242e22177 100644 --- a/CMake/3rdparty.cmake +++ b/CMake/3rdparty.cmake @@ -79,11 +79,12 @@ if(DCMTK_USE_FIND_PACKAGE) if(OPENSSL_VERSION_CHECK) message(STATUS "Info: DCMTK OPENSSL support will be enabled") set(WITH_OPENSSL 1) - include_directories(${OPENSSL_INCLUDE_DIR}) set(OPENSSL_LIBS ${OPENSSL_LIBRARIES} ${OPENSSL_EXTRA_LIBS_STATIC}) + set(OPENSSL_MODULES OpenSSL::Crypto OpenSSL::SSL) CHECK_LIBRARY_EXISTS(dl dlopen "" HAVE_LIBDL) if(HAVE_LIBDL) set(OPENSSL_LIBS ${OPENSSL_LIBS} dl) + set(OPENSSL_MODULES ${OPENSSL_MODULES} dl) endif() else() message(STATUS "Info: DCMTK OPENSSL support will be disabled: DCMTK requires OpenSSL version 1.1.1 or newer") @@ -118,8 +119,7 @@ if(DCMTK_USE_FIND_PACKAGE) else() message(STATUS "Info: DCMTK ZLIB support will be enabled") set(WITH_ZLIB 1) - include_directories(${ZLIB_INCLUDE_DIRS}) - set(ZLIB_LIBS ${ZLIB_LIBRARIES}) + set(ZLIB_MODULES ZLIB::ZLIB) endif() endif() diff --git a/CMake/DCMTKConfig.cmake.in b/CMake/DCMTKConfig.cmake.in index e8c80fa62d..b021c1e11b 100644 --- a/CMake/DCMTKConfig.cmake.in +++ b/CMake/DCMTKConfig.cmake.in @@ -107,6 +107,19 @@ SET_AND_CHECK(DCMTK_TARGETS "@PACKAGE_DCMTK_CMKDIR_CONFIG@/DCMTKTargets.cmake") # Compatibility: This variable is deprecated set(DCMTK_INCLUDE_DIR ${DCMTK_INCLUDE_DIRS}) +# Depend packages +if(DCMTK_WITH_ZLIB) + if(NOT ZLIB_FOUND) + find_dependency(ZLIB) + endif() +endif() + +if(DCMTK_WITH_OPENSSL) + if(NOT OPENSSL_FOUND) + find_dependency(OpenSSL) + endif() +endif() + if(NOT DCMTK_TARGETS_IMPORTED) set(DCMTK_TARGETS_IMPORTED 1) include(${DCMTK_TARGETS}) diff --git a/dcmdata/libdcxml/CMakeLists.txt b/dcmdata/libdcxml/CMakeLists.txt index 89968e8932..87062c55d6 100644 --- a/dcmdata/libdcxml/CMakeLists.txt +++ b/dcmdata/libdcxml/CMakeLists.txt @@ -7,5 +7,5 @@ DCMTK_ADD_LIBRARY(dcmxml xml2dcm.cc ) -DCMTK_TARGET_LINK_MODULES(dcmxml dcmdata ofstd oflog) +DCMTK_TARGET_LINK_MODULES(dcmxml dcmdata ofstd oflog ${ZLIB_MODULES}) DCMTK_TARGET_LINK_LIBRARIES(dcmxml ${ZLIB_LIBS} ${LIBXML_LIBS}) diff --git a/dcmdata/libsrc/CMakeLists.txt b/dcmdata/libsrc/CMakeLists.txt index 74e454cbe8..be21cc0ea4 100644 --- a/dcmdata/libsrc/CMakeLists.txt +++ b/dcmdata/libsrc/CMakeLists.txt @@ -96,7 +96,7 @@ DCMTK_ADD_LIBRARY(dcmdata vrscanl.c ) -DCMTK_TARGET_LINK_MODULES(dcmdata ofstd oflog) +DCMTK_TARGET_LINK_MODULES(dcmdata ofstd oflog ${ZLIB_MODULES}) DCMTK_TARGET_LINK_LIBRARIES(dcmdata ${ZLIB_LIBS}) # Various dictionary-related commands diff --git a/dcmsign/libsrc/CMakeLists.txt b/dcmsign/libsrc/CMakeLists.txt index 0faefeeb2b..dbe1be7577 100644 --- a/dcmsign/libsrc/CMakeLists.txt +++ b/dcmsign/libsrc/CMakeLists.txt @@ -22,7 +22,12 @@ DCMTK_ADD_LIBRARY(dcmdsig ) DCMTK_TARGET_LINK_MODULES(dcmdsig ofstd dcmdata) -DCMTK_TARGET_LINK_LIBRARIES(dcmdsig ${OPENSSL_LIBS}) + +if(OPENSSL_MODULES) + DCMTK_TARGET_LINK_MODULES(dcmdsig ${OPENSSL_MODULES}) +else() + DCMTK_TARGET_LINK_LIBRARIES(dcmdsig ${OPENSSL_LIBS}) +endif() if (TARGET dcmdsig) set_property(TARGET dcmdsig PROPERTY OUTPUT_NAME "dcmdsig${DCMTK_TLS_LIBRARY_POSTFIX}") diff --git a/dcmtls/libsrc/CMakeLists.txt b/dcmtls/libsrc/CMakeLists.txt index b7276e9ea7..6989a4bd2a 100644 --- a/dcmtls/libsrc/CMakeLists.txt +++ b/dcmtls/libsrc/CMakeLists.txt @@ -9,7 +9,11 @@ DCMTK_ADD_LIBRARY(dcmtls ) DCMTK_TARGET_LINK_MODULES(dcmtls ofstd dcmdata dcmnet) -DCMTK_TARGET_LINK_LIBRARIES(dcmtls ${OPENSSL_LIBS}) +if(OPENSSL_MODULES) + DCMTK_TARGET_LINK_MODULES(dcmtls ${OPENSSL_MODULES}) +else() + DCMTK_TARGET_LINK_LIBRARIES(dcmtls ${OPENSSL_LIBS}) +endif() if (TARGET dcmtls) set_property(TARGET dcmtls PROPERTY OUTPUT_NAME "dcmtls${DCMTK_TLS_LIBRARY_POSTFIX}")