Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- cmake_minimum_required(VERSION 3.7)
- project( DelayDeviceLinking CUDA)
- string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_30,code=compute_30")
- set(CMAKE_CXX_STANDARD 11)
- set(CMAKE_CUDA_STANDARD 11)
- add_library(StaticA STATIC function1.cu)
- add_library(StaticB STATIC function2.cu)
- add_library(StaticC STATIC function3.cu)
- target_link_libraries(StaticB PUBLIC StaticA)
- target_link_libraries(StaticC PUBLIC StaticA)
- set_target_properties(StaticA StaticB StaticC
- PROPERTIES
- CUDA_SEPARABLE_COMPILATION ON
- POSITION_INDEPENDENT_CODE ON)
- add_executable( DelayDeviceLinkingA main.cu)
- target_link_libraries(DelayDeviceLinkingA PRIVATE StaticB)
- add_executable( DelayDeviceLinkingB main2.cu)
- target_link_libraries(DelayDeviceLinkingB PRIVATE StaticB StaticC)
- if(APPLE)
- # We need to add the default path to the driver (libcuda.dylib) as an rpath, so that
- # the static cuda runtime can find it at runtime.
- target_link_libraries(DelayDeviceLinkingA PRIVATE -Wl,-rpath,/usr/local/cuda/lib)
- target_link_libraries(DelayDeviceLinkingB PRIVATE -Wl,-rpath,/usr/local/cuda/lib)
- endif()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement