Skip to content

WIP: REMOTE_MODULE_TEST BUG: Fix DCMTK external module compatibility (ijg include paths + MSVC __cplusplus)#6072

Draft
hjmjohnson wants to merge 2 commits intoInsightSoftwareConsortium:release-5.4from
hjmjohnson:fix-dcmtk-external-module-compat
Draft

WIP: REMOTE_MODULE_TEST BUG: Fix DCMTK external module compatibility (ijg include paths + MSVC __cplusplus)#6072
hjmjohnson wants to merge 2 commits intoInsightSoftwareConsortium:release-5.4from
hjmjohnson:fix-dcmtk-external-module-compat

Conversation

@hjmjohnson
Copy link
Copy Markdown
Member

Fix two DCMTK issues that break external module builds (e.g., ITKIOTransformDCMTK). Backport candidate for v5.4.6 per #6051.

Issue 1 (Linux): DCMTK internal JPEG codec libraries (ijg8, ijg12, ijg16) are included in the INTERFACE_INCLUDE_DIRECTORIES loop, but these libraries have no public headers. The exported paths don't exist, causing CMake configure errors in external modules.

Issue 2 (Windows): MSVC reports __cplusplus == 199711L regardless of the actual C++ standard. DCMTK's osconfig.h checks __cplusplus >= 201103L and raises #error on MSVC even with C++17 enabled. Adding /Zc:__cplusplus makes MSVC report the true value.

Downstream impact
Commits
  1. BUG: Exclude DCMTK ijg libs from INTERFACE_INCLUDE_DIRECTORIES* — skip ijg8/ijg12/ijg16 in the include path loop
  2. COMP: Add /Zc:__cplusplus for MSVC — in itkCompilerChecks.cmake, append /Zc:__cplusplus when building with MSVC (available since 19.14, we require 19.20+)

The DCMTK ExternalProject include path loop iterates over all
_ITKDCMTK_LIB_NAMES and adds ${lib}/include to
ITKDCMTK_INCLUDE_DIRS. The internal JPEG codec libraries (ijg8,
ijg12, ijg16) have no public headers, so these paths don't exist.
When exported in INTERFACE_INCLUDE_DIRECTORIES, CMake 3.x+ raises
an error in external modules that link against ITK::ITKDCMTKModule:

  Imported target "ITK::ITKDCMTKModule" includes non-existent path
  ".../ITKDCMTK_ExtProject/ijg12/include"

Skip libs matching "^ijg" in the include path loop. These are
internal JPEG codecs used only by dcmjpeg and never needed in
consumer include paths.

Fixes ITKIOTransformDCMTK#17 (Linux build failure).
MSVC does not set __cplusplus to the correct value by default —
it always returns 199711L regardless of the actual standard being
compiled with. DCMTK's osconfig.h checks:

  #if defined(HAVE_CXX11) && __cplusplus < 201103L
  #error DCMTK was configured to use C++11 features, but ...
  #endif

This fires on MSVC even when C++17 is enabled because __cplusplus
reports 199711L. The /Zc:__cplusplus flag (available since VS2017
15.7, MSVC 19.14) makes the compiler report the true value.

ITK already requires MSVC 19.20+ so this flag is always available.

Fixes ITKIOTransformDCMTK#17 (Windows build failure).
@github-actions github-actions bot added type:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots area:ThirdParty Issues affecting the ThirdParty module labels Apr 15, 2026
@hjmjohnson hjmjohnson changed the title BUG: Fix DCMTK external module compatibility (ijg include paths + MSVC __cplusplus) WIP: REMOTE_MODULE_TEST BUG: Fix DCMTK external module compatibility (ijg include paths + MSVC __cplusplus) Apr 16, 2026
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:Bug Inconsistencies or issues which will cause an incorrect result under some or all circumstances type:Infrastructure Infrastructure/ecosystem related changes, such as CMake or buildbots

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant