Skip to content

ENH: Build DCMTK in-scope with FetchContent - #6474

Merged
blowekamp merged 3 commits into
InsightSoftwareConsortium:mainfrom
blowekamp:dcmtk-fetchcontent
Jun 24, 2026
Merged

ENH: Build DCMTK in-scope with FetchContent#6474
blowekamp merged 3 commits into
InsightSoftwareConsortium:mainfrom
blowekamp:dcmtk-fetchcontent

Conversation

@blowekamp

@blowekamp blowekamp commented Jun 18, 2026

Copy link
Copy Markdown
Member

Replace the ExternalProject-based DCMTK build with FetchContent so DCMTK compiles in ITKs CMake scope, consuming ITKs codec targets directly and exporting namespaced DCMTK:: targets through ITKs module system.

DCMTK is exported in its own package and cmake target file. This reduced ITK burden and keeps the export code in DCMTK.

Supersedes #6397.

Changes
  • FetchContent replaces ExternalProject; DCMTK is configured as an add_subdirectory inside ITKs scope
  • Codec libraries wired via ITK::ITKTIFFModule / ITK::ITKJPEGModule / ITK::ITKPNGModule / ITK::ITKZLIBModule interface targets
  • DCMTK:: IMPORTED INTERFACE wrappers created so ITKTargets.cmake records namespaced target names that find_package(DCMTK) can satisfy
  • ITKDCMTK_EXPORT_CODE_BUILD / _INSTALL set to locate DCMTKConfig.cmake in build and install trees
  • DCMTK-internal CMake command overrides (CHECK_FUNCTION_EXISTS, CHECK_CXX_SYMBOL_EXISTS) renamed to DCMTK_CHECK_* to prevent leaking into sibling ITK modules
  • CACHE INTERNAL variable noise removed; normal variables suffice in FetchContent scope
AI assistance

GitHub Copilot (Claude Sonnet 4.6) assisted with CMake design, export target strategy, and identifying the global command override leak. All changes reviewed and committed by blowekamp.

@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:ThirdParty Issues affecting the ThirdParty module labels Jun 18, 2026
@hjmjohnson

Copy link
Copy Markdown
Member

Hi Brad — looked over this. Two things:

Windows is a real failure, not a flake. Pixi-Cxx (windows-2022) dies with the MINC tmpnam #error C1189 in libminc/.../files.c:914. That's the same MSVC CHECK_FUNCTION_EXISTS-leak that 48839b3 ("Build in-scope DCMTK alongside MINC and GDCM on MSVC") was added to fix. 7727bef drops that workaround on the grounds that DCMTK's checks were renamed to DCMTK_CHECK_* — but this PR doesn't bump DCMTKGitTag.cmake (still for/itk-dcmtk-3.7.0-ccfd10b), and the config log still shows Looking for tmpnam - not found, so the global override is leaking into MINC again. Fix needs either the restore-workaround back, or a DCMTK fork tag that actually carries the DCMTK_CHECK_* rename.

Commit structure: all 8 commits touch only Modules/ThirdParty/DCMTK/CMakeLists.txt, and the last three (45ec44d/2839ecf/7727bef) revert or replace most of the first five — itk_module_use removed, CACHE INTERNAL removed, itk_module_target() swapped for DCMTK:: IMPORTED targets, and 48839b3 deleted outright. Once the Windows fix is settled I'd squash the whole thing to a single COMP: Build DCMTK in-scope with FetchContent commit — it's one cohesive build-system change to one file, and the intermediate states aren't independently buildable or bisection-worthy.

@blowekamp

Copy link
Copy Markdown
Member Author

Please see InsightSoftwareConsortium/DCMTK#2, which I was using locally to address that issue.

Comment thread Modules/ThirdParty/DCMTK/CMakeLists.txt Outdated
@blowekamp

Copy link
Copy Markdown
Member Author

@hjmjohnson I will not be working on this during the week end. You are welcome to rebase, squash and resolve difference with main, etc. Please let me review and merge when complete.

The comments are still the lengthly AI style and need to be refined and reviewed.

@hjmjohnson
hjmjohnson force-pushed the dcmtk-fetchcontent branch from 7727bef to a0e474e Compare June 22, 2026 00:06
hjmjohnson pushed a commit to blowekamp/ITK that referenced this pull request Jun 22, 2026
Replace the ExternalProject DCMTK build with FetchContent so DCMTK
configures inside ITK's CMake scope, consumes ITK's codec targets
directly, and exports namespaced DCMTK:: targets through ITK's module
system.

Bump DCMTK_GIT_TAG to the fork commit that prefixes DCMTK's CMake check
commands with DCMTK_, preventing the CHECK_FUNCTION_EXISTS override from
leaking into sibling modules (MINC tmpnam C1189 on MSVC).

Supersedes InsightSoftwareConsortium#6397, InsightSoftwareConsortium#6474 commit series.
hjmjohnson pushed a commit to blowekamp/ITK that referenced this pull request Jun 22, 2026
Replace the ExternalProject DCMTK build with FetchContent so DCMTK
configures inside ITK's CMake scope, consumes ITK's codec targets
directly, and exports namespaced DCMTK:: targets through ITK's module
system.

Bump DCMTK_GIT_TAG to the fork commit that prefixes DCMTK's CMake check
commands with DCMTK_, preventing the CHECK_FUNCTION_EXISTS override from
leaking into sibling modules (MINC tmpnam C1189 on MSVC).

Supersedes InsightSoftwareConsortium#6397, InsightSoftwareConsortium#6474 commit series.
@hjmjohnson
hjmjohnson force-pushed the dcmtk-fetchcontent branch from a0e474e to 9ff0b09 Compare June 22, 2026 01:49
@hjmjohnson

Copy link
Copy Markdown
Member

@blowekamp I did the squashing, and some small cleanups, and mereged the approved DCMTK PR that was needed to support this. Handing it back to you for next steps.

blowekamp added a commit to blowekamp/ITK that referenced this pull request Jun 23, 2026
Replace the ExternalProject DCMTK build with FetchContent so DCMTK
configures inside ITK's CMake scope, consumes ITK's codec targets
directly, and exports namespaced DCMTK:: targets through ITK's module
system.

Bump DCMTK_GIT_TAG to the fork commit that prefixes DCMTK's CMake check
commands with DCMTK_, preventing the CHECK_FUNCTION_EXISTS override from
leaking into sibling modules (MINC tmpnam C1189 on MSVC).

Supersedes InsightSoftwareConsortium#6397, InsightSoftwareConsortium#6474 commit series.
@blowekamp
blowekamp force-pushed the dcmtk-fetchcontent branch from 9ff0b09 to 3de8308 Compare June 23, 2026 13:52
@blowekamp
blowekamp marked this pull request as ready for review June 23, 2026 15:13
@blowekamp

Copy link
Copy Markdown
Member Author

@blowekamp I did the squashing, and some small cleanups, and mereged the approved DCMTK PR that was needed to support this. Handing it back to you for next steps.

Thanks Hans. The changes look good to me now.

@greptile-apps

greptile-apps Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR replaces the ExternalProject_Add-based DCMTK build with FetchContent_MakeAvailable, bringing DCMTK into ITK's own CMake scope so it can consume ITK's codec targets directly and export proper DCMTK:: namespaced targets through ITK's module system. The Git tag is also bumped to pick up a patch that renames DCMTK's internal CMake check commands with a DCMTK_ prefix, preventing them from leaking into sibling ITK modules.

  • The FetchContent approach significantly simplifies the build: ~230 lines of ExternalProject boilerplate are replaced with ~100 lines of direct variable assignments and FetchContent_Declare/MakeAvailable.
  • DCMTK:: IMPORTED INTERFACE wrapper targets are created in a loop post-FetchContent_MakeAvailable; the list(APPEND ITKDCMTK_LIBRARIES) runs outside the if(TARGET …) guard, which would add a non-existent target if any DCMTK library name changed.
  • The DCMTK_USE_ICU=ON + ITK_USE_SYSTEM_ICU=OFF path is broken: ICU is still driven by ExternalProject_Add (build time) while DCMTK's configure now runs at cmake configure time.

Confidence Score: 3/5

Safe to merge for the common case (no ICU, system or FetchContent DCMTK), but the non-system ICU path and the unconditional ITKDCMTK_LIBRARIES append need attention before enabling broader use.

The FetchContent migration is well-structured and correct for the default configuration path. Two concrete defects remain: the DCMTK_LIBRARIES loop appends wrapper target names unconditionally regardless of whether the underlying target was created, and the non-system ICU ExternalProject cannot satisfy DCMTK configure-time find_package calls. The ICU path is off by default but will fail silently on a clean configure when enabled.

Modules/ThirdParty/DCMTK/CMakeLists.txt — specifically the DCMTK:: wrapper loop (lines 247-258) and the DCMTK_USE_ICU + NOT ITK_USE_SYSTEM_ICU code path (lines 12-110 interacting with FetchContent at lines 236-242).

Important Files Changed

Filename Overview
Modules/ThirdParty/DCMTK/CMakeLists.txt Core change replacing ExternalProject_Add with FetchContent_MakeAvailable; two defects found: unconditional ITKDCMTK_LIBRARIES append outside the TARGET guard, and broken non-system ICU path due to configure-time vs build-time ordering.
Modules/ThirdParty/DCMTK/DCMTKGitTag.cmake Updates DCMTK git tag to pick up the DCMTK_ prefix patch for CMake check commands.
Modules/ThirdParty/DCMTK/itk-module-init.cmake Removes lib_prefix/lib_suffix detection block that was only needed for ExternalProject output paths; ICU detection and option declarations retained.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[ITK CMake Configure] --> B{ITK_USE_SYSTEM_DCMTK?}
    B -- YES --> C[find_package DCMTK System install]
    B -- NO --> D{DCMTK_USE_ICU?}
    D -- NO --> E[Set DCMTK variables in ITK scope]
    D -- YES --> F{ITK_USE_SYSTEM_ICU?}
    F -- YES --> G[find_package ICU System install]
    F -- NO --> H[ExternalProject_Add ICU - Builds at BUILD time]
    H --> I[Set ICU_ROOT to not-yet-built path]
    G --> E
    I --> E
    E --> J[FetchContent_MakeAvailable dcmtk - Runs DCMTK cmake NOW]
    J --> K[DCMTK find_package ICU at configure time - ICU not built yet]
    J --> L[DCMTK targets created]
    L --> M[Create DCMTK:: INTERFACE IMPORTED wrappers]
    M --> N{TARGET exists?}
    N -- YES --> O[add_library DCMTK::target]
    N -- NO --> P[Skip wrapper]
    O --> Q[list APPEND ITKDCMTK_LIBRARIES - always runs]
    P --> Q
    Q --> R[itk_module_impl]
    C --> R
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
    A[ITK CMake Configure] --> B{ITK_USE_SYSTEM_DCMTK?}
    B -- YES --> C[find_package DCMTK System install]
    B -- NO --> D{DCMTK_USE_ICU?}
    D -- NO --> E[Set DCMTK variables in ITK scope]
    D -- YES --> F{ITK_USE_SYSTEM_ICU?}
    F -- YES --> G[find_package ICU System install]
    F -- NO --> H[ExternalProject_Add ICU - Builds at BUILD time]
    H --> I[Set ICU_ROOT to not-yet-built path]
    G --> E
    I --> E
    E --> J[FetchContent_MakeAvailable dcmtk - Runs DCMTK cmake NOW]
    J --> K[DCMTK find_package ICU at configure time - ICU not built yet]
    J --> L[DCMTK targets created]
    L --> M[Create DCMTK:: INTERFACE IMPORTED wrappers]
    M --> N{TARGET exists?}
    N -- YES --> O[add_library DCMTK::target]
    N -- NO --> P[Skip wrapper]
    O --> Q[list APPEND ITKDCMTK_LIBRARIES - always runs]
    P --> Q
    Q --> R[itk_module_impl]
    C --> R
Loading

Comments Outside Diff (1)

  1. Modules/ThirdParty/DCMTK/CMakeLists.txt, line 5-6 (link)

    P2 The comment still describes the old ExternalProject model; DCMTK is now built in ITK's own scope via FetchContent.

    Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Reviews (1): Last reviewed commit: "STYLE: Remove redundant /Zc:__cplusplus ..." | Re-trigger Greptile

Comment on lines +247 to 258
foreach(_dcmtk_lib IN LISTS _ITKDCMTK_LIB_NAMES)
set(_dcmtk_target "${_dcmtk_lib}${DCMTK_LIBRARY_SUFFIX}")
if(TARGET "${_dcmtk_target}" AND NOT TARGET "DCMTK::${_dcmtk_target}")
add_library("DCMTK::${_dcmtk_target}" INTERFACE IMPORTED GLOBAL)
target_link_libraries(
"DCMTK::${_dcmtk_target}"
INTERFACE
"${_dcmtk_target}"
)
endif()

# make the imported library depend on its prerequisite
# libraries
set_property(
TARGET
${ITK_MODULE_${itk-module}_TARGETS_NAMESPACE}${lib}
PROPERTY
IMPORTED_LINK_INTERFACE_LIBRARIES
${ITKDCMTK_LIBDEP}
)
list(APPEND ITKDCMTK_LIBRARIES "DCMTK::${_dcmtk_target}")
endforeach()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Non-existent targets silently added to ITKDCMTK_LIBRARIES

list(APPEND ITKDCMTK_LIBRARIES "DCMTK::${_dcmtk_target}") runs unconditionally, outside the if(TARGET "${_dcmtk_target}" AND NOT TARGET "DCMTK::${_dcmtk_target}") guard. If FetchContent_MakeAvailable(dcmtk) did not produce a target for a given library name (e.g., due to a DCMTK version difference or a naming mismatch), the non-existent DCMTK::${_dcmtk_target} is still appended. When itk_module_impl() later processes ITKDCMTK_LIBRARIES, CMake will error on a target that was never defined. The append should move inside — or at least also guard on — the if(TARGET ...) block.

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.

Fixed in 39f4f94 — the list(APPEND ITKDCMTK_LIBRARIES ...) now lives inside an if(TARGET "${_dcmtk_target}") guard, so a missing or renamed DCMTK library no longer appends a non-existent DCMTK:: target.

Comment on lines +216 to 225
if(DCMTK_USE_ICU)
set(DCMTK_WITH_ICU ON)
set(DCMTK_WITH_STDLIBC_ICONV OFF)
set(DCMTK_ENABLE_CHARSET_CONVERSION "ICU" CACHE INTERNAL "") # NOTE: DCMTK requires a cache entry
set(ICU_ROOT "${ICU_ROOT_DIR}")
else()
set(
ITKDCMTK_EXPORT_CODE_BUILD
"
${ITKDCMTK_EXPORT_CODE_BUILD}
foreach(lib ${_ITKDCMTK_LIB_NAMES})
if(NOT TARGET ${ITK_MODULE_${itk-module}_TARGETS_NAMESPACE}\${lib})
add_library(${ITK_MODULE_${itk-module}_TARGETS_NAMESPACE}\${lib} ${_ITKDCMTK_LIB_LINKAGE} IMPORTED)
set_property(TARGET ${ITK_MODULE_${itk-module}_TARGETS_NAMESPACE}\${lib} PROPERTY IMPORTED_LOCATION
\"${lib_dir}/${lib_prefix}\${lib}${lib_suffix}\")
set_property(TARGET ${ITK_MODULE_${itk-module}_TARGETS_NAMESPACE}\${lib} PROPERTY
IMPORTED_LINK_INTERFACE_LIBRARIES
${ITKDCMTK_LINK_DEPENDENCIES})
endif()
endforeach()
"
)
endif()
# create imported targets when module is loaded from install tree
set(
ITKDCMTK_EXPORT_CODE_INSTALL
"
foreach(lib ${_ITKDCMTK_LIB_NAMES})
if(NOT TARGET ${ITK_MODULE_${itk-module}_TARGETS_NAMESPACE}\${lib})
add_library(${ITK_MODULE_${itk-module}_TARGETS_NAMESPACE}\${lib} ${_ITKDCMTK_LIB_LINKAGE} IMPORTED)
set_property(TARGET ${ITK_MODULE_${itk-module}_TARGETS_NAMESPACE}\${lib} PROPERTY IMPORTED_LOCATION
\"\${ITK_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/${lib_prefix}\${lib}${lib_suffix}\")
set_property(TARGET ${ITK_MODULE_${itk-module}_TARGETS_NAMESPACE}\${lib} PROPERTY
IMPORTED_LINK_INTERFACE_LIBRARIES
${ITKDCMTK_LINK_DEPENDENCIES})
set(DCMTK_WITH_ICU OFF)
set(DCMTK_ENABLE_BUILTIN_OFICONV_DATA ON)
set(DCMTK_ENABLE_CHARSET_CONVERSION "oficonv" CACHE INTERNAL "")
endif()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 ICU configure-time / build-time ordering broken when DCMTK_USE_ICU=ON and ITK_USE_SYSTEM_ICU=OFF

FetchContent_MakeAvailable(dcmtk) populates and configures DCMTK at CMake configure time. When DCMTK_USE_ICU=ON and ITK_USE_SYSTEM_ICU=OFF, ICU is still built by ExternalProject_Add(icu …) (line 93), which runs at build time — after the configure phase. DCMTK's cmake, running in-scope during configuration, will call find_package(ICU) with ICU_ROOT pointing at an install directory that doesn't exist yet. The old ExternalProject_Add for DCMTK had an explicit DEPENDS ${ICU_DEPENDENCY} to enforce ordering; FetchContent has no equivalent mechanism.

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.

Fixed in 39f4f94 — the in-scope FetchContent model cannot sequence a build-time ICU ExternalProject before DCMTK's configure-time find_package(ICU). The from-source ICU path is removed; DCMTK_USE_ICU=ON now requires ITK_USE_SYSTEM_ICU=ON and fails with a clear FATAL_ERROR otherwise.

Comment thread Modules/ThirdParty/DCMTK/CMakeLists.txt Outdated
Comment on lines 85 to 92
set(
CHARSET_CONVERSION_ARGS
-DDCMTK_WITH_STDLIBC_ICONV:BOOL=OFF
-DDCMTK_WITH_ICU:BOOL=ON
-DDCMTK_ENABLE_CHARSET_CONVERSION:STRING=ICU
-DICU_ROOT:PATH=${ICU_ROOT_DIR}
)
itk_download_attempt_check(icu)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Dead CHARSET_CONVERSION_ARGS assignment — the variable is built up here but is never passed anywhere in the new FetchContent path (the ExternalProject_Add for DCMTK that consumed it is gone). The equivalent settings are now applied as normal CMake variables directly before FetchContent_MakeAvailable. This branch can be simplified by removing the leftover list-build.

Suggested change
set(
CHARSET_CONVERSION_ARGS
-DDCMTK_WITH_STDLIBC_ICONV:BOOL=OFF
-DDCMTK_WITH_ICU:BOOL=ON
-DDCMTK_ENABLE_CHARSET_CONVERSION:STRING=ICU
-DICU_ROOT:PATH=${ICU_ROOT_DIR}
)
itk_download_attempt_check(icu)
itk_download_attempt_check(icu)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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.

Fixed in 39f4f94 — the dead CHARSET_CONVERSION_ARGS assignments were removed (no ExternalProject consumes them anymore; charset selection is applied via DCMTK_WITH_ICU / DCMTK_ENABLE_CHARSET_CONVERSION directly before FetchContent_MakeAvailable).

Comment thread Modules/ThirdParty/DCMTK/CMakeLists.txt Outdated
Comment on lines 112 to 114
else()
# Built-in oficonv only; disable ICU and external iconv for a deterministic backend.
list(
APPEND
CHARSET_CONVERSION_ARGS
-DDCMTK_WITH_ICU:BOOL=OFF
-DDCMTK_WITH_ICONV:BOOL=OFF
)
set(CHARSET_CONVERSION_ARGS -DDCMTK_WITH_ICU:BOOL=OFF)
endif()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Dead CHARSET_CONVERSION_ARGS assignment in the non-ICU else branch — there is no longer a DCMTK ExternalProject_Add to consume this variable. The DCMTK_WITH_ICU OFF setting is now applied as a normal variable directly in the FetchContent configuration block.

Suggested change
else()
# Built-in oficonv only; disable ICU and external iconv for a deterministic backend.
list(
APPEND
CHARSET_CONVERSION_ARGS
-DDCMTK_WITH_ICU:BOOL=OFF
-DDCMTK_WITH_ICONV:BOOL=OFF
)
set(CHARSET_CONVERSION_ARGS -DDCMTK_WITH_ICU:BOOL=OFF)
endif()
else()
endif()

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

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.

Fixed in 39f4f94 — dead CHARSET_CONVERSION_ARGS removed here too; the DCMTK_WITH_ICU OFF setting is now applied as a normal variable in the FetchContent block.

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.

Confirmed and fixed. With the build moved in-scope via FetchContent + add_subdirectory(), there's no separate CMake invocation to receive a -D argument list, so the CHARSET_CONVERSION_ARGS marshalling is dead. The charset configuration is now set directly as ordinary variables in the DCMTK_USE_ICU if/else block (DCMTK_WITH_ICU, DCMTK_ENABLE_BUILTIN_OFICONV_DATA, and the cache entry DCMTK_ENABLE_CHARSET_CONVERSION), matching how every other DCMTK option in this file is passed. The dead CHARSET_CONVERSION_ARGS assignment has been removed.

Replace the ExternalProject DCMTK build with FetchContent so DCMTK
configures inside ITK's CMake scope, consumes ITK's codec targets
directly, and exports namespaced DCMTK:: targets through ITK's module
system.

Bump DCMTK_GIT_TAG to the fork commit that prefixes DCMTK's CMake check
commands with DCMTK_, preventing the CHECK_FUNCTION_EXISTS override from
leaking into sibling modules (MINC tmpnam C1189 on MSVC).

Supersedes InsightSoftwareConsortium#6397, InsightSoftwareConsortium#6474 commit series.
Move lib_prefix into CMakeLists.txt next to its only use and reduce
it to a single line: ICU is always built statically on non-Windows so
CMAKE_STATIC_LIBRARY_PREFIX is the only relevant value. Remove
lib_suffix entirely; it was set but never read.
DCMTK's GenerateDCMTKConfigure.cmake already appends /Zc:__cplusplus
to CMAKE_CXX_FLAGS after its STL feature probes. The INTERFACE
target_compile_options on ITKDCMTKModule at the bottom of this file
handles propagation to consumers.
@hjmjohnson
hjmjohnson force-pushed the dcmtk-fetchcontent branch from 3de8308 to 347daf6 Compare June 23, 2026 15:55
@hjmjohnson

Copy link
Copy Markdown
Member

Pushed fixes for the four Greptile findings (force-pushed with lease, your authorship preserved on all three commits, no rebase onto upstream/main):

  • P1 (append guard): list(APPEND ITKDCMTK_LIBRARIES ...) moved inside the if(TARGET ...) guard.
  • P1 (ICU ordering): the in-scope FetchContent model can't sequence a build-time ICU ExternalProject before DCMTK's configure-time find_package(ICU). Removed the from-source ICU path; DCMTK_USE_ICU=ON now requires ITK_USE_SYSTEM_ICU=ON (clear FATAL_ERROR otherwise).
  • P2 (dead CHARSET_CONVERSION_ARGS): removed from both CMakeLists.txt and itk-module-init.cmake.
  • P2 (stale comments): updated the ExternalProject-era comments to describe the FetchContent model.

The first three commits squashed clean; net -134/+18 across the two CMake files. Default builds (DCMTK_USE_ICU=OFF) are unaffected. Handing back to you to review and merge.

@hjmjohnson

Copy link
Copy Markdown
Member

@blowekamp Sorry, but Greptile identified 3 more issues. They and the solutions sound correct to me, but they are non-trivial changes. I left the solutions unresolved to make it easier to review.

@hjmjohnson
hjmjohnson self-requested a review June 23, 2026 16:24
@blowekamp

Copy link
Copy Markdown
Member Author

@blowekamp Sorry, but Greptile identified 3 more issues. They and the solutions sound correct to me, but they are non-trivial changes. I left the solutions unresolved to make it easier to review.

@hjmjohnson I am not following what you and your AI have done here nor what you are asking me to do. I'll leave fixing this up to you and your agents and not spend more time here understanding these review comments right now.

@blowekamp

Copy link
Copy Markdown
Member Author

So.. The optional ICU dependency also needs to be converted to FetchContent so it's available during configuration of DCMTK.

@hjmjohnson

Copy link
Copy Markdown
Member

So.. The optional ICU dependency also needs to be converted to FetchContent so it's available during configuration of DCMTK.

I will try to figure that out tomorrow afternoon.

@blowekamp

Copy link
Copy Markdown
Member Author

So.. The optional ICU dependency also needs to be converted to FetchContent so it's available during configuration of DCMTK.

I will try to figure that out tomorrow afternoon.

Thank you Hans. I thought I was working on this branch yesterday and it was changed on me which was discouraging.

Just not that with the other changes to third-party libraries now using CMake interface libraries e.g. JPEG::JPEG the ExternalProject DCMTK build with system libraries has broken. The interface libraries can not be communicated through a "-DJPEG_LIBRARIES=JPEG::JPEG". However this tighter coupling with FetchContent does work with the interface libraries.

If this PR is good except for the ICU ExternalProject option ( disable by default) it maybe work merging, and making another PR to update the ICU project.

@hjmjohnson

Copy link
Copy Markdown
Member

Thanks Hans. The changes look good to me now.

@blowekamp Sorry, I misinterpreted that statement as hand-off back to me. I should have double checked. I'm approving this and will let you merge. I do think it is best to make an evolutionary step forward to help decouple the issues.

@blowekamp
blowekamp merged commit 1f56182 into InsightSoftwareConsortium:main Jun 24, 2026
21 checks passed
@blowekamp

Copy link
Copy Markdown
Member Author

@blowekamp Sorry, I misinterpreted that statement as hand-off back to me. I should have double checked. I'm approving this and will let you merge. I do think it is best to make an evolutionary step forward to help decouple the issues.

Perhaps if there a multiple developers handing off who is working on a PR, the "assignee" field can be used.

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

Labels

area:ThirdParty Issues affecting the ThirdParty 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