Reputation: 131646
How does one check the version of NVCC, with CMake 3.15 (not 3.17 or later)?
I suppose I could write my own module to run it with --version
, but is there an easier way to do it?
Upvotes: 2
Views: 1274
Reputation: 19926
In CMake 3.15 with CUDA
language support enabled, the CMAKE_CUDA_COMPILER_VERSION
variable is defined and contains the correct version. MRE:
cmake_minimum_required(VERSION 3.15)
project(test LANGUAGES CUDA)
message(STATUS "CMAKE_CUDA_COMPILER = ${CMAKE_CUDA_COMPILER}")
message(STATUS "CMAKE_CUDA_COMPILER_ID = ${CMAKE_CUDA_COMPILER_ID}")
message(STATUS "CMAKE_CUDA_COMPILER_VERSION = ${CMAKE_CUDA_COMPILER_VERSION}")
Output:
$ cmake-3.15 -S . -B build
-- The CUDA compiler identification is NVIDIA 10.1.243
-- Check for working CUDA compiler: /usr/bin/nvcc
-- Check for working CUDA compiler: /usr/bin/nvcc -- works
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done
-- CMAKE_CUDA_COMPILER = /usr/bin/nvcc
-- CMAKE_CUDA_COMPILER_ID = NVIDIA
-- CMAKE_CUDA_COMPILER_VERSION = 10.1.243
-- Configuring done
-- Generating done
-- Build files have been written to: /home/alex/test/build
I have various versions of CMake installed as cmake-3.XX
, I assume you would simply run cmake
.
Upvotes: 1