COMP: Pin DCMTK with single-export namespace fix - #6548
Conversation
6eab740 to
ec1ff34
Compare
| list(JOIN _ITKDCMTK_LIB_NAMES " " _itkdcmtk_lib_names_spaced) | ||
| set( | ||
| ITKDCMTK_EXPORT_CODE_BUILD | ||
| " | ||
| if(NOT ITK_BINARY_DIR) | ||
| set(DCMTK_DIR \"${CMAKE_BINARY_DIR}\") | ||
| find_package(DCMTK REQUIRED NO_MODULE) | ||
| foreach(_itkdcmtk_lib ${_itkdcmtk_lib_names_spaced}) |
There was a problem hiding this comment.
Include suffixed targets
The repair loop uses the unsuffixed _ITKDCMTK_LIB_NAMES, but this file creates and links DCMTK::${_dcmtk_lib}${DCMTK_LIBRARY_SUFFIX} targets at lines 151-161. When DCMTK_LIBRARY_SUFFIX is non-empty, no DCMTK::dcmdata target exists, so the loop skips every exported DCMTK target and leaves the broken DCMTK::ITK::* references in the build-tree export.
Artifacts
Repro: deterministic suffixed DCMTK repair harness
- Contains supporting evidence from the run (text/x-python; charset=utf-8).
Repro: harness execution log showing skipped repair and remaining broken entry
- Keeps the command output available without making the summary code-heavy.
Repro: command-v output showing CMake and Ninja unavailable
- Keeps the command output available without making the summary code-heavy.
|
This solution does not seem quite right to me. If DCMTK saw ITK's provided libraries as "imported" targets it would not alter the namespace. I tries one way to modify the ITK's third party libraries to be imported target to DCMTK but it did not work. I may look into modifying how DCMTK does the exports. I have not found this type of issue in searches. I may create a minimal reproducible example and seek some advice on it. |
@blowekamp See DCMTK/dcmtk#150 for a minimal reproducible example. I am trying to build a forest of tools (ANTs, BRAINSTools, Slicer, SlicerExtensions, ITK-SNAP, .... and may others, and keep running into DCMTK build failures downstream. |
That is a good start to the MRE I was thinking. But I was going also going to create a minimal sub-project to replace DCMTK's library and export. On thing that is atypical in ITK is that the export name space is set as a property: ITK/CMake/ITKModuleMacros.cmake Lines 789 to 794 in a66345a I am currently looking at example cmake code which export multiple namespace to see how things can be done. |
|
@blowekamp Thank you for looking into this. If you find a workable solution, please just push over top of this PR, or close this and open a new PR. |
Root cause of
|
|
The fix described above has been submitted upstream: InsightSoftwareConsortium/DCMTK#3 |
ec1ff34 to
f9b0320
Compare
|
Reworked per @blowekamp's root-cause fix: the ITK-side repair loop is gone, replaced by a DCMTK pin bump to the head of InsightSoftwareConsortium/DCMTK#3 (single Local verification (2026-07-13)
Blocked on: InsightSoftwareConsortium/DCMTK#3 landing on a |
|
@bradking We now building DCMTK with FetchContent, and using namespace ITK third-party interfaces/libraries and exporting into a separate Targets file. As documented in my "Root cause of DCMTK::ITK::ITKZLIBModule namespace corruption" post above it appears that the CMake |
|
|
This is what the change is for DCMTK. Thank you. |
DCMTK's GenerateCMakeExports.cmake wrote DCMTKTargets.cmake with three export(APPEND) calls; CMake's append mode skips the cross-export-set namespace lookup and blindly prefixes DCMTK:: onto ITK's codec targets, recording the nonexistent DCMTK::ITK::ITKZLIBModule (and TIFF/JPEG/PNG). An external consumer of an ITK build tree then fails at generate. The pinned InsightSoftwareConsortium/DCMTK#3 merges the exports into a single export() call so foreign targets resolve to their ITK:: names. Root cause analysis and DCMTK fix by Bradley Lowekamp.
f9b0320 to
94fc539
Compare
|
@hjmjohnson Merged DCMTK pr, and update this PR. |
|
I confirmed that downstream (ANTs testbed) builds are fixed with this change! Yippie! This was a blocker for testing downstream tool building. |
a40bf87
into
InsightSoftwareConsortium:main
Pin DCMTK to the head of InsightSoftwareConsortium/DCMTK#3 (@blowekamp's fix: one
export()call instead of threeexport(APPEND)calls), so the build-treeDCMTKTargets.cmakerecords ITK's codec targets asITK::*instead of the nonexistentDCMTK::ITK::*. Replaces the earlier ITK-side repair loop; external build-tree consumers (e.g. an ANTs SuperBuild) now survive CMake generate with no workaround in ITK.Blocked on: InsightSoftwareConsortium/DCMTK#3 landing on a
for/itk-…branch; the pin currently points at blowekamp/DCMTK because the fix SHA is not clone-reachable from the ISC repo. FlipDCMTK_GIT_REPOSITORYback once merged.Root cause (from blowekamp's analysis on this PR)
CMake's
export(TARGETS ... APPEND)skips the cross-export-set namespace lookup (HandleMissingTarget) and blindly prefixes the current namespace onto foreign dependency targets. DCMTK'sGenerateCMakeExports.cmakebuiltDCMTKTargets.cmakewith threeAPPENDcalls, so ITK's codec targets were recorded asDCMTK::ITK::ITK{ZLIB,TIFF,JPEG,PNG}Module. A single non-appendexport()resolves them to their realITK::names. Intentional (undocumented) CMake behavior, not a CMake bug. The install-tree export (install(EXPORT)) was never affected.Testing performed (2026-07-13, pin commit f9b0320)
DCMTKTargets.cmake: zeroDCMTK::ITK::*entries; deps export asITK::ITK{ZLIB,TIFF,JPEG,PNG}Module.find_package(ITK COMPONENTS ITKIODCMTK)+itk::DCMTKImageIO::New(), same compiler as the ITK build): configure + generate + link + run all succeed. On unpatchedmain(post-COMP: Link namespaced DCMTK targets in the DCMTK IO modules #6543) the same consumer fails at generate withtarget DCMTK::ITK::ITKZLIBModule not found.ctest -R DCMTK: 38/39 pass; soleNot RunisITKIODCMTKKWStyleTest(KWStyle not installed locally — unrelated).