-
Notifications
You must be signed in to change notification settings - Fork 36
/
CMakeLists.txt
268 lines (225 loc) · 7.79 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
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
# For Debian currently with
#
# cd build
# cmake -DCMAKE_BUILD_TYPE=RelWithDebInfo -DOPENMP=1 ..
# cmake --build .
# ctest .
# make install
# See below option statements and the README for build information
cmake_minimum_required(VERSION 3.16)
project(wfa2lib)
set(CMAKE_CXX_STANDARD 17)
include(FeatureSummary)
include(GNUInstallDirs)
find_package(PkgConfig REQUIRED)
feature_summary(
FATAL_ON_MISSING_REQUIRED_PACKAGES
WHAT REQUIRED_PACKAGES_NOT_FOUND)
# ---- Options
option(OPENMP "Enable OpenMP" OFF) # enables WFA_PARALLEL
option(PROFILING "Enable profiling" OFF)
option(ASAN "Use address sanitiser" OFF)
option(EXTRA_FLAGS "Add optimization flags for C/C++ compiler" OFF)
# include(CheckIPOSupported) # adds lto
# check_ipo_supported(RESULT ipo_supported OUTPUT output)
# ---- Dependencies
if(OPENMP)
include(FindOpenMP)
set(OPTIMIZE_FLAGS "-DWFA_PARALLEL")
endif(OPENMP)
if(EXTRA_FLAGS)
set(OPTIMIZE_FLAGS "${OPTIMIZE_FLAGS} ${EXTRA_FLAGS}")
endif(EXTRA_FLAGS)
find_package(Threads)
set_package_properties(Threads PROPERTIES TYPE REQUIRED)
# ---- Build switches
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ${ipo_supported})
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: Release|Debug|RelWithDebInfo (for distros)." FORCE)
endif()
if (${CMAKE_BUILD_TYPE} MATCHES Release)
set(OPTIMIZE_FLAGS "${OPTIMIZE_FLAGS} -march=native -D_FILE_OFFSET_BITS=64")
endif()
if ((${CMAKE_BUILD_TYPE} MATCHES Release) OR (${CMAKE_BUILD_TYPE} MATCHES RelWithDebInfo))
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPTIMIZE_FLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPTIMIZE_FLAGS}")
endif ()
if (${CMAKE_BUILD_TYPE} MATCHES "Debug")
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OPTIMIZE_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OPTIMIZE_FLAGS}")
add_definitions(-Wfatal-errors)
endif ()
if (ASAN)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer -fno-common")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer -fno-common")
endif(ASAN)
if(PROFILING)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g")
endif(PROFILING)
if(GPROF)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pg")
endif(GPROF)
# ---- Include files
file(GLOB INCLUDES
wavefront/*.h*
)
file(GLOB UTILS_INCLUDES
utils/*.h*
)
file(GLOB ALIGNMENT_INCLUDES
alignment/*.h*
)
file(GLOB SYSTEM_INCLUDES
system/*.h*
)
set(wfa2lib_SOURCE
wavefront/wavefront_align.c
wavefront/wavefront_aligner.c
wavefront/wavefront_attributes.c
wavefront/wavefront_backtrace_buffer.c
wavefront/wavefront_backtrace.c
wavefront/wavefront_backtrace_offload.c
wavefront/wavefront_bialign.c
wavefront/wavefront_bialigner.c
wavefront/wavefront.c
wavefront/wavefront_components.c
wavefront/wavefront_compute_affine2p.c
wavefront/wavefront_compute_affine.c
wavefront/wavefront_compute.c
wavefront/wavefront_compute_edit.c
wavefront/wavefront_compute_linear.c
wavefront/wavefront_debug.c
wavefront/wavefront_display.c
wavefront/wavefront_extend.c
wavefront/wavefront_heuristic.c
wavefront/wavefront_pcigar.c
wavefront/wavefront_penalties.c
wavefront/wavefront_plot.c
wavefront/wavefront_sequences.c
wavefront/wavefront_slab.c
wavefront/wavefront_unialign.c
wavefront/wavefront_termination.c
wavefront/wavefront_extend_kernels_avx.c
wavefront/wavefront_extend_kernels.c
system/mm_stack.c
system/mm_allocator.c
system/profiler_counter.c
system/profiler_timer.c
utils/bitmap.c
utils/dna_text.c
utils/sequence_buffer.c
utils/vector.c
utils/commons.c
utils/heatmap.c
alignment/affine2p_penalties.c
alignment/affine_penalties.c
alignment/cigar.c
alignment/score_matrix.c
)
add_library(wfa2_static
${wfa2lib_SOURCE}
)
add_library(wfa2 SHARED ${wfa2lib_SOURCE})
set_target_properties(wfa2_static PROPERTIES OUTPUT_NAME wfa2)
set_target_properties(wfa2 PROPERTIES SOVERSION 0)
target_include_directories(wfa2 PUBLIC . wavefront utils)
target_include_directories(wfa2_static PUBLIC . wavefront utils)
add_library(wfa2::wfa2 ALIAS wfa2)
add_library(wfa2::wfa2_static ALIAS wfa2_static)
if(OPENMP)
target_link_libraries(wfa2_static PRIVATE OpenMP::OpenMP_C)
target_link_libraries(wfa2 PRIVATE OpenMP::OpenMP_C)
endif(OPENMP)
# ---- C++ binding library
set(wfa2cpp_SOURCE
bindings/cpp/WFAligner.cpp
)
file(GLOB CPP_INCLUDES
bindings/cpp/*.h*
)
add_library(wfa2cpp_static STATIC ${wfa2cpp_SOURCE})
add_library(wfa2cpp SHARED ${wfa2cpp_SOURCE})
set_target_properties(wfa2cpp PROPERTIES SOVERSION 0)
set_target_properties(wfa2cpp_static PROPERTIES OUTPUT_NAME wfa2cpp)
target_link_libraries(wfa2cpp PUBLIC wfa2)
target_link_libraries(wfa2cpp_static PUBLIC wfa2_static)
add_library(wfa2::wfa2cpp ALIAS wfa2cpp)
add_library(wfa2::wfa2cpp_static ALIAS wfa2cpp_static)
if(OPENMP)
target_link_libraries(wfa2cpp_static PRIVATE OpenMP::OpenMP_CXX)
target_link_libraries(wfa2cpp PRIVATE OpenMP::OpenMP_CXX)
endif(OPENMP)
# ---- Get version
file (STRINGS "VERSION.txt" BUILD_NUMBER)
add_definitions(-DWFA2LIB_VERSION="${BUILD_NUMBER}")
add_definitions(-DVERSION="${BUILD_NUMBER}")
set(wfa2lib_LIBS
)
# add_dependencies(wfa2lib ${wfa2lib_DEPS})
# ---- Build all
# add_subdirectory(tools/align_benchmark)
add_executable(align_benchmark
tools/align_benchmark/align_benchmark_params.c
tools/align_benchmark/align_benchmark.c
tools/align_benchmark/benchmark/benchmark_check.c
tools/align_benchmark/benchmark/benchmark_edit.c
tools/align_benchmark/benchmark/benchmark_gap_affine2p.c
tools/align_benchmark/benchmark/benchmark_gap_affine.c
tools/align_benchmark/benchmark/benchmark_gap_linear.c
tools/align_benchmark/benchmark/benchmark_indel.c
tools/align_benchmark/benchmark/benchmark_utils.c
system/mm_allocator.c
system/mm_stack.c
system/profiler_counter.c
system/profiler_timer.c
utils/bitmap.c
utils/commons.c
utils/dna_text.c
utils/heatmap.c
utils/sequence_buffer.c
utils/vector.c
alignment/affine2p_penalties.c
alignment/affine_penalties.c
alignment/cigar.c
alignment/score_matrix.c
tools/align_benchmark/gap_affine/affine_matrix.c
tools/align_benchmark/gap_affine/swg.c
tools/align_benchmark/gap_linear/nw.c
tools/align_benchmark/gap_affine2p/affine2p_dp.c
tools/align_benchmark/gap_affine2p/affine2p_matrix.c
tools/align_benchmark/edit/edit_bpm.c
tools/align_benchmark/edit/edit_dp.c
tools/align_benchmark/indel/indel_dp.c
)
target_include_directories(align_benchmark PUBLIC . wavefront system utils tools/align_benchmark)
add_dependencies(align_benchmark wfa2)
target_link_libraries(align_benchmark m)
target_link_libraries(align_benchmark wfa2)
if(OPENMP)
target_link_libraries(align_benchmark OpenMP::OpenMP_C)
endif(OPENMP)
# ---- Test
enable_testing()
function(add_wfa_test)
add_test(
NAME wfa2lib
COMMAND ./tests/wfa.utest.sh ${CMAKE_CURRENT_BINARY_DIR}
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
endfunction()
add_wfa_test()
# ---- Install
# Do not install anything when used with FetchContent
if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
install(TARGETS wfa2_static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} )
install(TARGETS wfa2 ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} )
install(FILES ${INCLUDES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/wfa2lib/wavefront)
install(FILES ${UTILS_INCLUDES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/wfa2lib/utils)
install(FILES ${ALIGNMENT_INCLUDES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/wfa2lib/alignment)
install(FILES ${SYSTEM_INCLUDES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/wfa2lib/system)
install(TARGETS wfa2cpp ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(TARGETS wfa2cpp_static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
install(FILES ${CPP_INCLUDES} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/wfa2lib/bindings/cpp)
endif()