diff --git a/CMakeLists.txt b/CMakeLists.txt index f6f34abd4..1caea9809 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -28,8 +28,17 @@ SET(CMAKE_CXX_STANDARD_REQUIRED True) # Catch2 compiles itself with CATCH_CONFIG_DISABLE_EXCEPTIONS. Adding it here, before any # FetchContent, reaches every C++ target whatever CMAKE_CXX_FLAGS holds. CUDA gets it from its own # default CMAKE_CUDA_FLAGS, which nothing overrides. +# +# CUDA's CCCL headers (cub, thrust, libcu++) stop with an #error under MSVC's traditional +# preprocessor, which miscompiles their macros. nvcc preprocesses and compiles host code with cl.exe, +# so the standard-conforming preprocessor is switched on for .cu sources here, reaching every CUDA +# target, fetched ones included (VS 2019 16.5 or newer). ffbidx already sets the same for its own +# CUB-using kernel, which is why the other CUDA targets never needed it. C++ sources keep the +# default: none includes a CCCL header, and the switch would change the preprocessing of Qt, the +# Windows SDK and every fetched dependency with nothing to gain. IF (MSVC) ADD_COMPILE_OPTIONS($<$:/EHsc>) + ADD_COMPILE_OPTIONS($<$:-Xcompiler=/Zc:preprocessor>) ENDIF() SET(JFJOCH_WRITER_ONLY OFF CACHE BOOL "Compile HDF5 writer only")