-
Notifications
You must be signed in to change notification settings - Fork 4
/
CMakeLists.txt
79 lines (43 loc) · 1.97 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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
cmake_minimum_required (VERSION 3.14.3)
project (smlm LANGUAGES CXX)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_LIST_DIR})
find_package(Matlab REQUIRED)
# -------------
# Mex files for CPU code
# -------------
matlab_add_mex(NAME mex_gausstransform_cpu SRC gausstransform/mex_gausstransform_cpu.cpp)
matlab_add_mex(NAME mex_expdist_cpu SRC expdist/mex_expdist_cpu.cpp)
install(TARGETS mex_gausstransform_cpu mex_expdist_cpu
DESTINATION MATLAB/all2all)
# -------------
# Everything below this line is GPU related, using GPU is enabled by default
# To disable compilation of GPU code use cmake -DUSE_GPU=OFF .
# -------------
option (USE_GPU
"Use CUDA-enabled GPU Functions?" ON)
if (USE_GPU)
#enable_language(CUDA)
# -------------
# CUDA
# -------------
find_package(CUDA REQUIRED)
message(STATUS "Found CUDA ${CUDA_VERSION_STRING} at ${CUDA_TOOLKIT_ROOT_DIR}")
set(CMAKE_CUDA_FLAGS "-O3 -m64 -Xcompiler=-fPIC -Xptxas=-v -gencode arch=compute_30,code=sm_30 -gencode arch=compute_35,code=sm_35 -gencode arch=compute_37,code=sm_37 -gencode arch=compute_50,code=sm_50 -gencode arch=compute_52,code=sm_52 -gencode arch=compute_60,code=sm_60")
message(STATUS "CUDA compiler args cmake cuda flags ${CMAKE_CUDA_FLAGS}")
# -------------
# CUB
# -------------
find_package(CUB REQUIRED)
include_directories(${CUB_INCLUDE_DIR})
message(STATUS "Found CUB ${CUB_INCLUDE_DIR}")
cuda_add_library(gausstransform SHARED gausstransform/gausstransform.cu)
cuda_add_library(expdist SHARED expdist/expdist.cu)
# Build GPU-enabled MEX functions
include_directories(${CUDA_INCLUDE_DIRS})
link_directories(${CUDA_LIBRARIES})
matlab_add_mex(NAME mex_gausstransform SRC gausstransform/mex_gausstransform.cpp LINK_TO gausstransform)
matlab_add_mex(NAME mex_expdist SRC expdist/mex_expdist.cpp LINK_TO expdist)
install(TARGETS mex_gausstransform mex_expdist
DESTINATION MATLAB/all2all)
endif (USE_GPU)