CUDA_ADD_CUDA_INCLUDE_ONCE does not include directories as system headers
We have currently trouble with treating warnings as errors via set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
in your project, because CUDA_ADD_CUDA_INCLUDE_ONCE
is adding include directories via include_directories(${CUDA_INCLUDE_DIRS})
.
Possible solution:
- Variant 1: Change line to
include_directories(SYSTEM ${CUDA_INCLUDE_DIRS})
- Variant 2: Use
target_include_directories(${cuda_target} SYSTEM PUBLIC ${CUDA_INCLUDE_DIRS})
(more clean). - Variant 1+/2+: Add option to
CUDA_ADD_LIBRARY
CUDA_ADD_EXECUTABLE
, so every developer can decide if this should be system include directories or not (in case you think there is a reason to not include it as system include directories).
Not sure if this issue is also related to enable_language(CUDA)
.
I tried to workaround this for older CMake versions (before 3.9), but failed (see here). Any idea how to workaround this issue for older CMake versions?