nvcc "-Xcompiler" flag should not be de-duplicated
CMakeLists.txt:
cmake_minimum_required(VERSION 3.18)
project(test CUDA)
add_library(test test.cu)
target_compile_options(test PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler -Werror>)
target_compile_options(test PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler -Wno-error=unused-const-variable>)
Generated command:
/usr/local/cuda/bin/nvcc -forward-unknown-to-host-compiler --generate-code=arch=compute_30,code=[compute_30,sm_30] -Xcompiler -Werror -Wno-error=unused-const-variable -x cu -c test.cu -o CMakeFiles/test.dir/test.cu.o
From #20869 (closed) I knew that -Xcompiler is de-duplicated. However, it is not correct. -Xcompiler -Werror -Wno-error=unused-const-variable
only passes "-Werror" to the underlying compiler, resulting in an error because of -Wno-error=unused-const-variable
unrecognized by nvcc.
Edited by daquexian