From 8eb864bd4678f3469792b39f4ded6e264a7d35d2 Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Wed, 15 Apr 2026 16:31:35 -0500 Subject: [PATCH 1/2] BUG: Exclude DCMTK ijg* libs from INTERFACE_INCLUDE_DIRECTORIES 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). --- Modules/ThirdParty/DCMTK/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Modules/ThirdParty/DCMTK/CMakeLists.txt b/Modules/ThirdParty/DCMTK/CMakeLists.txt index 5aaf18f2ebf..f4b4c6c7217 100644 --- a/Modules/ThirdParty/DCMTK/CMakeLists.txt +++ b/Modules/ThirdParty/DCMTK/CMakeLists.txt @@ -130,7 +130,13 @@ else(ITK_USE_SYSTEM_DCMTK) set(ITKDCMTK_LIBRARIES "${_ITKDCMTK_LIB_NAMES}") # # add all the embedded include directories to include dirs + # Skip internal JPEG codec libraries (ijg8, ijg12, ijg16) — they have + # no public headers and exporting non-existent paths in + # INTERFACE_INCLUDE_DIRECTORIES causes CMake errors in external modules. foreach(lib ${_ITKDCMTK_LIB_NAMES}) + if(lib MATCHES "^ijg") + continue() + endif() # add to include list list(APPEND ITKDCMTK_INCLUDE_DIRS ${ITKDCMTK_INCLUDE}/${lib}/include) From 83b75005b93b75ae87e1185f03949a964c832846 Mon Sep 17 00:00:00 2001 From: "Hans J. Johnson" Date: Wed, 15 Apr 2026 16:31:43 -0500 Subject: [PATCH 2/2] COMP: Add /Zc:__cplusplus for MSVC to fix DCMTK C++11 detection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- CMake/itkCompilerChecks.cmake | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/CMake/itkCompilerChecks.cmake b/CMake/itkCompilerChecks.cmake index 6a41860130c..da1be82a20b 100644 --- a/CMake/itkCompilerChecks.cmake +++ b/CMake/itkCompilerChecks.cmake @@ -38,3 +38,12 @@ if(NOT ITK_IGNORE_CMAKE_CXX17_CHECKS) set(CMAKE_CXX_EXTENSIONS OFF) endif() endif() + +# MSVC does not set __cplusplus correctly by default (returns 199711L +# regardless of the actual standard). /Zc:__cplusplus makes it report +# the true value. Required for third-party headers (e.g. DCMTK +# osconfig.h) that check __cplusplus >= 201103L at compile time. +# Available since VS2017 15.7 (MSVC 19.14); we require 19.20+. +if(MSVC AND NOT CMAKE_CXX_FLAGS MATCHES "/Zc:__cplusplus") + string(APPEND CMAKE_CXX_FLAGS " /Zc:__cplusplus") +endif()