-
Notifications
You must be signed in to change notification settings - Fork 636
/
Copy pathCMakeLists.txt
46 lines (33 loc) · 1.29 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
project(cmake_and_cuda LANGUAGES CXX CUDA)
include(CTest)
add_library(particles STATIC
randomize.cpp
randomize.h
particle.cu
particle.h
v3.cu
v3.h
)
# Request that particles be built with -std=c++11
# As this is a public compile feature anything that links to particles
# will also build with -std=c++11
target_compile_features(particles PUBLIC cxx_std_11)
# We need to explicitly state that we need all CUDA files in the particle
# library to be built with -dc as the member functions could be called by
# other libraries and executables
set_target_properties( particles
PROPERTIES CUDA_SEPARABLE_COMPILATION ON
)
if(BUILD_TESTING)
add_executable(particle_test test.cu)
set_target_properties(particle_test PROPERTIES CUDA_SEPARABLE_COMPILATION ON)
target_link_libraries(particle_test PRIVATE particles)
add_test(NAME particles_10k COMMAND particle_test 10000 )
add_test(NAME particles_256k COMMAND particle_test 256000 )
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.
set_property(TARGET particle_test PROPERTY BUILD_RPATH ${CMAKE_CUDA_IMPLICIT_LINK_DIRECTORIES})
endif()
endif()