CMake不';你不能传递CUDA参数吗? 我试图用C++和CUDA源文件编译一个库。我将GNU make与CMake一起使用。我选择的编译器是clang,因为CUDA只支持gcc版本5,Debian 9将gcc 6作为其最早的版本,我必须使用Debian 9或10存储库提供的软件

CMake不';你不能传递CUDA参数吗? 我试图用C++和CUDA源文件编译一个库。我将GNU make与CMake一起使用。我选择的编译器是clang,因为CUDA只支持gcc版本5,Debian 9将gcc 6作为其最早的版本,我必须使用Debian 9或10存储库提供的软件,cmake,cuda,clang,Cmake,Cuda,Clang,CMake版本是3.9.0 clang版本是3.8.1 CC和C++在/Ur/bin中正确链接到CLAN和CLAN+++ẃ它还链接到正确的文件 不幸的是,CMake对CUDA的初始检查失败了,尽管据我所知,一切似乎都设置正确。看起来参数没有正确地传递给CUDA编译器 这是我的项目主CMake文件的一部分: cmake_minimum_required (VERSION 3.9.0 FATAL_ERROR) project (dev) find_package(CUDA REQUIRED)

CMake版本是3.9.0 clang版本是3.8.1

CC和C++在/Ur/bin中正确链接到CLAN和CLAN+++ẃ它还链接到正确的文件

不幸的是,CMake对CUDA的初始检查失败了,尽管据我所知,一切似乎都设置正确。看起来参数没有正确地传递给CUDA编译器

这是我的项目主CMake文件的一部分:

cmake_minimum_required (VERSION 3.9.0 FATAL_ERROR)

project (dev)

find_package(CUDA REQUIRED)

set(CUDA_HOST_COMPILATION_CPP ON)
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -Wno-deprecated-gpu-targets -ccbin clang-3.8")
库的CMake文件如下所示:

cmake_minimum_required(VERSION 3.9.0 FATAL_ERROR)

project (libname LANGUAGES CXX CUDA)

file(GLOB SOURCES "*.cu" "*.cpp")

add_library(libname ${SOURCES})

set_target_properties(libname PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
set_target_properties(libname PROPERTIES POSITION_INDEPENDENT_CODE ON)
这是CMake的输出:

-- The C compiler identification is Clang 3.8.1
-- The CXX compiler identification is Clang 3.8.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE  
-- Found CUDA: /usr (found version "8.0") 
-- The CUDA compiler identification is unknown
-- Check for working CUDA compiler: /usr/bin/nvcc
-- Check for working CUDA compiler: /usr/bin/nvcc -- broken
CMake的CUDA/nvcc测试失败,出现以下错误:

  Change Dir: /home/user/projects/hamonIC-linux-experimental/current_state/working_copy/code/build/CMakeFiles/CMakeTmp



  Run Build Command:"/usr/bin/make" "cmTC_6d1a9/fast"

  /usr/bin/make -f CMakeFiles/cmTC_6d1a9.dir/build.make
  CMakeFiles/cmTC_6d1a9.dir/build

  make[1]: Entering directory
  '/home/user/projects/hamonIC-linux-experimental/current_state/working_copy/code/build/CMakeFiles/CMakeTmp'


  Building CUDA object CMakeFiles/cmTC_6d1a9.dir/main.cu.o

  /usr/bin/nvcc -x cu -c
  /home/user/projects/hamonIC-linux-experimental/current_state/working_copy/code/build/CMakeFiles/CMakeTmp/main.cu
  -o CMakeFiles/cmTC_6d1a9.dir/main.cu.o

  nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are
  deprecated, and may be removed in a future release (Use
  -Wno-deprecated-gpu-targets to suppress warning).

  ERROR: No supported gcc/g++ host compiler found, but clang-3.8 is
  available.

         Use 'nvcc -ccbin clang-3.8' to use that instead.

  CMakeFiles/cmTC_6d1a9.dir/build.make:65: recipe for target
  'CMakeFiles/cmTC_6d1a9.dir/main.cu.o' failed

  make[1]: *** [CMakeFiles/cmTC_6d1a9.dir/main.cu.o] Error 1

  make[1]: Leaving directory
  '/home/user/projects/hamonIC-linux-experimental/current_state/working_copy/code/build/CMakeFiles/CMakeTmp'


  Makefile:126: recipe for target 'cmTC_6d1a9/fast' failed

  make: *** [cmTC_6d1a9/fast] Error 2





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  hic_iplibrary/source/ciccommon/CMakeLists.txt:7 (project)

CMake中的CUDA NVCC标志必须以分号分隔,而不是以空格分隔

CMakeLists.txt中的标志更改为使用:

set(CUDA\u NVCC\u FLAGS“${CUDA\u NVCC\u FLAGS};-Wno不推荐的gpu目标;-ccbin=clang-3.8”)

这应该允许CMake将您的标志传递给NVCC