I use CMake 3.11 to build the following tiny CUDA-based project:
CMakeLists.txt
:
cmake_minimum_required(VERSION 3.1)
find_package(CUDA 7.0 REQUIRED)
set(CUDA_SEPARABLE_COMPILATION ON)
cuda_add_executable(dummy dummy.cu)
dummy.cu
:
int main() { }
Strangely enough, when building, the following command is used for the dlink phase:
/path/to/cuda/bin/nvcc -m64 -ccbin /opt/gcc-5.4.0/bin/gcc -dlink /home/joeuser/src/dummy/CMakeFiles/dummy.dir//./dummy_generated_dummy.cu.o /path/to/cuda/lib64/libcublas_device.a -o /home/joeuser/src/dummy/CMakeFiles/dummy.dir/./dummy_intermediate_link.o
Why is CMake linking against cublas where it supposedly doesn't need it?
Note: If I remove the SEPARABLE_COMPILATION line, cublas is not added to the dlink command arguments.
Partial answer:
This doesn't seem to happen if we use CMake's native CUDA language support, e.g.
instead of the above - works. I can't make it not have separable compilation though, even if I set: