CUDA with BASIS
issamsaid opened this issue · 1 comments
CMake is now supporting CUDA as a native language. However it is not possible to use basis_add_libraray(TARGET files LANGUAGE CUDA)
. The error message is :
CMake Error at CMake-Basis/3.3.1/share/modules/TargetTools.cmake:519 (target_link_libraries):
Target "cuda" of type UTILITY may not be linked into another target.
One may link only to STATIC or SHARED libraries, or to executables with the
ENABLE_EXPORTS property set.
Are they any plans to support CUDA?
Thanks for reporting this issue. I'll collect some notes here as to which functions may need to be extended in order to support CUDA with CMake 3.8+ (i.e., without need for FindCUDA
).
-
basis_get_source_language
: Recognize.cu
filename extension
BASIS/src/cmake/modules/CommonTools.cmake
Line 2760 in b21423c
-
basis_add_library_target
: SetsLANGUAGE
target property toCXX
(CMake does not define this target property, it may only be used by BASIS; see file property)
BASIS/src/cmake/modules/TargetTools.cmake
Line 2118 in b21423c
-
Enable
CUDA
language support of CMake 3.8+ inBasisProject.cmake
file usingbasis_project
(no fix needed, user must specifyCUDA
language when used):
BASIS/src/cmake/modules/ProjectTools.cmake
Line 585 in b21423c
-
Pass
basis_project(LANGUAGES CUDA)
on to CMake'sproject
command (also allowNONE
?)
(this is the most important change):
BASIS/src/cmake/modules/ProjectTools.cmake
Line 1869 in b21423c
-
Set property
CUDA_SEPARABLE_COMPILATION
appropriately.
(though default value can be set by user by settingCMAKE_CUDA_SEPARABLE_COMPILATION
). -
On macOS, set property
BUILD_RPATH
to includeCMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES
.
Note that the LANGUAGE
option of basis_add_library
is mainly used to determine which specialized function to use for defining the build target. When the option argument is CXX
and it's not a MEX-file target, CMake's add_library
function is used. Otherwise BASIS uses some custom basis_*
functions which define custom build commands and targets.
Hence, I would try
basis_add_library(TARGET files LANGUAGE CXX)
until LANGUAGE
argument CUDA
is supported by basis_add_library
and basis_add_executable
.
See also: https://devblogs.nvidia.com/building-cuda-applications-cmake/