Whenever the user changes the value and clicks Configure or Generate, the values are reset back to 52 60 61 75. But there doesn’t seem to be any way to change that selection. On the other hand the cmake-gui correctly reports the set of selected architectures to the user. (It does keep the user selection shown, but that selection is ignored.)īy using set(CMAKE_CUDA_ARCHITECTURES 52 60 61 75 CACHE STRING "CUDA architectures" FORCE) It does work the way you describe it, it does have the desired effect of enforcing “my favourite” list of architectures, but first of all it lies to the user about the architectures being used (the GUI claims that the architecture 30 would be used) which is not too helpful, and even more importantly it prevents the user from having any effect on the set of architectures being used for the actual compilation.
#Clion cuda code
The code set(CMAKE_CUDA_ARCHITECTURES 52 60 61 75) The option 70 stays (it should not be automatically changed back to 52 60 61 75) and the generated project has the correct flags just for architecture 70. The user changes that value to 70, clicks Configure, then Generate. The value of CMAKE_CUDA_ARCHITECTURES should read 52 60 61 75 (not 30). I would want to compile support for architectures “ 52 60 61 75” in that case.Ĭase 2: The user compiling the library runs cmake-gui, selects Configure. (Still, I don’t want to specify this property on per-target basis I just want to be able to specify the list of architectures at a single place and keep it consistent across the project.) I would like to support the following two scenarios:Ĭase 1: The user compiling the library doesn’t do anything extra (no extra options are specified).
#Clion cuda how to
Thank you for the explanation, it clarified some aspects of how CMake handles cache, so I can better understand what is going on under the hood, but I still don’t quite get it how to achieve what I’m striving for.įor simplicity let’s assume that we only have a trivial hello-world library with a single CMakeLists.txt, so there is no need for different CMakeLists.txt inside the project to override each other.
I installed CMake 0520-g81e8f62 on Windows, I’m using Visual Studio 10.19 (16.7.0 Preview 1.0) with NVidia’s SDK 10.2. Note the strange flag -compile -cudart static 61 75,code= Nvcc fatal : A single input file is required for a non-link phase when an outputfile is specified Set_property(TARGET hello PROPERTY CUDA_ARCHITECTURES 52 61 75)ĭuring configuration I have tried to set CMAKE_CUDA_ARCHITECTURES to 52 61 75 in the GUI, but the compiler test fails with Compiling CUDA source file main.cu.Ĭ:\MyProject\build\vs2019-圆4\CMakeFiles\CMakeTmp>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\bin\nvcc.exe" -use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\VC\Tools\MSVC\6\bin\HostX64\圆4" -x cu -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v10.2\include" -keep-dir 圆4\Debug -maxrregcount=0 -machine 64 -compile -cudart static 61 75,code= -Xcompiler="/EHsc -Zi -Ob0" -g -D_WINDOWS -D"CMAKE_INTDIR=\"Debug\"" -D"CMAKE_INTDIR=\"Debug\"" -D_MBCS -Xcompiler "/EHsc /W3 /nologo /Od /FdcmTC_e9572.dir\Debug\vc142.pdb /FS /Zi /RTC1 /MDd /GR" -o cmTC_e9572.dir\Debug\main.obj "C:\MyProject\build\vs2019-圆4\CMakeFiles\CMakeTmp\main.cu"
So I tried (simplified): cmake_minimum_required(VERSION 3.17 FATAL_ERROR)Īdd_library(hello SHARED hello.cpp hello.h hello.cu) I was looking for ways to properly target different compute capabilities of cuda devices and found a couple of new policies for 3.18.