-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
106 lines (78 loc) · 2.58 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
cmake_minimum_required(VERSION 3.12...3.28)
# set project name
project(opensaft
VERSION 1.0
DESCRIPTION "Open source implementation of 3D SAFT"
LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif()
option(OPENSAFT_CUDA_SUPPORT "Enable CUDA support" OFF)
option(OPENSAFT_TESTING "Build unit tests" ON)
option(OPENSAFT_GUI "build graphical user interface alongside" OFF)
# prepare for cuda compilation
if (OPENSAFT_CUDA_SUPPORT)
enable_language(CUDA)
find_package(CUDA REQUIRED QUIET)
include(FindCUDA)
INCLUDE_DIRECTORIES(/opt/cuda/include include)
set(CUDA_ATTACH_VS_BUILD_RULE_TO_CUDA_FILE OFF)
endif()
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON )
set(CMAKE_CUDA_FLAGS "${CUDA_CUDA_FLAGS} -rdc=true -Xptxas -v -O2")
set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; -x cu -rdc=true -ftz=false -prec-div=true -prec-sqrt=true -g)
# add path cmake/modules to search directory
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")
# find dependencies (most of them are handled through FetchContent)
find_library(H5CPP_LIB hdf5_cpp)
find_library(H5_LIB hdf5) # todo this sounds fishy that
# main library holding the backbone of the application
add_library(opensaft STATIC "")
add_subdirectory(src/)
target_link_libraries(opensaft PUBLIC
)
target_include_directories(opensaft PUBLIC
${CMAKE_SOURCE_DIR}/src
)
if (OPENSAFT_GUI)
add_library(opensaft-gui)
find_package(ImGUI REQUIRED)
find_package(GLFW REQUIRED)
find_package(OpenGL REQUIRED)
find_package(ImPlot REQUIRED)
find_package(ImGUIFileDialog REQUIRED)
find_package(Backward REQUIRED)
target_link_libraries(opensaft-gui PUBLIC
${ImGUI_LIBRARIES}
${implot_LIBRARIES}
${GLFW_LIBRARIES}
${cvolume_LIBRARIES}
${ImGUIFileDialog_LIBRARIES}
${backward_LIBRARIES}
)
target_include_directories(opensaft PUBLIC
${CMAKE_SOURCE_DIR}/src
${ImGUI_INCLUDE_DIR}
${ImPlot_INCLUDE_DIR}
${ImGUIFileDialog_INCLUDE_DIR}
${OPENGL_INCLUDE_DIRS}
${GLFW3_INCLUDE_DIR}
${cvolume_INCLUDE_DIR}
${backward_INCLUDE_DIR}
)
# add an executable for the main graphical user interface
add_executable(OpensaftGui src/main.cpp)
if (OPENSAFT_CUDA_SUPPORT)
set_property(TARGET OpensaftGui PROPERTY CUDA_SEPARABLE_COMPILATION ON)
set_property(TARGET OpensaftGui PROPERTY CUDA_ARCHITECTURES 50 75 86)
endif()
target_link_libraries(OpensaftGui PUBLIC opensaft-gui)
install(TARGETS OpensaftGui DESTINATION bin)
endif (OPENSAFT_GUI)
find_library(TERM_LIB curses)
if (OPENSAFT_TESTING)
add_subdirectory(tests)
endif()