COMP: Link namespaced DCMTK targets in the DCMTK IO modules#6543
Conversation
Match the vendored DCMTK version and guarantee that the system package config exports DCMTK::-namespaced imported targets, which the DCMTK IO modules link against.
|
| Filename | Overview |
|---|---|
| Modules/IO/DCMTK/src/CMakeLists.txt | Updates ITKIODCMTK to link namespaced DCMTK targets so exported build-tree consumers resolve DCMTK libraries. |
| Modules/IO/IOTransformDCMTK/src/CMakeLists.txt | Updates IOTransformDCMTK to link the namespaced DCMTK dcmdata target. |
| Modules/ThirdParty/DCMTK/CMakeLists.txt | Adds vendored DCMTK namespaced wrappers and build-tree export repair, with one cache override issue in the single-library mode pin. |
| Modules/ThirdParty/DCMTK/itk-module-init.cmake | Raises system DCMTK discovery to require version 3.7.0 for namespaced target availability. |
Sequence Diagram
%%{init: {'theme': 'neutral'}}%%
sequenceDiagram
participant Consumer as External build-tree consumer
participant ITK as ITKConfig / ITKDCMTK export code
participant DCMTK as DCMTKConfig.cmake
participant Targets as Imported targets
Consumer->>ITK: find_package(ITK COMPONENTS ITKIODCMTK)
ITK->>DCMTK: set DCMTK_DIR to ITK build root
ITK->>DCMTK: find_package(DCMTK REQUIRED NO_MODULE)
DCMTK->>Targets: import DCMTK::dcmdata and related targets
ITK->>Targets: "rewrite DCMTK::ITK::*Module links to ITK::*Module"
Consumer->>Targets: "link ITKIODCMTK / IOTransformDCMTK via DCMTK::* targets"
%%{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"}}}%%
sequenceDiagram
participant Consumer as External build-tree consumer
participant ITK as ITKConfig / ITKDCMTK export code
participant DCMTK as DCMTKConfig.cmake
participant Targets as Imported targets
Consumer->>ITK: find_package(ITK COMPONENTS ITKIODCMTK)
ITK->>DCMTK: set DCMTK_DIR to ITK build root
ITK->>DCMTK: find_package(DCMTK REQUIRED NO_MODULE)
DCMTK->>Targets: import DCMTK::dcmdata and related targets
ITK->>Targets: "rewrite DCMTK::ITK::*Module links to ITK::*Module"
Consumer->>Targets: "link ITKIODCMTK / IOTransformDCMTK via DCMTK::* targets"
Comments Outside Diff (1)
-
General comment
Build-tree ITK import skips DCMTK target rewrite after DCMTK was imported first
- Bug
- The PR claim requires an external build-tree consumer to import DCMTK from the ITK build root before
find_package(ITK), then have ITK's package import rewrite already-importedDCMTK::targets fromDCMTK::ITK::*Modulereferences toITK::*Module. Executed head evidence shows this does not happen: afterfind_package(ITK REQUIRED COMPONENTS ITKIODCMTK),DCMTK::dcmdatastill containsDCMTK::ITK::ITKZLIBModule. This leaves the same broken imported-target namespace that the change was intended to repair.
- The PR claim requires an external build-tree consumer to import DCMTK from the ITK build root before
- Cause
- In
Modules/ThirdParty/DCMTK/CMakeLists.txt, the generated build-tree export code added at lines 172-187 is wrapped inif(NOT ITK_BINARY_DIR). In the build-tree consumer scenario, importing ITK definesITK_BINARY_DIR, so the rewrite loop is skipped and previously importedDCMTK::targets are not repaired.
- In
- Fix
- Run the rewrite loop for external consumers even when
ITK_BINARY_DIRis defined by a build-tree ITK package import. For example, do not guard the repair withif(NOT ITK_BINARY_DIR), or replace it with a condition that only avoids recursive/inside-ITK execution while still executing during external build-tree package import. Then verify thatDCMTK::ITK::entries becomeITK::afterfind_package(ITK).
- Run the rewrite loop for external consumers even when
- Bug
Reviews (1): Last reviewed commit: "COMP: Repair DCMTK build-tree export ref..." | Re-trigger Greptile
|
I was able to inspect the DCMTKTargets.cmake file and verified this but. The first two commit look like they can quickly go in quickly. The namespace export changes I would like more time to inspect closer, there may be changes needed in DCMTK to make this fix more normal. |
Bare dcmdata/dcmimgle/... names survive only inside ITK's own build scope; the exported link interface then carries $<LINK_ONLY:dcmdata>, which no external consumer of the ITK build tree can resolve. The DCMTK:: wrapper targets export as DCMTK::dcmdata, which consumers resolve through find_package(DCMTK). Pin BUILD_SINGLE_SHARED_LIBRARY=OFF for the vendored build: a single- library build renames the per-library targets with a suffix that the DCMTK::<lib> link names cannot match, and the suffix variable is not visible outside DCMTK's directory scope. This also retires the dead DCMTK_LIBRARY_SUFFIX handling in the wrapper loop.
bcc43b3 to
0a0a06c
Compare
|
Done as suggested @blowekamp: this PR is now just the first two commits (with the inline |
Link the DCMTK IO modules against
DCMTK::-namespaced targets so the exported link interface resolves for external consumers, and require DCMTK 3.7.0+ forITK_USE_SYSTEM_DCMTK(the first release whose package config exports those namespaced targets).Why
Bare
dcmdata/dcmimgle/... names survive only inside ITK's own build scope; the exported link interface then carries$<LINK_ONLY:dcmdata>, which no external consumer of the ITK build tree can resolve. TheDCMTK::wrapper targets export asDCMTK::dcmdata, which consumers resolve throughfind_package(DCMTK).BUILD_SINGLE_SHARED_LIBRARYis pinned OFF with a plainset()(per review): a single-library build renames the per-library targets with a suffix theDCMTK::<lib>link names cannot match.Testing
Configured and built
Module_ITKIODCMTK+IOTransformDCMTKlocally with the vendored DCMTK; all 46 DCMTK tests pass. Also verified the stale-cache scenario from review: with a poisonedBUILD_SINGLE_SHARED_LIBRARY:BOOL=ONcache entry, configure/generate still produce the per-library targets (the plainset()shadows the cache).The build-tree export repair for the
DCMTK::ITK::*Modulemis-prefix (formerly the third commit here) is split out to #6548 (draft) for closer inspection, per @blowekamp. Note: #6548 should land with or promptly after this PR — with the namespaced linking alone, an external build-tree consumer fails at generate resolvingDCMTK::ITK::*Module(verified repro in #6548; on currentmainthe same consumer instead fails at link time, so no working flow regresses). Install-tree consumers are unaffected.