Reputation: 2158
As stated here https://cmake.org/cmake/help/latest/module/FindCUDA.html
find_package(CUDA)
is a deprecated way to use CUDA in CXX project. We have to use
project(MY_PROJECT LANGUAGES CUDA CXX)
but how can I detect whether the current platform supports CUDA. The goal is to exclude some targets from build if CUDA is not installed.
Upvotes: 1
Views: 647
Reputation: 2158
Just found a solution thanks to a comment posted on the question referring to this Stack Overflow answer, and in turn this piece of documentation.
Here is a code snippet :
cmake_minimum_required(VERSION 3.8)
include(CheckLanguage)
project(my_project)
check_language(CUDA)
if (CMAKE_CUDA_COMPILER)
message(STATUS "CUDA is OK")
else()
message(STATUS "No CUDA")
endif()
Upvotes: 1