ENH: Make ITKDCMTK a private dependency of ITKIODCMTK and IOTransformDCMTK#6496
Conversation
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.
| # 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 |
There was a problem hiding this comment.
Some of this extra configuration may be able to be cleaning up after the DCMTK FetchContent PR is merged.
|
| 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
%%{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
Reviews (1): Last reviewed commit: "ENH: Make ITKDCMTK a private dependency ..." | Re-trigger Greptile
hjmjohnson
left a comment
There was a problem hiding this comment.
Good step in the right direction.
|
@blowekamp Heads-up: Making |
|
Please see #6514 for the fix |
Move DCMTK headers out of public include paths so consumers of
ITKIODCMTKandIOTransformDCMTKno longer need DCMTK on their include path.Changes
ITKIODCMTK
itkDCMTKFileReader.hmoved frominclude/tosrc/; it exposedDcmStack,E_TransferSyntax,DcmDictEntryand other DCMTK types in the public API but is an internal implementation class.src/CMakeLists.txt: addedPRIVATEinclude forsrc/so the.cxxfiles find the moved header.test/CMakeLists.txt: addedsrc/to the test driver include path (the existing DCMTK header workaround was already present).itk-module.cmake:ITKDCMTKmoved fromDEPENDStoPRIVATE_DEPENDS.IOTransformDCMTK
itkDCMTKTransformIO.hxxmoved frominclude/tosrc/; it was already only included fromitkDCMTKTransformIO.cxxfor explicit instantiation.src/CMakeLists.txt: addedPRIVATEinclude forsrc/.itk-module.cmake:ITKDCMTKmoved fromDEPENDStoPRIVATE_DEPENDS.AI assistance