forked from rkms86/SUSAN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
92 lines (80 loc) · 3.33 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
79
80
81
82
83
84
85
86
87
88
89
90
# Define Project
cmake_minimum_required(VERSION 3.3)
project(SUSAN LANGUAGES CXX CUDA)
set(CMAKE_BUILD_TYPE Release)
########################################################################
########################################################################
# Configure EIGEN
set(CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/extern/eigen_lib)
find_package(Eigen3 3.3 REQUIRED NO_MODULE)
########################################################################
########################################################################
# Configure CUDA:
# SM 5.0 and below: DEPRECATED
# v10.2: up to SM 7.5
# v11.0: SM 8.0
# v11.1: SM 8.6
# v11.5: SM 8.7
# v11.8: SM 9.0
# v12.0: up to SM 9.0
find_package(CUDAToolkit)
list(APPEND CUDA_ARCHS 52 53 60 61 62 70 72 75)
if(CUDAToolkit_VERSION_MAJOR LESS 10)
message(FATAL_ERROR "SUSAN requires CUDA toolkit at least version 10.")
elseif(CUDAToolkit_VERSION_MAJOR EQUAL 11)
list(APPEND CUDA_ARCHS 80)
if(CUDAToolkit_VERSION_MINOR GREATER_EQUAL 1)
list(APPEND CUDA_ARCHS 86)
elseif(CUDAToolkit_VERSION_MINOR GREATER_EQUAL 5)
list(APPEND CUDA_ARCHS 87)
elseif(CUDAToolkit_VERSION_MINOR GREATER_EQUAL 8)
list(APPEND CUDA_ARCHS 90)
endif()
elseif(CUDAToolkit_VERSION_MAJOR EQUAL 12)
list(APPEND CUDA_ARCHS 80 86 87 89 90)
else()
message(FATAL_ERROR "SUSAN does not support your CUDA toolkit version.")
endif()
string(APPEND CMAKE_CUDA_FLAGS " --expt-relaxed-constexpr")
string(APPEND CMAKE_CUDA_FLAGS " -Xcudafe --display_error_number")
########################################################################
########################################################################
# Basic Executables
set(target_list estimate_ctf reconstruct rec_subtomos aligner refs_aligner ctf_refiner)
foreach(target IN LISTS target_list)
set(bin susan_${target})
add_executable(${bin} src/${target}.cu)
target_link_libraries(${bin} cufft Eigen3::Eigen)
set_property(TARGET ${bin} PROPERTY CUDA_ARCHITECTURES ${CUDA_ARCHS})
endforeach()
# Conditionally build if MPI is found
find_package(MPI)
if( MPI_FOUND )
set(target_list reconstruct_mpi aligner_mpi ctf_refiner_mpi)
foreach(target IN LISTS target_list)
set(bin susan_${target})
add_executable(${bin} src/${target}.cu)
target_compile_definitions(${bin} PUBLIC OPENMPI)
target_link_libraries(${bin} cufft ${MPI_CXX_LIBRARIES} Eigen3::Eigen)
target_include_directories(${bin} PUBLIC ${MPI_CXX_INCLUDE_DIRS})
set_property(TARGET ${bin} PROPERTY CUDA_ARCHITECTURES ${CUDA_ARCHS})
endforeach()
endif( MPI_FOUND )
# Conditionally build if MATLAB is found
find_package(Matlab)
if( Matlab_FOUND )
include_directories(${CMAKE_SOURCE_DIR}/src)
file(GLOB_RECURSE mex_cpp LIST_DIRECTORIES false "${CMAKE_SOURCE_DIR}/+SUSAN/*.cpp")
foreach(src IN LISTS mex_cpp)
get_filename_component(folder ${src} DIRECTORY)
get_filename_component(target ${src} NAME_WE)
set(binary "${target}.${Matlab_MEX_EXTENSION}")
matlab_add_mex(NAME ${target} SRC ${src} LINK_TO Eigen3::Eigen R2018a)
add_custom_command(TARGET ${target} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "${CMAKE_CURRENT_BINARY_DIR}/${binary}" "${folder}/.")
endforeach()
endif( Matlab_FOUND )
# Add target to install binaries into the Python package
add_custom_target(prepare_python
COMMAND mkdir -p ${CMAKE_SOURCE_DIR}/susan/bin
COMMAND cp -v ${CMAKE_CURRENT_BINARY_DIR}/susan_* ${CMAKE_SOURCE_DIR}/susan/bin/
)