[dcmtk] Revise, fix, test (#41565)

This commit is contained in:
Kai Pastor 2024-10-23 08:57:38 +02:00 committed by GitHub
parent 31554ea6a8
commit 61a6ef586f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 274 additions and 91 deletions

View File

@ -0,0 +1,55 @@
diff --git a/CMake/3rdparty.cmake b/CMake/3rdparty.cmake
index c355922..33ddc73 100644
--- a/CMake/3rdparty.cmake
+++ b/CMake/3rdparty.cmake
@@ -1,3 +1,11 @@
+set(CMAKE_REQUIRE_FIND_PACKAGE_Iconv "${DCMTK_WITH_ICONV}")
+set(CMAKE_REQUIRE_FIND_PACKAGE_ICU "${DCMTK_WITH_ICU}")
+set(CMAKE_REQUIRE_FIND_PACKAGE_LibXml2 "${DCMTK_WITH_XML}")
+set(CMAKE_REQUIRE_FIND_PACKAGE_OpenSSL "${DCMTK_WITH_OPENSSL}")
+set(CMAKE_REQUIRE_FIND_PACKAGE_PNG "${DCMTK_WITH_PNG}")
+set(CMAKE_REQUIRE_FIND_PACKAGE_TIFF "${DCMTK_WITH_TIFF}")
+set(CMAKE_REQUIRE_FIND_PACKAGE_ZLIB "${DCMTK_WITH_ZLIB}")
+
set(USE_FIND_PACKAGE_DOCS "Control whether libraries are searched via CMake's find_package() mechanism or a Windows specific fallback")
# Advanced user (eg. vcpkg) may want to override this:
if(NOT DEFINED DCMTK_USE_FIND_PACKAGE_WIN_DEFAULT)
@@ -42,7 +50,7 @@ if(DCMTK_USE_FIND_PACKAGE)
message(STATUS "Info: DCMTK TIFF support will be enabled")
include_directories(${TIFF_INCLUDE_DIR} ${JPEG_INCLUDE_DIR})
endif()
- set(LIBTIFF_LIBS ${TIFF_LIBRARY} ${TIFF_EXTRA_LIBS_STATIC} ${JPEG_LIBRARY})
+ set(LIBTIFF_LIBS ${TIFF_LIBRARIES})
endif()
endif()
@@ -57,7 +65,7 @@ if(DCMTK_USE_FIND_PACKAGE)
message(STATUS "Info: DCMTK PNG support will be enabled")
set(WITH_LIBPNG 1)
include_directories(${PNG_INCLUDE_DIR})
- set(LIBPNG_LIBS ${PNG_LIBRARY})
+ set(LIBPNG_LIBS ${PNG_LIBRARIES})
endif()
endif()
@@ -102,7 +110,7 @@ if(DCMTK_USE_FIND_PACKAGE)
else()
message(STATUS "Info: DCMTK XML support will be enabled")
set(WITH_LIBXML 1)
- include_directories(${LIBXML2_INCLUDE_DIR})
+ include_directories(${LIBXML2_INCLUDE_DIRS})
set(LIBXML_LIBS ${LIBXML2_LIBRARIES} ${LIBXML2_EXTRA_LIBS_STATIC})
endif()
endif()
@@ -140,7 +148,10 @@ if(DCMTK_USE_FIND_PACKAGE)
# Find libiconv
if(DCMTK_WITH_ICONV)
find_package(Iconv QUIET)
- find_package(LIBCHARSET QUIET)
+ set(ICONV_FOUND 1)
+ if(CHARSET_LIBRARIES)
+ set(LIBCHARSET_FOUND 1)
+ endif()
if(ICONV_FOUND)
if(NOT Iconv_IS_BUILT_IN)
set(LIBICONV_FOUND ${ICONV_FOUND})

View File

@ -0,0 +1,19 @@
diff --git a/CMake/dcmtkUseWine.cmake b/CMake/dcmtkUseWine.cmake
index 6dbd7dc..cf529e2 100644
--- a/CMake/dcmtkUseWine.cmake
+++ b/CMake/dcmtkUseWine.cmake
@@ -1,3 +1,14 @@
+if(CMAKE_HOST_WIN32)
+ function(DCMTK_SETUP_WINE)
+ endfunction()
+ function(WINE_COMMAND)
+ message(FATAL_ERROR "Not implemented")
+ endfunction()
+ function(WINE_DETACHED)
+ message(FATAL_ERROR "Not implemented")
+ endfunction()
+ return()
+endif()
#
# Functions for detection and usage of Wine
# Used when cross compiling

View File

@ -1,13 +0,0 @@
diff --git a/CMake/3rdparty.cmake b/CMake/3rdparty.cmake
index 955ea71..9968352 100644
--- a/CMake/3rdparty.cmake
+++ b/CMake/3rdparty.cmake
@@ -42,7 +42,7 @@ if(DCMTK_USE_FIND_PACKAGE)
message(STATUS "Info: DCMTK TIFF support will be enabled")
include_directories(${TIFF_INCLUDE_DIR} ${JPEG_INCLUDE_DIR})
endif()
- set(LIBTIFF_LIBS ${TIFF_LIBRARY} ${TIFF_EXTRA_LIBS_STATIC} ${JPEG_LIBRARY})
+ set(LIBTIFF_LIBS ${TIFF_LIBRARIES})
endif()
endif()

View File

@ -1,13 +0,0 @@
diff --git a/CMake/3rdparty.cmake b/CMake/3rdparty.cmake
index 2c974e8..90707bd 100644
--- a/CMake/3rdparty.cmake
+++ b/CMake/3rdparty.cmake
@@ -94,7 +94,7 @@ if(DCMTK_USE_FIND_PACKAGE)
else()
message(STATUS "Info: DCMTK XML support will be enabled")
set(WITH_LIBXML 1)
- include_directories(${LIBXML2_INCLUDE_DIR})
+ include_directories(${LIBXML2_INCLUDE_DIRS})
set(LIBXML_LIBS ${LIBXML2_LIBRARIES} ${LIBXML2_EXTRA_LIBS_STATIC})
endif()
endif()

12
ports/dcmtk/msvc.diff Normal file
View File

@ -0,0 +1,12 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bef673f..284d40e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -21,6 +21,7 @@ target_include_directories(config INTERFACE
$<BUILD_INTERFACE:${DCMTK_BINARY_DIR}/config/include>
$<INSTALL_INTERFACE:include>
)
+target_compile_options(config INTERFACE "\$<\$<CXX_COMPILER_ID:MSVC>:/Zc:__cplusplus>")
install(TARGETS config EXPORT DCMTKTargets)
# Include directories

View File

@ -0,0 +1,60 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 284d40e..8f8acfd 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -158,7 +158,12 @@ endif()
if(DCMTK_WITH_ICONV)
# libiconv does not provide a .pc file
- set(PKGCONF_LIBS_PRIV "${PKGCONF_LIBS_PRIV} ${Iconv_LIBRARY} ${LIBCHARSET_LIBRARY}")
+ if(Iconv_LIBRARIES)
+ string(APPEND PKGCONF_LIBS_PRIV " -liconv")
+ endif()
+ if(CHARSET_LIBRARIES)
+ string(APPEND PKGCONF_LIBS_PRIV " -lcharset")
+ endif()
endif()
if(DCMTK_WITH_ICU)
@@ -200,6 +205,41 @@ endif()
get_property(DCMTK_LIBRARY_TARGETS GLOBAL PROPERTY DCMTK_LIBRARY_TARGETS)
+foreach(lib IN LISTS WIN32_STD_LIBRARIES)
+ string(APPEND PKGCONF_LIBS_PRIV " -l${lib}")
+endforeach()
+configure_file("${DCMTK_SOURCE_DIR}/CMake/dcmtk.pc.in" "${DCMTK_BINARY_DIR}/dcmtk-deps.pc" @ONLY)
+install(FILES "${DCMTK_BINARY_DIR}/dcmtk-deps.pc" DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
+set(PKGCONF_LIBS "")
+set(PKGCONF_LIBS_PRIV "")
+set(PKGCONF_REQ_PUB dcmtk-deps)
+set(PKGCONF_REQ_PRIV "")
+
+foreach(lib IN ITEMS
+ dcmfg # for dcmseg, dcmpmap, dcmect
+ dcmiod # for dcmpstat, dcmfg, dcmseg
+ dcmdsig # for dcmpstat
+ dcmtls # for dcmpstat
+ dcmqrdb # for dcmpstat
+ dcmsr # for cmr
+ dcmnet # for dcmtls, dcmwlm, dcmqrdb
+ dcmtkcharls # for dcmjpls
+ ijg8 # for dcmjpeg
+ ijg12 # fpr dcmjpeg
+ ijg16 # for dcmjpeg
+ dcmimage # for dcmjpeg etc.
+ dcmimgle # for dcmimage etc.
+ dcmxml # for i2d
+ dcmdata # fpr dcmxml, dcmimgle, etc.
+ oflog # for most libs
+ ofstd # for oflog
+ oficonv # for ofstd
+ )
+ if(lib IN_LIST DCMTK_LIBRARY_TARGETS)
+ list(REMOVE_ITEM DCMTK_LIBRARY_TARGETS ${lib})
+ list(APPEND DCMTK_LIBRARY_TARGETS ${lib})
+ endif()
+endforeach()
foreach(T ${DCMTK_LIBRARY_TARGETS})
set(PKGCONF_LIBS "${PKGCONF_LIBS} -l${T}")
endforeach()

View File

@ -6,9 +6,16 @@ vcpkg_from_github(
HEAD_REF master
PATCHES
dcmtk.patch
fix_link_xml2.patch
dependencies.diff
dictionary_paths.patch
fix_link_tiff.patch
disable-test-setup.diff
pkgconfig-lib-order.diff
msvc.diff
)
file(REMOVE
"${SOURCE_PATH}/CMake/FindICONV.cmake"
"${SOURCE_PATH}/CMake/FindICU.cmake"
"${SOURCE_PATH}/CMake/FindJPEG.cmake"
)
# Prefix all exported API symbols of vendored libjpeg with "dcmtk_"
@ -19,6 +26,18 @@ foreach(file_path ${src_files})
file(WRITE "${file_path}" "${file_string}")
endforeach()
vcpkg_cmake_get_vars(cmake_vars_file)
include("${cmake_vars_file}")
if(VCPKG_DETECTED_CMAKE_CROSSCOMPILING)
message(STATUS [[
Cross-compiling DCMTK needs input from executing test programs in the target
environment. You may need to provide a suitable emulator setup, and you can set
values directly with `VCPKG_CMAKE_CONFIGURE_OPTIONS` in a custom triplet file.
For more information see
https://support.dcmtk.org/redmine/projects/dcmtk/wiki/Cross_Compiling
]])
endif()
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
"iconv" DCMTK_WITH_ICONV
@ -33,37 +52,40 @@ vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
if("external-dict" IN_LIST FEATURES)
set(DCMTK_DEFAULT_DICT "external")
set(DCMTK_ENABLE_BUILTIN_OFICONV_DATA OFF)
set(DCMTK_ENABLE_BUILTIN_OFICONV_DATA OFF)
else()
set(DCMTK_DEFAULT_DICT "builtin")
set(DCMTK_ENABLE_BUILTIN_OFICONV_DATA ON)
set(DCMTK_ENABLE_BUILTIN_OFICONV_DATA ON)
endif()
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}
"-DDCMTK_DEFAULT_DICT=${DCMTK_DEFAULT_DICT}"
-DDCMTK_ENABLE_BUILTIN_OFICONV_DATA=${DCMTK_ENABLE_BUILTIN_OFICONV_DATA}
-DDCMTK_WITH_DOXYGEN=OFF
-DDCMTK_FORCE_FPIC_ON_UNIX=ON
-DDCMTK_OVERWRITE_WIN32_COMPILER_FLAGS=OFF
-DDCMTK_ENABLE_PRIVATE_TAGS=ON
-DCMAKE_CXX_STANDARD=17
-DCMAKE_INSTALL_DOCDIR=share/${PORT}/doc
-DDCMTK_DEFAULT_DICT=${DCMTK_DEFAULT_DICT}
-DCMAKE_DISABLE_FIND_PACKAGE_BISON=ON
-DCMAKE_DISABLE_FIND_PACKAGE_FLEX=ON
-DDCMTK_ENABLE_BUILTIN_OFICONV_DATA=${DCMTK_ENABLE_BUILTIN_OFICONV_DATA}
-DDCMTK_ENABLE_PRIVATE_TAGS=ON
-DDCMTK_ENABLE_STL=ON
-DDCMTK_OVERWRITE_WIN32_COMPILER_FLAGS=OFF
-DDCMTK_USE_FIND_PACKAGE=ON
-DDCMTK_WIDE_CHAR_FILE_IO_FUNCTIONS=ON
-DDCMTK_WIDE_CHAR_MAIN_FUNCTION=ON
-DDCMTK_ENABLE_STL=ON
-DCMAKE_DEBUG_POSTFIX=d
-DDCMTK_USE_FIND_PACKAGE_WIN_DEFAULT=ON
-DBUILD_TESTING=OFF
-DDCMTK_WITH_OPENJPEG=OFF
-DDCMTK_WITH_DOXYGEN=OFF
-DDCMTK_WITH_SNDFILE=OFF
-DDCMTK_WITH_WRAP=OFF
OPTIONS_DEBUG
-DINSTALL_HEADERS=OFF
-DINSTALL_OTHER=OFF
-DBUILD_APPS=OFF
)
vcpkg_cmake_install()
vcpkg_copy_pdbs()
vcpkg_cmake_config_fixup()
vcpkg_fixup_pkgconfig()
if ("tools" IN_LIST FEATURES)
set(_tools
@ -147,18 +169,15 @@ if ("tools" IN_LIST FEATURES)
vcpkg_copy_tools(TOOL_NAMES ${_tools} AUTO_CLEAN)
endif()
vcpkg_cmake_config_fixup()
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/include")
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/dcmtk/config/osconfig.h" "#define DCMTK_PREFIX \"${CURRENT_PACKAGES_DIR}\"" "" IGNORE_UNCHANGED)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/dcmtk/config/osconfig.h" "#define DCM_DICT_DEFAULT_PATH \"${CURRENT_PACKAGES_DIR}/share/dcmtk-${VERSION}/dicom.dic:${CURRENT_PACKAGES_DIR}/share/dcmtk-${VERSION}/private.dic\"" "" IGNORE_UNCHANGED)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/dcmtk/config/osconfig.h" "#define DEFAULT_CONFIGURATION_DIR \"${CURRENT_PACKAGES_DIR}/etc/dcmtk-${VERSION}/\"" "" IGNORE_UNCHANGED)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/dcmtk/config/osconfig.h" "#define DEFAULT_SUPPORT_DATA_DIR \"${CURRENT_PACKAGES_DIR}/share/dcmtk-${VERSION}/\"" "" IGNORE_UNCHANGED)
# no absolute paths
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/dcmtk/config/osconfig.h"
"#define (DCMTK_PREFIX|DCM_DICT_DEFAULT_PATH|DEFAULT_CONFIGURATION_DIR|DEFAULT_SUPPORT_DATA_DIR) \"[^\"]*\""
"#define \\1 \"\" /* redacted by vcpkg */"
REGEX
)
vcpkg_fixup_pkgconfig()
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYRIGHT")
configure_file("${CMAKE_CURRENT_LIST_DIR}/usage" "${CURRENT_PACKAGES_DIR}/share/${PORT}/usage" @ONLY)
file(COPY "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
file(RENAME "${CURRENT_PACKAGES_DIR}/share/${PORT}/doc-${VERSION}/COPYRIGHT" "${CURRENT_PACKAGES_DIR}/share/${PORT}/copyright")

View File

@ -1,25 +1,9 @@
The package dcmtk provides CMake targets:
dcmtk provides CMake targets:
find_package(DCMTK CONFIG REQUIRED)
target_link_libraries(main PRIVATE DCMTK::DCMTK)
# You may also need one or more of the following targets:
# DCMTK::cmr DCMTK::i2d DCMTK::ijg8 DCMTK::config DCMTK::ofstd
# DCMTK::oflog DCMTK::dcmdata DCMTK::dcmimgle DCMTK::dcmimage
# DCMTK::dcmjpeg DCMTK::ijg12 DCMTK::ijg16 DCMTK::dcmjpls
# DCMTK::dcmtkcharls DCMTK::dcmtls DCMTK::dcmnet DCMTK::dcmsr
# DCMTK::dcmdsig DCMTK::dcmwlm DCMTK::dcmqrdb DCMTK::dcmpstat
# DCMTK::dcmrt DCMTK::dcmiod DCMTK::dcmfg DCMTK::dcmseg
# DCMTK::dcmtract DCMTK::dcmpmap DCMTK::dcmect
find_package(DCMTK CONFIG REQUIRED)
target_link_libraries(main PRIVATE DCMTK::DCMTK)
# You may also select specific modules using DCMTK::<module>.
Add the following cmake code to your CMakeLists.txt to create definitions for DCMTK
if ("${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}" STREQUAL "/")
message(WARNING "No vcpkg install dir found, DCMTK definitions are not set")
else()
target_compile_definitions(main
PUBLIC
"DCMTK_PREFIX=${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}"
"DCM_DICT_DEFAULT_PATH=${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/dcmtk-@VERSION@/dicom.dic:${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/dcmtk-@VERSION@/private.dic"
"DEFAULT_CONFIGURATION_DIR=${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/etc/dcmtk-@VERSION@/"
"DEFAULT_SUPPORT_DATA_DIR=${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/share/dcmtk-@VERSION@/"
)
endif()
dcmtk provides pkg-config modules:
dcmtk

View File

@ -1,11 +1,11 @@
{
"name": "dcmtk",
"version": "3.6.8",
"port-version": 8,
"port-version": 9,
"description": "This DICOM ToolKit (DCMTK) package consists of source code, documentation and installation instructions for a set of software libraries and applications implementing part of the DICOM/MEDICOM Standard.",
"homepage": "https://github.com/DCMTK/dcmtk",
"license": "BSD-3-Clause OR BSD-2-Clause OR libtiff OR MIT OR Zlib OR Libpng",
"supports": "!(windows & arm)",
"license": null,
"supports": "!uwp",
"dependencies": [
{
"name": "vcpkg-cmake",
@ -14,6 +14,10 @@
{
"name": "vcpkg-cmake-config",
"host": true
},
{
"name": "vcpkg-cmake-get-vars",
"host": true
}
],
"features": {

View File

@ -209,16 +209,6 @@ cctag:x64-windows-static-md=fail
cello:arm64-uwp=fail
cello:x64-uwp=fail
chakracore:x64-linux=skip
# DCMTK currently has a vendored copy of libcharls.a, which causes conflicts with charls (TODO: use charls' copy)
charls:arm64-windows=skip
charls:arm64-uwp=skip
charls:x64-linux=skip
charls:x64-osx=skip
charls:x64-uwp=skip
charls:x64-windows=skip
charls:x64-windows-static=skip
charls:x64-windows-static-md=skip
charls:x86-windows=skip
# chartdir does not offer stable download URLs
chartdir:arm-neon-android=fail
chartdir:arm64-android=fail
@ -300,10 +290,11 @@ dbghelp:x64-windows-static=skip
dbghelp:x64-windows-static-md=skip
dbghelp:x64-windows=skip
dbghelp:x86-windows=skip
# Cross builds depend on try_run results
dcmtk:arm-neon-android=fail
dcmtk:arm64-android=fail
dcmtk:arm64-windows=fail
dcmtk:x64-android=fail
dcmtk:x64-uwp=fail
# legacy directxsdk which conflicts with dxsdk-d3dx
directxsdk:x86-windows=skip
directxsdk:x64-windows=skip

View File

@ -0,0 +1,10 @@
set(VCPKG_POLICY_EMPTY_PACKAGE enabled)
vcpkg_find_acquire_program(PKGCONFIG)
vcpkg_cmake_configure(
SOURCE_PATH "${CURRENT_PORT_DIR}/project"
OPTIONS
"-DPKG_CONFIG_EXECUTABLE=${PKGCONFIG}"
)
vcpkg_cmake_build()

View File

@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.10)
project(dcmtk-test CXX)
set(CMAKE_CXX_STANDARD 17)
find_package(DCMTK CONFIG REQUIRED)
add_executable(main main.cpp)
target_link_libraries(main PRIVATE DCMTK::DCMTK)
find_package(PkgConfig REQUIRED)
pkg_check_modules(DCMTK dcmtk REQUIRED IMPORTED_TARGET)
add_executable(main-pkgconfig main.cpp)
target_link_libraries(main-pkgconfig PRIVATE PkgConfig::DCMTK)
target_compile_options(main-pkgconfig PRIVATE "\$<\$<CXX_COMPILER_ID:MSVC>:/Zc:__cplusplus>")

View File

@ -0,0 +1,9 @@
#include <dcmtk/dcmdata/dcjson.h>
#include <dcmtk/dcmtls/tlslayer.h>
int main()
{
auto djfp = DcmJsonFormatPretty(OFTrue);
DcmTLSTransportLayer::initializeOpenSSL(); // https://github.com/microsoft/vcpkg/issues/38476
return 0;
}

View File

@ -0,0 +1,25 @@
{
"name": "vcpkg-ci-dcmtk",
"version-string": "ci",
"description": "Port to force features of dcmtk within CI",
"homepage": "https://github.com/microsoft/vcpkg",
"license": "MIT",
"dependencies": [
{
"name": "dcmtk",
"features": [
"iconv",
"icu",
"openssl",
"tiff",
"tools",
"xml2",
"zlib"
]
},
{
"name": "vcpkg-cmake",
"host": true
}
]
}

View File

@ -2254,7 +2254,7 @@
},
"dcmtk": {
"baseline": "3.6.8",
"port-version": 8
"port-version": 9
},
"debug-assert": {
"baseline": "1.3.4",

View File

@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "49f23c4ed5cbf8ff7b8dea4ef9fd66539b765c2a",
"version": "3.6.8",
"port-version": 9
},
{
"git-tree": "fa61ef50b6065815a6e5d6b123fef77f744307b9",
"version": "3.6.8",