Skip to content

Commit

Permalink
Fixes #583: All wrapper library targets now depend on librt (on Linux…
Browse files Browse the repository at this point in the history
…), libm, a threads library (pthreads on Linux) and the dynamic linking library (libdl on Linux)
  • Loading branch information
Eyal Rozenberg authored and Eyal Rozenberg committed Feb 8, 2024
1 parent 440639c commit 234676a
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ foreach(wrapper_lib ${targets})
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
)
target_link_libraries(${caw_lib} INTERFACE CUDA::cudart CUDA::cuda_driver)

# These next three dependencies should be carried by the CUDA libraries themselves...
# but they aren't - this is CMake bug 25665
target_link_libraries(${caw_lib} INTERFACE Threads::Threads ${CMAKE_DL_LIBS} m)
if(UNIX AND NOT APPLE)
target_link_libraries(${caw_lib} INTERFACE rt)
endif()

# Targets using these libraries should be compiled with C++11 _at least_,
# but it doesn't seem there's a way to express that at the CMake level

Expand All @@ -70,10 +78,9 @@ if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 11.1)
set(ptx_compiler_target nvptxcompiler_static)
endif()
target_link_libraries(caw_rtc INTERFACE CUDA::${ptx_compiler_target})
target_link_libraries(caw_rtc INTERFACE Threads::Threads) # Because the NVIDIA PTX compiler itself uses threads
endif()

target_link_libraries(caw_nvtx INTERFACE cuda-api-wrappers::runtime-and-driver ${CMAKE_DL_LIBS}) # libnvToolsExt uses dlclose
target_link_libraries(caw_nvtx INTERFACE cuda-api-wrappers::runtime-and-driver)

if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 10.0)
target_link_libraries(caw_nvtx INTERFACE CUDA::nvtx3)
Expand Down

0 comments on commit 234676a

Please sign in to comment.