Reputation: 64
I am recently using CMake to compile my CUDA codes, but don't know how to pass different compile flags to nvcc, in Debug or Release mode. I wish I can specify something as follows,
set(CUDA_GENE_FLAGS_DEBUG "-gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37")
set(CUDA_GENE_FLAGS_RELEASE "-Xptxas -O3 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37")
So when I specify Debug or Release mode in visual studio, these flags can be chosen automatically. Can anyone give me a hand on this? Thanks.
Upvotes: 4
Views: 4334
Reputation: 305
I encountered a same problem while compiling linking OpenMP for a CUDA program.
According to the latest CMake document for FindCUDA here, you should try these three variables: CUDA_NVCC_FLAGS
, CUDA_NVCC_FLAGS_DEBUG
and CUDA_NVCC_FLAGS_RELEASE
.
But it didn't work for me and then I found another reference.
If none of above variables work, try to use CMAKE_CUDA_FLAGS
like this for a workaround:
set(CMAKE_CUDA_FLAGS ${YOUR_FLAGS})
Upvotes: 6