summaryrefslogtreecommitdiffstats
path: root/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-10-24 14:46:06 (GMT)
committerBrad King <brad.king@kitware.com>2018-10-24 14:52:46 (GMT)
commitd81c4db489d773e4a1ce6be49eb9c41582e68ae3 (patch)
tree512d4e46d43003c862442e588c26f12460cb2123 /Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt
parent5d481919d499f6de1dd079bf732f32ec3f085101 (diff)
parent2cc050b53b4afb1ed62621360b860e25b7c46015 (diff)
downloadCMake-d81c4db489d773e4a1ce6be49eb9c41582e68ae3.zip
CMake-d81c4db489d773e4a1ce6be49eb9c41582e68ae3.tar.gz
CMake-d81c4db489d773e4a1ce6be49eb9c41582e68ae3.tar.bz2
Merge branch 'cuda-thread-flags' into release-3.13
Merge-request: !2512
Diffstat (limited to 'Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt')
-rw-r--r--Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt45
1 files changed, 45 insertions, 0 deletions
diff --git a/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt b/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt
new file mode 100644
index 0000000..cb47b09
--- /dev/null
+++ b/Tests/Cuda/ProperDeviceLibraries/CMakeLists.txt
@@ -0,0 +1,45 @@
+cmake_minimum_required(VERSION 3.13)
+project(ProperDeviceLibraries CXX CUDA)
+
+string(APPEND CMAKE_CUDA_FLAGS " -gencode arch=compute_35,code=compute_35 -gencode arch=compute_35,code=sm_35")
+set(CMAKE_CUDA_STANDARD 11)
+
+set(THREADS_PREFER_PTHREAD_FLAG ON)
+find_package(Threads)
+
+add_executable(ProperDeviceLibraries main.cu)
+set_target_properties(ProperDeviceLibraries
+ PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
+
+add_library(UseThreadsMixed SHARED use_pthreads.cxx use_pthreads.cu)
+target_link_libraries(UseThreadsMixed Threads::Threads)
+
+add_library(UseThreadsCuda SHARED use_pthreads.cu)
+target_link_libraries(UseThreadsCuda Threads::Threads)
+
+target_link_libraries(ProperDeviceLibraries PRIVATE UseThreadsMixed UseThreadsCuda)
+
+if(THREADS_HAVE_PTHREAD_ARG AND CMAKE_USE_PTHREADS_INIT)
+ add_library(UseExplicitPThreadsFlag SHARED use_pthreads.cu)
+ target_compile_options(UseExplicitPThreadsFlag PUBLIC "-Xcompiler=-pthread")
+ target_link_libraries(UseExplicitPThreadsFlag PUBLIC "-pthread")
+
+ add_library(UseExplicitLThreadsFlag SHARED use_pthreads.cu)
+ target_compile_options(UseExplicitLThreadsFlag PUBLIC "-Xcompiler=-pthread")
+ target_link_libraries(UseExplicitLThreadsFlag PUBLIC "-lpthread")
+
+ add_library(UseExplicitLongThreadsFlag SHARED use_pthreads.cu)
+ target_link_libraries(UseExplicitLongThreadsFlag PUBLIC "--library pthread")
+
+ target_link_libraries(ProperDeviceLibraries PRIVATE UseExplicitPThreadsFlag UseExplicitLThreadsFlag UseExplicitLongThreadsFlag)
+endif()
+
+if(CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 10.0.0)
+ #CUDA 10 removed the cublas_device library
+ target_link_libraries(ProperDeviceLibraries PRIVATE cublas_device)
+endif()
+
+if(APPLE)
+ # Help the static cuda runtime find the driver (libcuda.dyllib) at runtime.
+ set_property(TARGET ProperDeviceLibraries PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
+endif()