-
Notifications
You must be signed in to change notification settings - Fork 7
/
CMakeLists.txt
224 lines (176 loc) · 5.32 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
cmake_minimum_required(VERSION 3.10)
execute_process(
COMMAND git rev-parse HEAD
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE GIT_COMMIT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
project(rpvg)
set(CMAKE_CXX_STANDARD 14)
set(BUILD_STATIC 0 CACHE BOOL "Build static version")
if(${BUILD_STATIC} EQUAL 1)
set(Protobuf_USE_STATIC_LIBS ON)
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
endif(${BUILD_STATIC} EQUAL 1)
find_package(OpenMP REQUIRED)
find_package(Protobuf REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(HTSlib REQUIRED htslib)
ExternalProject_Add(sdsl-lite-proj
SOURCE_DIR "${PROJECT_SOURCE_DIR}/deps/sdsl-lite"
BUILD_IN_SOURCE TRUE
UPDATE_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ./install.sh ${PROJECT_SOURCE_DIR}/deps/sdsl-lite
)
ExternalProject_Add(gbwt-proj
SOURCE_DIR "${PROJECT_SOURCE_DIR}/deps/gbwt"
BUILD_IN_SOURCE TRUE
UPDATE_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND $(MAKE)
INSTALL_COMMAND ""
DEPENDS sdsl-lite-proj
)
ExternalProject_Add(libvgio-proj
SOURCE_DIR "${PROJECT_SOURCE_DIR}/deps/libvgio"
BUILD_IN_SOURCE TRUE
UPDATE_COMMAND ""
CONFIGURE_COMMAND cmake -DCMAKE_INSTALL_PREFIX=${PROJECT_SOURCE_DIR}/deps/libvgio .
BUILD_COMMAND $(MAKE)
INSTALL_COMMAND ""
)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)
include_directories(
${HTSlib_INCLUDE_DIRS}
${Protobuf_INCLUDE_DIRS}
${PROJECT_SOURCE_DIR}/deps/Catch2/single_include/catch2
${PROJECT_SOURCE_DIR}/deps/cxxopts/include
${PROJECT_SOURCE_DIR}/deps/sparsepp
${PROJECT_SOURCE_DIR}/deps/sdsl-lite/include
${PROJECT_SOURCE_DIR}/deps/gbwt/include
${PROJECT_SOURCE_DIR}/deps/libvgio
${PROJECT_SOURCE_DIR}/deps/libvgio/include
${PROJECT_SOURCE_DIR}/deps/libvgio/handlegraph-prefix/include
${PROJECT_SOURCE_DIR}/deps/eigen
${PROJECT_SOURCE_DIR}/deps/xg/src
${PROJECT_SOURCE_DIR}/deps/xg/deps/mmmulti/src
${PROJECT_SOURCE_DIR}/deps/xg/deps/mmmulti/deps/mio/include
${PROJECT_SOURCE_DIR}/deps/xg/deps/mmmulti/deps/atomic_queue/include/atomic_queue
${PROJECT_SOURCE_DIR}/deps/xg/deps/ips4o
${PROJECT_SOURCE_DIR}/deps/xg/deps/gfakluge/src
${PROJECT_SOURCE_DIR}/deps/xg/deps/gfakluge/src/tinyFA
)
link_directories(
${PROJECT_SOURCE_DIR}/deps/sdsl-lite/lib
${PROJECT_SOURCE_DIR}/deps/gbwt/lib
${PROJECT_SOURCE_DIR}/deps/libvgio
${PROJECT_SOURCE_DIR}/deps/libvgio/handlegraph-prefix/lib
)
add_library(xg
deps/xg/src/xg.cpp
)
target_link_libraries(xg
sdsl
handlegraph
divsufsort
divsufsort64
)
add_dependencies(xg gbwt-proj)
add_dependencies(xg libvgio-proj)
set(SOURCE_FILES
src/fragment_length_dist.cpp
src/paths_index.cpp
src/alignment_path.cpp
src/alignment_path_finder.cpp
src/path_clusters.cpp
src/read_path_probabilities.cpp
src/path_estimator.cpp
src/path_posterior_estimator.cpp
src/path_abundance_estimator.cpp
src/threaded_output_writer.cpp
src/io/register_libvg_io.cpp
src/io/register_loader_saver_gbwt.cpp
src/io/register_loader_saver_r_index.cpp
src/io/register_loader_saver_xg.cpp
)
if(${BUILD_STATIC} EQUAL 0)
link_directories(
${HTSlib_LIBRARY_DIRS}
)
add_library(${PROJECT_NAME}
${SOURCE_FILES}
)
target_link_libraries(${PROJECT_NAME}
${HTSlib_LIBRARIES}
)
else(${BUILD_STATIC} EQUAL 0)
message(STATUS "Building static version")
link_directories(
${HTSlib_STATIC_LIBRARY_DIRS}
)
add_executable(${PROJECT_NAME}
src/main.cpp
${SOURCE_FILES}
)
target_link_libraries(${PROJECT_NAME}
${HTSlib_STATIC_LIBRARIES}
)
set(CMAKE_EXE_LINKER_FLAGS "-static -static-libgcc -static-libstdc++")
endif(${BUILD_STATIC} EQUAL 0)
target_link_libraries(${PROJECT_NAME}
${PROTOBUF_LIBRARIES}
sdsl
gbwt
handlegraph
vgio
divsufsort
divsufsort64
xg
)
add_dependencies(${PROJECT_NAME} gbwt-proj)
add_dependencies(${PROJECT_NAME} libvgio-proj)
add_dependencies(${PROJECT_NAME} xg)
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(CMAKE_CXX_FLAGS "--std=c++14 -Xpreprocessor -fopenmp -g -march=native -O3 -DGIT_COMMIT='\"${GIT_COMMIT}\"'")
target_link_libraries(${PROJECT_NAME} omp)
target_link_libraries(xg omp)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(CMAKE_CXX_FLAGS "--std=c++14 -fopenmp -g -march=native -O3 -DGIT_COMMIT='\"${GIT_COMMIT}\"'")
target_link_libraries(${PROJECT_NAME} atomic)
target_link_libraries(xg atomic)
endif()
if(${BUILD_STATIC} EQUAL 0)
add_executable(${PROJECT_NAME}-bin
src/main.cpp
)
target_link_libraries(${PROJECT_NAME}-bin
${PROJECT_NAME}
)
set_target_properties(${PROJECT_NAME}-bin PROPERTIES OUTPUT_NAME ${PROJECT_NAME})
add_executable(${PROJECT_NAME}-tests
src/tests/main_test.cpp
src/tests/fragment_length_dist_test.cpp
src/tests/paths_index_test.cpp
src/tests/alignment_path_test.cpp
src/tests/alignment_path_finder_test.cpp
src/tests/read_path_probabilities_test.cpp
src/tests/path_clusters_test.cpp
src/tests/path_abundance_estimator_test.cpp
)
include_directories(
${PROJECT_SOURCE_DIR}/deps/catch2/single_include
)
target_link_libraries(${PROJECT_NAME}-tests
${PROJECT_NAME}
)
enable_testing()
add_test(
NAME ${PROJECT_NAME}-tests
COMMAND ${PROJECT_NAME}-tests
)
endif(${BUILD_STATIC} EQUAL 0)