Skip to content

ENH: Make ITKDCMTK a private dependency of ITKIODCMTK and IOTransformDCMTK#6496

Merged
blowekamp merged 2 commits into
InsightSoftwareConsortium:mainfrom
blowekamp:dcmtk-private-depends
Jun 25, 2026
Merged

ENH: Make ITKDCMTK a private dependency of ITKIODCMTK and IOTransformDCMTK#6496
blowekamp merged 2 commits into
InsightSoftwareConsortium:mainfrom
blowekamp:dcmtk-private-depends

Conversation

@blowekamp

Copy link
Copy Markdown
Member

Move DCMTK headers out of public include paths so consumers of ITKIODCMTK and IOTransformDCMTK no longer need DCMTK on their include path.

Changes

ITKIODCMTK

  • itkDCMTKFileReader.h moved from include/ to src/; it exposed DcmStack, E_TransferSyntax, DcmDictEntry and other DCMTK types in the public API but is an internal implementation class.
  • src/CMakeLists.txt: added PRIVATE include for src/ so the .cxx files find the moved header.
  • test/CMakeLists.txt: added src/ to the test driver include path (the existing DCMTK header workaround was already present).
  • itk-module.cmake: ITKDCMTK moved from DEPENDS to PRIVATE_DEPENDS.

IOTransformDCMTK

  • itkDCMTKTransformIO.hxx moved from include/ to src/; it was already only included from itkDCMTKTransformIO.cxx for explicit instantiation.
  • src/CMakeLists.txt: added PRIVATE include for src/.
  • itk-module.cmake: ITKDCMTK moved from DEPENDS to PRIVATE_DEPENDS.
AI assistance
  • Tool: GitHub Copilot (Claude Sonnet 4.6)
  • Role: identified affected headers, implemented the moves, updated CMake, built and verified locally

Move itkDCMTKFileReader.h from include/ to src/ so DCMTK types
(DcmStack, E_TransferSyntax, DcmDictEntry, etc.) do not appear in
public headers. Add PRIVATE include dir in src/CMakeLists.txt and
src/ include path in test/CMakeLists.txt for the test that exercises
DCMTKFileReader directly. Change itk-module.cmake to list ITKDCMTK
under PRIVATE_DEPENDS instead of DEPENDS.
Move itkDCMTKTransformIO.hxx from include/ to src/; it is only ever
included from itkDCMTKTransformIO.cxx for explicit instantiation, so
it was already effectively private. Add PRIVATE include dir in
src/CMakeLists.txt and change itk-module.cmake to list ITKDCMTK
under PRIVATE_DEPENDS.
@github-actions github-actions Bot added type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots type:Enhancement Improvement of existing methods or implementation area:IO Issues affecting the IO module labels Jun 23, 2026
# is a PRIVATE_DEPENDS of ITKIODCMTK (so consumers don't see DCMTK headers),
# but the test driver includes itkDCMTKFileReader.h directly and therefore
# needs the DCMTK include path on its compile line.
# Reconstruct the include path the same way

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some of this extra configuration may be able to be cleaning up after the DCMTK FetchContent PR is merged.

@blowekamp blowekamp marked this pull request as ready for review June 23, 2026 17:40
@greptile-apps

greptile-apps Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR makes ITKDCMTK a private dependency of both ITKIODCMTK and IOTransformDCMTK, so downstream consumers of those modules no longer need DCMTK headers on their compile line.

  • itkDCMTKFileReader.h is relocated from include/ to src/ and the library target is given a PRIVATE include on src/; the test driver's CMakeLists.txt adds the same src/ path plus reconstructs the bundled-DCMTK header tree for the one test that directly exercises the internal reader API.
  • itkDCMTKTransformIO.hxx is relocated from include/ to src/ (it was already only consumed by itkDCMTKTransformIO.cxx for explicit instantiation), with a matching PRIVATE include added to the IOTransformDCMTK target; no test-side workaround is needed because no test directly includes the .hxx.
  • Both itk-module.cmake files are updated to list ITKDCMTK under PRIVATE_DEPENDS instead of DEPENDS.

Confidence Score: 5/5

Safe to merge. The changes are well-scoped relocations of internal headers with appropriate CMake wiring; all internal consumers and test targets are updated consistently.

Both relocated headers (itkDCMTKFileReader.h, itkDCMTKTransformIO.hxx) were already pure implementation details — no changed file exposed them to external callers. Every internal .cxx consumer is covered by the PRIVATE include added to the library target. The test driver workaround correctly handles both the bundled-DCMTK and system-DCMTK cases. The PRIVATE_DEPENDS change in both itk-module.cmake files matches the intent and is consistent with how other ITK modules handle third-party libraries they keep off the public interface.

No files require special attention.

Important Files Changed

Filename Overview
Modules/IO/DCMTK/itk-module.cmake Moves ITKDCMTK from DEPENDS to PRIVATE_DEPENDS; ITKIOImageBase remains a public dependency.
Modules/IO/DCMTK/src/CMakeLists.txt Adds PRIVATE include for src/ so the moved itkDCMTKFileReader.h is found during compilation.
Modules/IO/DCMTK/test/CMakeLists.txt Adds src/ to the test driver include path (needed by itkDCMTKGetDicomTagsTest.cxx) and retains the bundled-DCMTK header reconstruction for the NOT ITK_USE_SYSTEM_DCMTK path.
Modules/IO/IOTransformDCMTK/itk-module.cmake Moves ITKDCMTK from DEPENDS to PRIVATE_DEPENDS; ITKIOTransformBase remains a public dependency.
Modules/IO/IOTransformDCMTK/src/CMakeLists.txt Adds PRIVATE include for src/ so the moved itkDCMTKTransformIO.hxx is found by itkDCMTKTransformIO.cxx.
Modules/IO/IOTransformDCMTK/src/itkDCMTKTransformIO.hxx Renamed/moved from include/ to src/; file contents are unchanged. Only consumed by itkDCMTKTransformIO.cxx for explicit instantiation, so no test-side workaround is needed.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    subgraph Before
        A1[Consumer] -->|sees DCMTK headers| B1[ITKIODCMTK]
        B1 -->|DEPENDS| C1[ITKDCMTK]
        A1 -->|sees DCMTK headers| D1[IOTransformDCMTK]
        D1 -->|DEPENDS| C1
    end

    subgraph After
        A2[Consumer] -->|no DCMTK headers| B2[ITKIODCMTK]
        B2 -->|PRIVATE_DEPENDS| C2[ITKDCMTK]
        A2 -->|no DCMTK headers| D2[IOTransformDCMTK]
        D2 -->|PRIVATE_DEPENDS| C2
    end

    subgraph Headers moved to src/
        H1[itkDCMTKFileReader.h: include to src]
        H2[itkDCMTKTransformIO.hxx: include to src]
    end
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    subgraph Before
        A1[Consumer] -->|sees DCMTK headers| B1[ITKIODCMTK]
        B1 -->|DEPENDS| C1[ITKDCMTK]
        A1 -->|sees DCMTK headers| D1[IOTransformDCMTK]
        D1 -->|DEPENDS| C1
    end

    subgraph After
        A2[Consumer] -->|no DCMTK headers| B2[ITKIODCMTK]
        B2 -->|PRIVATE_DEPENDS| C2[ITKDCMTK]
        A2 -->|no DCMTK headers| D2[IOTransformDCMTK]
        D2 -->|PRIVATE_DEPENDS| C2
    end

    subgraph Headers moved to src/
        H1[itkDCMTKFileReader.h: include to src]
        H2[itkDCMTKTransformIO.hxx: include to src]
    end
Loading

Reviews (1): Last reviewed commit: "ENH: Make ITKDCMTK a private dependency ..." | Re-trigger Greptile

@hjmjohnson hjmjohnson left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good step in the right direction.

@blowekamp blowekamp merged commit da1c2fe into InsightSoftwareConsortium:main Jun 25, 2026
22 checks passed
@hjmjohnson

hjmjohnson commented Jun 25, 2026

Copy link
Copy Markdown
Member

@blowekamp Heads-up: main appears to be red on the Pixi-Cxx GitHub Action after this merged (run for da1c2fe). The ITKIODCMTK test driver no longer finds the DCMTK headers — fails at the build step on ubuntu-22.04 and macos-15:

FAILED: Modules/IO/DCMTK/test/CMakeFiles/ITKIODCMTKTestDriver.dir/itkDCMTKGetDicomTagsTest.cxx.o
Modules/IO/DCMTK/test/../src/itkDCMTKFileReader.h:27:10:
  fatal error: dcmtk/dcmdata/dcdict.h: No such file or directory

Making ITKDCMTK a PRIVATE dependency looks like it stopped propagating the DCMTK include directory to the test target — itkDCMTKGetDicomTagsTest.cxx includes itkDCMTKFileReader.h, which pulls dcmtk/dcmdata/dcdict.h. The DCMTK test (and any test-side consumer of itkDCMTKFileReader.h) likely needs the include path restored. Last green main was c8c14a8, immediately before this merge.

@blowekamp

Copy link
Copy Markdown
Member Author

Please see #6514 for the fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:IO Issues affecting the IO module type:Enhancement Improvement of existing methods or implementation type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants