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() 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)