简体   繁体   中英

How to make CMake use clang for CUDA to support c++17

According to this question , it is possible to use c++17 with cuda by using clang. However, I couldn't find how to setup CMakeLists.txt to accomplish this.

I enable c++17 with

add_compile_options(-std=c++17)

Out of the box with the following

    enable_language(CUDA)

nvcc complains

nvcc fatal   : Value 'c++17' is not defined for option 'std'

Adding the following as suggested here

    set(CUDA_HOST_COMPILER clang++)
    set(CMAKE_CUDA_COMPILER /usr/bin/clang++)

clang to complain

clang: error: language not recognized: 'cu'

Try

set(CMAKE_CXX_STANDARD 17)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM