-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
236 lines (196 loc) · 6.15 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
cmake_minimum_required(VERSION 3.10)
project(NanoSpring
VERSION 0.1
LANGUAGES C CXX)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED True)
include(CheckIPOSupported)
include(CheckCXXSourceCompiles)
# Clear All Flags
set(CMAKE_CXX_FLAGS "")
set(CMAKE_CXX_FLAGS_DEBUG "")
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "")
set(CMAKE_CXX_FLAGS_RELEASE "")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release)
endif()
check_ipo_supported(RESULT result)
if(result)
message(STATUS "Support for Interprocedural Optimization detected.")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "CHECKS=${CHECKS} (Use -DCHECKS=True to enable all checks")
message(STATUS "LOG=${LOG} (Use -LOG=True to output log files for analysis")
message(STATUS "Directory: ${CMAKE_CURRENT_SOURCE_DIR}")
find_package(OpenMP)
##############################
# malloc_trim
check_cxx_source_compiles(
"#include <malloc.h>
int main() {
malloc_trim(0);
return 0;
}"
USE_MALLOC_TRIM)
if(USE_MALLOC_TRIM)
message(STATUS "Support for malloc_trim detected.")
else()
message(STATUS "Support for malloc_trim not detected.")
endif()
###############################
# boost
set( Boost_NO_SYSTEM_PATHS ON ) # do not use system boost
add_subdirectory(boost-cmake)
#######################################################
# libbsc
add_library(libbsc
STATIC
libbsc/adler32/adler32.cpp
libbsc/bwt/libsais/libsais.c
libbsc/bwt/bwt.cpp
libbsc/coder/coder.cpp
libbsc/coder/qlfc/qlfc.cpp
libbsc/coder/qlfc/qlfc_model.cpp
libbsc/filters/detectors.cpp
libbsc/filters/preprocessing.cpp
libbsc/libbsc/libbsc.cpp
libbsc/lzp/lzp.cpp
libbsc/platform/platform.cpp
libbsc/st/st.cpp
)
target_include_directories(libbsc
PUBLIC libbsc)
target_compile_options(libbsc
PUBLIC
-g -Wall
# Comment out CFLAGS line below for compatability mode for 32bit file sizes
# (less than 2GB) and systems that have compilers that treat int as 64bit
# natively (ie: modern AIX)
-D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
# Comment out CFLAGS line below to disable optimizations
-O3 -fomit-frame-pointer -fstrict-aliasing -ffast-math
# Comment out CFLAGS line below to disable AVX2 instruction set (performance will suffer)
-mavx2
# Comment out CFLAGS line below to disable OpenMP optimizations
# We disable this here and parallelize at the top level
# -fopenmp -DLIBBSC_OPENMP_SUPPORT
# Comment out CFLAGS line below to enable debug output
-DNDEBUG
# Comment out CFLAGS line below to disable unaligned memory access
-DLIBBSC_ALLOW_UNALIGNED_ACCESS
)
if(OpenMP_CXX_FOUND)
target_link_libraries(libbsc PUBLIC OpenMP::OpenMP_CXX -DLIBBSC_OPENMP_SUPPORT)
endif()
#######################################################
#minimap2
add_custom_target(
MINIMAP2
COMMAND make clean && make
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/minimap2/
)
#######################################################
#fast-lzma2
add_custom_target(
FASTLZMA2
COMMAND make clean && make
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/fast-lzma2/
)
#######################################################
# the NanoSpringLib library
add_library(NanoSpringLib
STATIC
src/AlignerTester.cpp
src/bsc.cpp
src/Compressor.cpp
src/Consensus.cpp
src/Decompressor.cpp
src/Edits.cpp
src/ReadAligner.cpp
src/ReadData.cpp
src/ReadFilter.cpp
src/ConsensusGraph.cpp
src/OmpMutex.cpp
src/DirectoryUtils.cpp
src/dnaToBits.cpp
src/BBHashMap.cpp
src/lzma2.cpp
include/AlignerTester.h
include/bsc_helper.h
include/Compressor.h
include/Consensus.h
include/Decompressor.h
include/Edits.h
include/StringAligner.h
include/ReadAligner.h
include/ReadData.h
include/ReadFilter.h
include/testAligner.h
include/ConsensusGraph.h
include/OmpMutex.h
include/DirectoryUtils.h
include/Types.h
include/dnaToBits.h
include/BBHashMap.h
include/BooPHF.h
include/lzma2_helper.h
)
target_include_directories(NanoSpringLib
PUBLIC include src
PUBLIC libbsc
PUBLIC minimap2 fast-lzma2)
target_compile_options(NanoSpringLib
PUBLIC
-W -Wall -Wextra)
target_compile_options(NanoSpringLib
PUBLIC
$<$<CONFIG:Release>:-O3 -msse4.1>)
target_compile_options(NanoSpringLib
PUBLIC
$<$<CONFIG:RelWithDebInfo>:-g -O3 -msse4.1>)
target_compile_options(NanoSpringLib
PUBLIC
$<$<CONFIG:Debug>:-g -O3 -msse4.1 -fsanitize=address -fno-omit-frame-pointer>)
if ( CHECKS )
target_compile_options(NanoSpringLib
PUBLIC
-DCHECKS)
endif()
if ( LOG )
target_compile_options(NanoSpringLib
PUBLIC
-DLOG)
endif()
if ( USE_MALLOC_TRIM )
target_compile_options(NanoSpringLib
PUBLIC
-DUSE_MALLOC_TRIM)
endif()
target_compile_definitions(NanoSpringLib PUBLIC "$<$<CONFIG:Debug>:DEBUG>")
target_compile_definitions(NanoSpringLib PUBLIC "$<$<CONFIG:RelWithDebInfo>:DEBUG>")
add_dependencies(NanoSpringLib MINIMAP2)
add_dependencies(NanoSpringLib FASTLZMA2)
target_link_libraries(NanoSpringLib
PUBLIC
libbsc
${CMAKE_CURRENT_SOURCE_DIR}/minimap2/libminimap2.a
${CMAKE_CURRENT_SOURCE_DIR}/fast-lzma2/libfast-lzma2.a
Boost::filesystem
Boost::iostreams
Boost::program_options
-lz -ldl -lm -lpthread
)
target_link_libraries(NanoSpringLib
PUBLIC
$<$<CONFIG:Debug>:-fsanitize=address -fno-omit-frame-pointer>)
# OpenMp support
if(OpenMP_CXX_FOUND)
target_link_libraries(NanoSpringLib PUBLIC OpenMP::OpenMP_CXX)
endif()
###############################################
add_executable(NanoSpring src/main.cpp)
target_link_libraries(NanoSpring PUBLIC NanoSpringLib)
add_executable(testLoneReads src/testLoneReads.cpp)
target_include_directories(testLoneReads PUBLIC minimap2)
target_link_libraries(testLoneReads PUBLIC NanoSpringLib)