且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何使用CMake将C ++编译为CUDA

更新时间:2021-07-22 21:26:28

默认情况下,CMake根据文件扩展名为源文件选择编译器。但是您可以通过设置 LANGUAGE 来强制CMake使用所需的编译器。 a>文件属性:

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)

(这只是使用正常的编译器选项为文件调用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.)