CUDA: Device Linking doesn't properly drop frameworks
When building a CUDA target that has device linking any frameworks that are listed will be passed to the device linker. This causes a malformed device link line:
cmake_minimum_required(VERSION 3.13 FATAL_ERROR)
project(framework_cuda_linking LANGUAGES CXX CUDA)
find_package(OpenGL REQUIRED)
add_executable(example test.cu)
target_compile_features(example PUBLIC cxx_std_11)
set_target_properties( example
PROPERTIES CUDA_SEPARABLE_COMPILATION ON
)
message(STATUS "OPENGL_LIBRARIES: ${OPENGL_LIBRARIES}")
target_link_libraries(example ${OPENGL_LIBRARIES})
Causes the following device link line to be generated:
nvcc -Xcompiler=-fPIC -shared -dlink CMakeFiles/.../test.cu.o -o CMakeFiles/.../cmake_device_link.o OpenGL
If you use the OpenGL::GL
target the following issue doesn't occur.