COMP: Enable DCMTK PNG/TIFF/ZLIB via find_package with ITK libraries (supersedes #5537)#6393
Conversation
Set DCMTK_USE_FIND_PACKAGE=ON so DCMTK wires up PNG, TIFF, ZLIB, and JPEG support; without it the DCMTK_WITH_* options are silently ignored on Windows and those features are compiled out (issue InsightSoftwareConsortium#5539). Bump the vendored DCMTK to a fork commit that guards the TIFF and JPEG lookups with the same ITK-aware bypass the PNG and ZLIB branches already use, so the stock Find modules are not invoked on ITK's internal library layout (which has no canonical header for version extraction). For MSVC, pass /Zc:__cplusplus to the DCMTK build so its STL feature probes observe the real __cplusplus value and enable C++17; otherwise they disable STL support and ITKIODCMTK fails to compile (issue InsightSoftwareConsortium#5539). Co-Authored-By: Dženan Zukić <dzenan.zukic@kitware.com>
|
@hjmjohnson With the update ITK interface modules with target based properties, the preferred way to use ITK's provided libraries is not to specify the old variables but just set the library variables to the ITK exported interface libraries which have the build in library files, header includes etc. The new pattern in libraries using ITK libraries is something like: Then in the ITK level CMakeFile set TIFF_LIBRARIES like this: ITK/Modules/ThirdParty/GDCM/src/CMakeLists.txt Lines 33 to 45 in fcc0c0a By not running the find_packages in the thirdparty library things are much easier. Additionally, the ITK level variable are already support both ITK vendored libraries and system libraries. |
dzenanz
left a comment
There was a problem hiding this comment.
Looks good on a glance. Thanks for giving me co-author credit. Consider Brad's suggestion. Good even as-is, assuming it works, of course 😄
Enables PNG/TIFF/ZLIB/JPEG support in the internally-built DCMTK by turning on
DCMTK_USE_FIND_PACKAGEand teaching the DCMTK fork to consume ITK's bundled codecs directly. Fixes theModule_IOTransformDCMTKbuild failure in #5539 and supersedes #5537 (the original one-line WIP by @dzenanz).Depends on DCMTK fork commit
5b5c6f0d5onfor/itk-dcmtk-3.7.0-ccfd10b(pushed);DCMTKGitTag.cmakeis bumped to it.Root cause (issue #5539)
On Windows (non-MinGW) DCMTK defaults
DCMTK_USE_FIND_PACKAGE=FALSE, so the entire block that wires TIFF/JPEG/PNG/ZLIB is skipped — theDCMTK_WITH_*options and the raw*_LIBRARY/*_INCLUDE_DIRhints ITK passes are silently ignored and the features are compiled out.Turning
DCMTK_USE_FIND_PACKAGEon (as #5537 did) then forcesfind_package(JPEG)/find_package(TIFF)unconditionally. The stockFindJPEG/FindTIFFmodules probe a canonical header in the include dir for version extraction, but ITK's internally-built libraries place the header in a subdirectory (.../JPEG/src/itkjpeg-turbo/jpeglib.hvs the passed.../JPEG/src), so configure dies readingjpeglib.h.DCMTK's PNG and ZLIB branches already guard with
if(X_INCLUDE_DIR AND X_LIBRARY)to use ITK's hints directly and skipfind_package. JPEG and TIFF lacked that guard. The fork commit adds it for JPEG and TIFF, mirroring the existing pattern.What changed
for/itk-dcmtk-3.7.0-ccfd10b,5b5c6f0d5):CMake/3rdparty.cmake— add ITK-aware bypass guards to the JPEG and TIFF lookups.Modules/ThirdParty/DCMTK/CMakeLists.txt: setDCMTK_USE_FIND_PACKAGE=ON; for MSVC pass/Zc:__cplusplusto the DCMTK build so its STL feature probes observe the real__cplusplusvalue and enable C++17 (otherwise STL support is disabled andITKIODCMTKfails to compile — the Turning on Module_IOTransformDCMTK triggers a compile time error in ITKIODCMTK #5539 symptom).DCMTKGitTag.cmake: bump to the fork commit.The MSVC runtime-CRT concern in #2872 is already handled in
mainviaCMAKE_MSVC_RUNTIME_LIBRARY+ CMP0091; no change here.Validation
Built and tested locally on macOS with
-DModule_ITKIODCMTK=ON:find_packagebypass, using ITK's internallibitktiff/libitkjpeg(not system libs); all DCMTK libraries build;ITKIODCMTKlinks.ctest -R DCMTK: 23/24 pass (onlyITKIODCMTKKWStyleTest (Not Run)— KWStyle absent). A stock-mainbaseline build is identical (23/24, same Not-Run) → no regression.macOS already forces
DCMTK_USE_FIND_PACKAGE=TRUE, so the originalfind_packagefailure and the MSVC/Zc:__cplusplusfix can only be exercised on Windows CI.