-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
286 lines (208 loc) · 11.3 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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
cmake_minimum_required(VERSION 2.8)
# ----------------------------- Packaging ------------------------------
project(fastafs)
# helps debugging:
# Do this once in a while - find different compiler warnings
#set(CMAKE_CXX_COMPILER "clang++")
set(PROJECT_VERSION "1.11.0")
set(PACKAGE_URL "https://github.com/yhoogstrate/fastafs")
set(PACKAGE_BUGREPORT "${PACKAGE_URL}/issues")
set(BUILD_DIR "bin")
set(BUILD_TEST_DIR "${BUILD_DIR}/test")
file(MAKE_DIRECTORY "${BUILD_DIR}")
file(MAKE_DIRECTORY "${BUILD_TEST_DIR}")
# include the git commit SHA1
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake-modules/")
include(GetGitRevisionDescription)
get_git_head_revision(GIT_REFSPEC GIT_SHA1)
if(NOT "${GIT_SHA1}" STREQUAL "")
set(GIT_SHA1_STRING "-${GIT_SHA1}")
endif()
# ----------------------------------------------------------------------
# ------------------------------ Pre-comp ------------------------------
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE debug)
message(WARNING "No CMAKE_BUILD_TYPE was defined. Build type 'debug' was chosen, which will perform slower than using 'cmake -DCMAKE_BUILD_TYPE=release'.")
endif(NOT CMAKE_BUILD_TYPE)
string(TOLOWER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE)
if(CMAKE_BUILD_TYPE STREQUAL "debug")
set(DEBUG "true")
else()
set(DEBUG "false")
endif()
configure_file("include/config.hpp.in" "include/config.hpp")# implies building is done from project root
#configure_file("include/config.hpp.in" "${CMAKE_CURRENT_BINARY_DIR}/config.hpp")
#configure_file("include/config.hpp.in" "${CMAKE_CURRENT_SOURCE_DIR}/config.hpp")
configure_file("include/config.hpp.in" "${BUILD_DIR}/include/config.hpp")
# ----------------------------------------------------------------------
# ------------------------------ Styling -------------------------------
# run 'make tidy' to style the syntax using astyle
find_program(ASTYLE astyle)
add_custom_command(
OUTPUT make_tidy
COMMAND bash tidy.sh
)
add_custom_target(tidy DEPENDS make_tidy )
# ----------------------------------------------------------------------
# --------------------------- Documentation ----------------------------
find_program(DOXYGEN doxygen)
find_program(DOT dot) # sudo apt install graphviz
configure_file("doc/Doxyfile.in" "doc/Doxyfile")
add_custom_command(
OUTPUT make_doc
COMMAND doxygen doc/Doxyfile
)
add_custom_target(doc DEPENDS make_doc)
# ----------------------------------------------------------------------
# ---------------------------- Compilation -----------------------------
add_subdirectory(src)
include_directories("${BUILD_DIR}/include")
include_directories("${CMAKE_SOURCE_DIR}/include")
# ZSTD
include_directories("${CMAKE_SOURCE_DIR}/dependencies/zstd-lib-common")
# ZSTD-SEEKABLE
add_subdirectory("${CMAKE_SOURCE_DIR}/dependencies/zstd-seekable-adapted")
include_directories("${CMAKE_SOURCE_DIR}/dependencies/zstd-seekable-adapted")
add_definitions(-std=c++14)
# Boost
find_package(Boost COMPONENTS unit_test_framework REQUIRED)
if(NOT Boost_FOUND)
message(FATAL_ERROR "Boost not found or requirement not satisfied. See building instructions.")
else()
message(STATUS "Found Boost: ${Boost_INCLUDE_DIR}, ${Boost_LIBRARIES}")
add_definitions(-DBOOST_ALL_DYN_LINK)
include_directories(${Boost_INCLUDE_DIRS})
endif()
link_libraries(ssl)
link_libraries(crypto)
link_libraries(fuse)
link_libraries(z)# zlib; -lz; for crc32 checks on whole file integrity
link_libraries(zstd)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
# -DXXH_NAMESPACE=ZST_
if(DEBUG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -pg -ggdb -Wconversion -D_FILE_OFFSET_BITS=64 -g -DBOOST_TEST_TOOLS_UNDER_DEBUGGER -DBOOST_TEST_TOOLS_DEBUGGABLE")# -Werror makes compilation crash when warnings are given (also part of Travis)
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -D_FILE_OFFSET_BITS=64")
endif()
# ----------------------------------------------------------------------
# ----------------------------- Build lib ------------------------------
add_library(libfastafs SHARED
src/fasta_to_fastafs.cpp
src/ucsc2bit_to_fastafs.cpp
src/flags.cpp
src/fastafs.cpp
src/ucsc2bit.cpp
src/xbit_byte_encoder.cpp
src/twobit_byte.cpp
src/fourbit_byte.cpp
src/fivebit_fivebytes.cpp
src/database.cpp
src/utils.cpp
src/sequence_region.cpp
src/fuse.cpp
src/lsfastafs.cpp
src/chunked_reader.cpp
dependencies/zstd-lib-common/xxhash.c
dependencies/zstd-seekable-adapted/zstdseek_utils.cpp
dependencies/zstd-seekable-adapted/zstdseek_compress.cpp
dependencies/zstd-seekable-adapted/zstdseek_decompress.cpp
)
target_include_directories(libfastafs PUBLIC include)
target_include_directories(libfastafs PUBLIC dependencies/zstd-lib-common)
target_include_directories(libfastafs PUBLIC dependencies/zstd-seekable-adapted)
set_target_properties(libfastafs PROPERTIES LIBRARY_OUTPUT_DIRECTORY "lib")
set_target_properties(libfastafs PROPERTIES VERSION ${PROJECT_VERSION})
set_target_properties(libfastafs PROPERTIES SOVERSION 1)
set_target_properties(libfastafs PROPERTIES OUTPUT_NAME fastafs)
##set_target_properties(libfastafs PROPERTIES HEADER_OUTPUT_DIRECTORY "include")
## great, this doesn't go automagically with an entire dir
set_target_properties(libfastafs PROPERTIES PUBLIC_HEADER "include/config.hpp;include/chunked_reader.hpp;include/database.hpp;include/fastafs.hpp;include/fasta_to_fastafs.hpp;include/flags.hpp;include/fourbit_byte.hpp;include/fuse.hpp;include/lsfastafs.hpp;include/sequence_region.hpp;include/twobit_byte.hpp;include/ucsc2bit.hpp;include/ucsc2bit_to_fastafs.hpp;include/utils.hpp")
set_target_properties(libfastafs PROPERTIES PUBLIC_HEADER_DIRECTORY include)
##set_target_properties(libfastafs PROPERTIES PUBLIC_HEADER_OUTPUT_DIRECTORY "include")
# ----------------------------------------------------------------------
# ----------------------------- Build exe ------------------------------
add_executable(fastafs src/main.cpp)
set_target_properties(fastafs PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${BUILD_DIR}")
target_link_libraries(fastafs libfastafs)
# mount-only binary, without all the other stuff 'mount.fastafs' [for fstab]
add_executable(mount.fastafs src/main_mount.cpp)
set_target_properties(mount.fastafs PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${BUILD_DIR}")
target_link_libraries(mount.fastafs libfastafs)
# ----------------------------------------------------------------------
# ------------------------------ Testing -------------------------------
#add_subdirectory(test)
set(BUILD_TEST_DIR "${BUILD_DIR}/test")
enable_testing()
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) # 'make check' as alias for 'make test'
add_executable(test_cache test/cache/test_cache.cpp)
set_target_properties(test_cache PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_cache libfastafs)
add_test(test_cache ${BUILD_TEST_DIR}/test_cache)
add_executable(test_check test/check/test_check.cpp)
set_target_properties(test_check PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_check libfastafs)
add_test(test_check ${BUILD_TEST_DIR}/test_check)
add_executable(test_chunked_reader test/chunked_reader/test_chunked_reader.cpp )
add_test(test_chunked_reader ${BUILD_TEST_DIR}/test_chunked_reader)
set_target_properties(test_chunked_reader PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_chunked_reader libfastafs)
add_executable(test_database test/database/test_database.cpp)
set_target_properties(test_database PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_database libfastafs)
add_test(test_database ${BUILD_TEST_DIR}/test_database)
add_executable(test_fastafs_as_ucsc2bit test/fastafs/test_ucsc2bit.cpp)
add_test(test_fastafs_as_ucsc2bit ${BUILD_TEST_DIR}/test_fastafs_as_ucsc2bit)
set_target_properties(test_fastafs_as_ucsc2bit PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_fastafs_as_ucsc2bit libfastafs)
add_executable(test_fastafs test/fastafs/test_fastafs.cpp)
add_test(test_fastafs ${BUILD_TEST_DIR}/test_fastafs)
set_target_properties(test_fastafs PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_fastafs libfastafs)
add_executable(test_fivebit_byte test/fivebit_fivebytes/test_fivebit_fivebytes.cpp)
add_test(test_fivebit_byte ${BUILD_TEST_DIR}/test_fivebit_byte)
set_target_properties(test_fivebit_byte PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_fivebit_byte libfastafs)
add_executable(test_flags test/flags/test_flags.cpp)
add_test(test_flags ${BUILD_TEST_DIR}/test_flags)
set_target_properties(test_flags PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_flags libfastafs)
add_executable(test_fourbit_byte test/fourbit_byte/test_fourbit_byte.cpp)
add_test(test_fourbit_byte ${BUILD_TEST_DIR}/test_fourbit_byte)
set_target_properties(test_fourbit_byte PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_fourbit_byte libfastafs)
add_executable(test_sequenceregion test/sequenceregion/test_sequenceregion.cpp)
add_test(test_sequenceregion ${BUILD_TEST_DIR}/test_sequenceregion)
set_target_properties(test_sequenceregion PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_sequenceregion libfastafs)
add_executable(test_twobit_byte test/twobit_byte/test_twobit_byte.cpp)
add_test(test_twobit_byte ${BUILD_TEST_DIR}/test_twobit_byte)
set_target_properties(test_twobit_byte PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_twobit_byte libfastafs)
add_executable(test_ucsc2bit_as_fasta test/ucsc2bit/test_ucsc2bit_as_fasta.cpp)
add_test(test_ucsc2bit_as_fasta ${BUILD_TEST_DIR}/test_ucsc2bit_as_fasta)
set_target_properties(test_ucsc2bit_as_fasta PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_ucsc2bit_as_fasta libfastafs)
add_executable(test_ucsc2bit_to_fastafs test/ucsc2bit_to_fastafs/test_ucsc2bit_to_fastafs.cpp)
add_test(test_ucsc2bit_to_fastafs ${BUILD_TEST_DIR}/test_ucsc2bit_to_fastafs)
set_target_properties(test_ucsc2bit_to_fastafs PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_ucsc2bit_to_fastafs libfastafs)
add_executable(test_utils test/utils/test_utils.cpp)
add_test(test_utils ${BUILD_TEST_DIR}/test_utils)
set_target_properties(test_utils PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_utils libfastafs)
add_executable(test_view test/view/test_view.cpp)
add_test(test_view ${BUILD_TEST_DIR}/test_view)
set_target_properties(test_view PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_view libfastafs)
#add_test(test_functional "test/test_functional.py")
find_program(CTEST_MEMORYCHECK_COMMAND NAMES valgrind) # 'ctest -T memcheck'
INCLUDE(Dart)
# ----------------------------------------------------------------------
# --------------------------- Installation -----------------------------
# The compiled binary, usually to: /usr/local/bin/fastafs
install(TARGETS fastafs DESTINATION "bin")
install(TARGETS mount.fastafs DESTINATION "bin")
# don't build during debug at least
install(TARGETS libfastafs LIBRARY DESTINATION "lib" PUBLIC_HEADER DESTINATION "include/libfastafs")
# ----------------------------------------------------------------------