Reputation: 349
My project uses CMake-GUI with visual studio. There is no gpu card installed on my system. The visual studio solution generated sets the nvcc flags to compute_30 and sm_30 but I need to set it to compute_50 and sm_50.
I use CMake 3.10.1 and Visual studio 14 2015 with 64 bit compilation.
I wish to supersede the default setting from CMake. I am not using the Find CUDA method to search and add CUDA. I am adding CUDA as a language support in CMAKE and VS enables the CUDA Build customization based on that.
Upvotes: 11
Views: 19920
Reputation: 121
With CMake 3.18 there is the new target property CUDA_ARCHITECTURES
. From the documentation here:
set_property(TARGET myTarget PROPERTY CUDA_ARCHITECTURES 35 50 72)
Generates code for real and virtual architectures 30, 50 and 72.
set_property(TARGET myTarget PROPERTY CUDA_ARCHITECTURES 70-real 72-virtual)
Generates code for real architecture 70 and virtual architecture 72.
Upvotes: 12
Reputation: 349
So I was able to figure it out myself. The following way we can set it -
string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_50,code=sm_50")
Upvotes: 5
Reputation: 464
The correct way is:
target_compile_options(myTarget PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-gencode arch=compute_50,code=sm_50>)
Select PRIVATE/PUBLIC as needed. This is the correct way to set per target flags.
Upvotes: 12