Skip to content

Commit

Permalink
Regards #558: Some more tweaks involving the NVIDIA PTX compiler library
Browse files Browse the repository at this point in the history
* Not trying to create the `nvptxcompiler` and `nvptxcompiler_static targets if they already exist
* Some code duplication avoidance
  • Loading branch information
eyalroz committed Dec 22, 2023
1 parent b9b2eff commit e77e78d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,11 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "lib/")
find_package(CUDAToolkit 9.0 REQUIRED)
find_package(Threads REQUIRED)
if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 11.1)
_CUDAToolkit_find_and_add_import_lib(nvptxcompiler)
_CUDAToolkit_find_and_add_import_lib(nvptxcompiler_static)
foreach(tgt in nvptxcompiler nvptxcompiler_static)
if (NOT TARGET ${tgt})
_CUDAToolkit_find_and_add_import_lib(${tgt})
endif()
endforeach()
endif()
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)

Expand Down Expand Up @@ -60,10 +63,11 @@ endforeach()
target_link_libraries(caw_rtc INTERFACE cuda-api-wrappers::runtime-and-driver CUDA::nvrtc)
if(CUDAToolkit_VERSION VERSION_GREATER_EQUAL 11.1)
if (TARGET CUDA::nvptxcompiler)
target_link_libraries(caw_rtc INTERFACE CUDA::nvptxcompiler)
set(ptx_compiler_target nvptxcompiler)
else()
target_link_libraries(caw_rtc INTERFACE CUDA::nvptxcompiler_static)
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()

Expand Down

0 comments on commit e77e78d

Please sign in to comment.