forked from ComputationalRadiationPhysics/cracen
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
192 lines (152 loc) · 7.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
project(DSP)
cmake_minimum_required(VERSION 3.0.1)
# helper for libs and packages
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR})
set(CMAKE_PREFIX_PATH "/usr/lib/x86_64-linux-gnu/"
"$ENV{CUDA_ROOT}" "$ENV{BOOST_ROOT}")
###############################################################################
# Compiler Flags
###############################################################################
string(FIND ${CMAKE_CXX_COMPILER} "clang++" CXX_COMPILER_IS_CLANG++)
string(FIND ${CMAKE_CXX_COMPILER} "g++" CXX_COMPILER_IS_G++)
if(${CXX_COMPILER_IS_G++})
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-unused-parameter")
# set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
endif(${CXX_COMPILER_IS_G++})
if(${CXX_COMPILER_IS_CLANG++})
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
endif(${CXX_COMPILER_IS_CLANG++})
###############################################################################
# CUDA
###############################################################################
find_package(CUDA REQUIRED)
set(CUDA_NVCC_FLAGS "-use_fast_math;-arch=compute_35;-code=sm_35;-Xptxas=-v;-O3;-std=c++11;-DDEBUG_ENABLED")
set(CUDA_ARCH sm_35 CACHE STRING "Set GPU architecture")
# Separate C++ from CUDA file compilation (So we can use our own compiler)
set(CUDA_SEPARABLE_COMPILATION ON)
# Do not propagate CXX flags to the nvcc host compiler (especially -std=c++11)
set(CUDA_PROPAGATE_HOST_FLAGS OFF)
###############################################################################
# PThreads
###############################################################################
find_package(Threads)
set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT})
set(OnlineDSP_LIBS ${OnlineDSP_LIBS} ${CMAKE_THREAD_LIBS_INIT})
###############################################################################
# Boost
###############################################################################
find_package(Boost 1.55.0 REQUIRED)
include_directories(SYSTEM ${Boost_INCLUDE_DIRS})
set(LIBS ${LIBS} ${Boost_LIBRARIES})
set(OnlineDSP_LIBS ${OnlineDSP_LIBS} ${Boost_LIBRARIES})
#nvcc + boost 1.55 work around
if(Boost_VERSION EQUAL 105500)
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} \"-DBOOST_NOINLINE=__attribute__((noinline))\" ")
endif(Boost_VERSION EQUAL 105500)
###############################################################################
# Acquiris Library for the ScopeReader
###############################################################################
find_package(Acqiris REQUIRED)
include_directories(${Acqiris_INCLUDE_DIRS})
add_definitions(${Acqiris_CFLAGS})
add_definitions(${Acqiris_LDFLAGS})
add_definitions(${Acqiris_CFLAGS_OTHER})
set(LIBS ${LIBS} ${Acqiris_LIBRARIES})
################################################################################
# GRAYBAT
################################################################################
set(graybat_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include/graybat)
find_package(graybat REQUIRED CONFIG)
#include_directories(SYSTEM ${graybat_INCLUDE_DIRS})
include_directories(${graybat_INCLUDE_DIRS})
set(LIBS ${LIBS} ${graybat_LIBRARIES})
###############################################################################
# Gtk3mm for the viewer
###############################################################################
find_package(PkgConfig REQUIRED)
PKG_CHECK_MODULES(GTK3 REQUIRED gtk+-3.0)
include_directories(${GTK3_INCLUDE_DIRS})
link_directories(${GTK3_LIBRARY_DIRS})
add_definitions(${GTK3_CFLAGS})
add_definitions(${GTK3_LDFLAGS})
add_definitions(${GTK3_CFLAGS_OTHER})
set(LIBS ${LIBS} ${GTK3_LIBRARIES})
PKG_CHECK_MODULES(GTK3MM gtkmm-3.0)
include_directories(${GTK3MM_INCLUDE_DIRS})
link_directories(${GTK3MM_LIBRARY_DIRS})
add_definitions(${GTK3MM_CFLAGS})
add_definitions(${GTK3MM_LDFLAGS})
add_definitions(${GTK3MM_CFLAGS_OTHER})
set(LIBS ${LIBS} ${GTK3MM_LIBRARIES})
###############################################################################
# Qt5 for the viewer
###############################################################################
## Find includes in corresponding build directories
#set(CMAKE_INCLUDE_CURRENT_DIR ON)
## Instruct CMake to run moc automatically when needed.
#set(CMAKE_AUTOMOC ON)
#set(CMAKE_BUILD_TYPE Debug)
#
#find_package(Qt5Widgets)
#include_directories(${Qt5Widgets_INCLUDE_DIRS})
#find_package(Qt5Gui)
#include_directories(${Qt5Gui_INCLUDE_DIRS})
#set(OnlineDSP_LIBS ${OnlineDSP_LIBS} Qt5::Gui Qt5::Widgets)
###############################################################################
# Include directories
###############################################################################
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/Config)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/Device)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/Input)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/Output)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/Utility)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include/)
cuda_include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
cuda_include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src/Device)
###############################################################################
# Executables
###############################################################################
file(GLOB_RECURSE SRCFILES "${CMAKE_CURRENT_SOURCE_DIR}/src/Config/*"
"${CMAKE_CURRENT_SOURCE_DIR}/src/Input/*"
"${CMAKE_CURRENT_SOURCE_DIR}/src/Output/*"
"${CMAKE_CURRENT_SOURCE_DIR}/src/Utility/*")
file(GLOB_RECURSE CUDASRCFILES "${CMAKE_CURRENT_SOURCE_DIR}/src/Device/*")
file(GLOB_RECURSE OnlineDSP_SRCFILES "${CMAKE_CURRENT_SOURCE_DIR}/src/OnlineDSP/*")
#FOREACH(item ${SRCFILES})
# IF(${item} MATCHES DSP.cu)
# LIST(REMOVE_ITEM ${SRCFILES) ${item})
# ENDIF(${item} MATCHES DSP.cu)
# IF(${item} MATCHES Viewer.cpp)
# LIST(REMOVE_ITEM ${SRCFILES} ${item})
# ENDIF(${item} MATCHES Viewer.cpp)
#ENDFOREACH(item)
LIST(REMOVE_DUPLICATES SRCFILES)
#LIST(REMOVE_ITEM SRCFILES ${CMAKE_CURRENT_SOURCE_DIR}/src/viewer/Viewer.cpp)
#LIST(REMOVE_ITEM SRCFILES ${CMAKE_CURRENT_SOURCE_DIR}/src/Dsp.cu)
#LIST(REMOVE_ITEM SRCFILES ${CMAKE_CURRENT_SOURCE_DIR}/src/OnlineDSP/*)
cuda_add_executable(DSP "${SRCFILES};${CUDASRCFILES};${CMAKE_CURRENT_SOURCE_DIR}/src/Dsp.cpp")
target_link_libraries(DSP ${LIBS})
cuda_add_executable(Fitter "${SRCFILES};${CUDASRCFILES};${CMAKE_CURRENT_SOURCE_DIR}/src/Fitter.cpp")
target_link_libraries(Fitter ${LIBS})
add_executable(ScopeReader "${SRCFILES};${CMAKE_CURRENT_SOURCE_DIR}/src/ScopeReader.cpp")
target_link_libraries(ScopeReader ${LIBS})
add_executable(FileReader "${SRCFILES};${CMAKE_CURRENT_SOURCE_DIR}/src/FileReader.cpp")
target_link_libraries(FileReader ${LIBS})
add_executable(FileWriter "${SRCFILES};${CMAKE_CURRENT_SOURCE_DIR}/src/FileWriter.cpp")
target_link_libraries(FileWriter ${LIBS})
add_executable(Viewer "${SRCFILES};${CMAKE_CURRENT_SOURCE_DIR}/src/viewer/Viewer.cpp")
target_link_libraries(Viewer ${LIBS})
#add_executable(OnlineDSP "${OnlineDSP_SRCFILES}")
#target_link_libraries(OnlineDSP ${OnlineDSP_LIBS})
ADD_CUSTOM_TARGET (
run
./${CMAKE_CURRENT_BUILD_DIR}/DSP
DEPENDS DSP
COMMENT "Executing programm." VERBATIM
)