CUDA: generator expression removes a gencode flag in CUDA_SELECT_NVCC_ARCH_FLAGS output variable
Hello CMake Community !
I encounter something strange on a CMake project using CXX and CUDA.
CMake Version : cmake-3.14.0-Linux-x86_64
I am using the find_package(CUDA REQUIRED)
to have access to the CUDA_SELECT_NVCC_ARCH_FLAGS
function.
Targeting Maxwell and Pascal Nvidia Architectures, I used the following command :
CUDA_SELECT_NVCC_ARCH_FLAGS(ARCH_FLAGS "5.2;6.1")
at this point :
${ARCH_FLAGS}
= -gencode;arch=compute_52,code=sm_52;-gencode;arch=compute_61,code=sm_61
${ARCH_FLAGS_readable}
= sm_52 sm_61
I work on a library that use C++17 .cpp/.h files and some CUDA .cu files. When I specify to CMake which flag to use when compiling Cuda files, I use this command :
target_compile_options(mylib
PRIVATE
$<$<COMPILE_LANGUAGE:CUDA>:-m64 -rdc=true ${ARCH_FLAGS}>
)
at this point, CMake Project is well parsed.
But when I try to compile, I receive an error from nvcc :
nvcc fatal : A single input file is required for a non-link phase when an outputfile is specified
which means (after googling the issue) : The command is not well formed !
And yes, it is not !
Here is the CMake built command :
/usr/local/cuda/bin/nvcc -I/usr/local/cuda/targets/x86_64-linux/include -I/home/myUser/myLib/include -g -Xcompiler=-fPIC -m64 -rdc=true -gencode arch=compute_52,code=sm_52 arch=compute_61,code=sm_61 -std=c++14 -x cu -c /home/myUser/myLib/src/libname/my_lib.cu -o CMakeFiles/myLib.dir/src/libname/my_lib.cu.o
It seams that a -gencode is missing just before the arch=compute_61,code=sm_61
.
It seams too that the generator expression removes duplicates when expanding list variables...
I did not found any issues on something similar, so, here I am, thanking you in advance for your help and advice !
Best regards !