CMake fails to configure CUDA using clang++-14
(Filed following this SO answer.)
I'm trying to configure a build with the following list file:
cmake_minimum_required(VERSION 3.24)
project(vector_addition_with_clang CUDA)
add_executable(vectorAdd vectorAdd.cu)
set_target_properties(vectorAdd PROPERTIES CUDA_ARCHITECTURES native)
and with the following command-line:
cmake -B build -DCMAKE_CUDA_HOST_COMPILER=clang++-14 -DCMAKE_CUDA_COMPILER=clang++-14
Now, if I replace clang++-14 with clang++-16, everything works fine. But with clang++-14 (and with --debug-output
), I get:
-- The CUDA compiler identification is unknown
Called from: [3] /opt/versions/cmake/3.28.1/share/cmake-3.28/Modules/CMakeDetermineCompilerId.cmake
[2] /opt/versions/cmake/3.28.1/share/cmake-3.28/Modules/CMakeDetermineCUDACompiler.cmake
[1] /tmp/1_vector_addition/CMakeLists.txt
CMake Error at /opt/versions/cmake/3.28.1/share/cmake-3.28/Modules/CMakeDetermineCUDACompiler.cmake:270 (message):
Failed to detect a default CUDA architecture.
Compiler output:
Call Stack (most recent call first):
CMakeLists.txt:2 (project)
Called from: [2] /opt/versions/cmake/3.28.1/share/cmake-3.28/Modules/CMakeDetermineCUDACompiler.cmake
[1] /tmp/1_vector_addition/CMakeLists.txt
-- Configuring incomplete, errors occurred!
I get the same output if I replace the native
architecture choice with a concrete value, e.g. 61
, corresponding to that of a GPU on my system.
Artifacts:
- Project source file and CMake list file: bug_25637.tar.gz
- Trace file:
trace.log.gz
- Build dir: build_dir.tar.gz
System info:
- Devuan GNU/Linux Excalibur (like Debian Trixie but without systemd)
- CMake 3.28.1 binary distribution
- X86_64 machine
- CUDA 12.2 installed under /usr/local/cuda
Edited by Eyal Rozenberg