Files
CMake/Tests/CudaOnly/SeparateCompilationTargetObjects/CMakeLists.txt
T
Robert Maynard cd984261e1 CUDA: Device linking now uses TARGET_OBJECTS content
Due to an oversight in cmLinkLineDeviceComputer object
files did not get propagate to the device linking phase
when given via the `$<TARGET_OBJECTS>` generator expression.
2023-09-25 08:50:38 -04:00

19 lines
782 B
CMake

cmake_minimum_required(VERSION 3.25.5)
project(SeparateCompilationObjects LANGUAGES CUDA)
add_library(foo OBJECT foo.cu)
set_target_properties(foo PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
add_library(bar OBJECT bar.cu)
set_target_properties(bar PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
add_executable(CudaOnlySeparateCompilationTargetObjects main.cu)
set_target_properties(CudaOnlySeparateCompilationTargetObjects PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
target_link_libraries(CudaOnlySeparateCompilationTargetObjects PRIVATE $<TARGET_OBJECTS:foo> bar)
if(APPLE)
# Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
set_property(TARGET CudaOnlySeparateCompilationTargetObjects PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
endif()