cmake-basis / BASIS

CMake BASIS makes it easy to create sharable software and libraries that work together. This is accomplished by combining and documenting some of the best practices and utilities available. This project supplies a fully integrated suite of functionality to make the whole process seamless!
https://cmake-basis.github.io
Other
48 stars 10 forks source link

CUDA with BASIS #627

Open issamsaid opened 6 years ago

issamsaid commented 6 years ago

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?

schuhschuh commented 6 years ago

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).

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/