How to compile C++ as CUDA using CMake

后端 未结 1 1684
栀梦
栀梦 2020-12-06 22:34

I\'m writing some code that can be compiled as C++ or as CUDA. In the latter case, it makes use of CUDA kernels, in the former it just runs conventional code.

Havin

相关标签:
1条回答
  • By default, CMake chooses compiler for a source file according to the file's extension. But you may force CMake to use the compiler you want by setting LANGUAGE property for a file:

    set_source_files_properties(test.cpp PROPERTIES LANGUAGE CUDA)
    

    (This just calls CUDA compiler for a file using normal compiler options. You still need to pass additional options for that compiler, so it could work with the unusual file's extension.)

    0 讨论(0)
提交回复
热议问题