Cmake Cuda Compiling Error (Cuda Compiler Idenfitication Is Unknown)

Hello,
I’m getting an error while compiling the cmake project I created. I think this error is caused by the internal structure of cmake.

Cmake Version : 3.27.8 (Clion Embedded Compiler)
Cuda Version: 12.3
Nvidia Driver: 545.23.08
OS: Ubuntu 22.04

Can you help me. Thanks.

cmake_minimum_required(VERSION 3.27.8)
project(XProject C CXX)
set(CMAKE_CXX_STANDARD 23)

# Find CUDA package
set(CMAKE_CUDA_ARCHITECTURES 80 86) # For: Ampere and Ada Lovelace
set(CMAKE_CUDA_COMPILER "/usr/local/cuda/bin")
enable_language(CUDA)
cmake/linux/x64/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_MAKE_PROGRAM=linux/x64/ninja -G Ninja
-- The CUDA compiler identification is unknown
-- Check for working CUDA compiler: /usr/local/cuda/bin
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
_CMAKE_CUDA_WHOLE_FLAG
CMake Error at /snap/clion/261/bin/cmake/linux/x64/share/cmake-3.27/Modules/CMakeTestCUDACompiler.cmake:89 (try_compile):
  Failed to generate test project build system.
Call Stack (most recent call first):
  CMakeLists.txt:30 (enable_language)

This looks like the directory the compiler is in, not the actual compiler.

Hello again,

Yes, as you said, it worked when I edited it as follows.

set(CMAKE_CUDA_COMPILER "/usr/local/cuda/bin/nvcc")

Thanks.