[CMake] Ways to require CUDA arch minimum version?

Mojca Miklavec mojca at macports.org
Wed Aug 21 07:57:40 EDT 2019


On Fri, 16 Aug 2019 at 03:34, Hong Xu wrote:
>
> Is there a way to enforce a minimum CUDA arch version when finding CUDA?
> Hong

I don't know if the following is the correct advice, but I use the
following code in my setup to enforce Pascal:

    string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_60,code=sm_60")

else my code would not compile once I started using some newer directives.
I believe that more archs would be needed in the string for better
support of newer architectures, but just to get the starting point.

I would have preferred if there was a better directive, similar to
    set(CMAKE_CXX_STANDARD 14)
that can enable either C++14 or C++17 or later (depending on other
components of the project) without actually harcoding c++14 and ending
up with "-std=c++14 -std=c++20" in flags. For example something along
the lines of
    set(CMAKE_CUDA_MIN_ARCH 60)

Mojca


More information about the CMake mailing list