forked from rvicedomini/muset
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
222 lines (162 loc) · 5.86 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
cmake_minimum_required(VERSION 3.15)
project(muset VERSION 0.5.1 LANGUAGES C CXX)
############################################################
## kmtricks compile-time parameters
set(KMER_LIST "32,64")
set(KMER_N 2)
set(MAX_C 4294967295)
############################################################
## Required C++ standard
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(cmake_path "${PROJECT_SOURCE_DIR}/cmake")
############################################################
## Options
option(ARCH_NATIVE "Add -march=native compiler flag. Disabled for conda builds." ON)
option(CONDA_BUILD "Build inside conda env." OFF)
############################################################
## Prevent in-source build
if(${PROJECT_SOURCE_DIR} STREQUAL ${PROJECT_BINARY_DIR})
message(FATAL_ERROR "In-source build not allowed. Create a \"build\" directory and run CMake from there.")
endif()
############################################################
## Default build type set to "Release"
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif ()
message(STATUS "CMAKE_BUILD_TYPE: " ${CMAKE_BUILD_TYPE})
############################################################
## Disable -march=native flag for conda builds
if (CONDA_BUILD)
set(ARCH_NATIVE OFF)
endif()
############################################################
## Display details on host system
message(STATUS "Build Info:")
message(STATUS " Host System: ${CMAKE_HOST_SYSTEM}")
message(STATUS " Host System Name: ${CMAKE_HOST_SYSTEM_NAME}")
message(STATUS " Host System Processor: ${CMAKE_HOST_SYSTEM_PROCESSOR}")
message(STATUS " Host System Version: ${CMAKE_HOST_SYSTEM_VERSION}")
############################################################
## Compiler flags
set(CMAKE_CXX_FLAGS_DEBUG "-g")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wno-ignored-qualifiers -Wno-char-subscripts -Wno-maybe-uninitialized -Wno-unused-function -pedantic")
if (UNIX)
if (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "amd64|x86_64")
# flags for PTHash
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mbmi2 -msse4.2")
endif()
endif()
if (ARCH_NATIVE)
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
endif()
message(STATUS " CXX Compiler flags: ${CMAKE_CXX_FLAGS}")
############################################################
## Dependencies
include(ExternalProject)
set(external_dir ${PROJECT_SOURCE_DIR}/external)
set(external_bindir ${PROJECT_BINARY_DIR}/external)
set(includes "")
set(deps_libs "")
set(deps "")
list(APPEND includes ${CMAKE_SOURCE_DIR}/include
${CMAKE_BINARY_DIR}/include)
# bcli
list(APPEND includes ${external_dir}/bcli/include)
# bitpacker
list(APPEND includes ${external_dir}/bitpacker/include)
# cfrcat
list(APPEND includes ${external_dir}/cfrcat/include)
# fmt
include(${cmake_path}/fmt.cmake)
# gatb-core-stripped
include(${cmake_path}/gatb-core-stripped.cmake)
# indicators
list(APPEND includes ${external_dir}/indicators/include)
# json
list(APPEND includes ${external_dir}/json/include)
# kff-cpp-api
include(${cmake_path}/kff-cpp-api.cmake)
# kseq++
list(APPEND includes ${external_dir}/kseq++/include)
# kmtricks-logan
# include(${cmake_path}/kmtricks.cmake)
# lz4
include(${cmake_path}/lz4.cmake)
# robin-hood-hashing
list(APPEND includes ${external_dir}/robin-hood-hashing/src/include)
# span-lite
list(APPEND includes ${external_dir}/span-lite/include)
# spdlog
include(${cmake_path}/spdlog.cmake)
# sshash
include(${cmake_path}/sshash.cmake)
# TurboPFor-Integer-Compression
include(${cmake_path}/TurboPFor-Integer-Compression.cmake)
# xxHash
include(${cmake_path}/xxHash.cmake)
# zlib
find_package(ZLIB REQUIRED)
list(APPEND deps_libs ZLIB::ZLIB)
# threads
set(CMAKE_THREAD_PREFER_PTHREAD TRUE)
set(THREADS_PREFER_PTHREAD_FLAG TRUE)
find_package(Threads REQUIRED)
list(APPEND deps_libs Threads::Threads)
############################################################
## config.hpp file
configure_file("${PROJECT_SOURCE_DIR}/include/kmtricks/config.h.in" ${PROJECT_BINARY_DIR}/include/kmtricks/config.hpp)
configure_file("${PROJECT_SOURCE_DIR}/src/config.h.in" ${PROJECT_BINARY_DIR}/include/config.h)
############################################################
## Set executable output directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)
message(STATUS "Executables output directory: ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}")
############################################################
# kmat_tools executable
set(kmat_tools_sources
src/kmat_convert.cpp
src/kmat_diff.cpp
src/kmat_fafmt.cpp
src/kmat_fasta.cpp
src/kmat_filter.cpp
src/kmat_merge.cpp
src/kmat_reverse.cpp
src/kmat_select.cpp
src/kmat_unitig.cpp
src/kmat_cli.cpp
src/kmat_tools.cpp
)
add_executable(kmat_tools ${kmat_tools_sources})
target_compile_definitions(kmat_tools PRIVATE DMAX_C=${MAX_C})
target_include_directories(kmat_tools PRIVATE ${includes})
target_link_libraries(kmat_tools ${deps_libs})
add_dependencies(kmat_tools ${deps})
############################################################
# muset cpp executable
set(muset_sources
src/kmat_fafmt.cpp
src/kmat_fasta.cpp
src/kmat_filter.cpp
src/kmat_unitig.cpp
src/muset_cli.cpp
src/muset.cpp
)
add_executable(muset ${muset_sources})
target_compile_definitions(muset PRIVATE DMAX_C=${MAX_C})
target_include_directories(muset PRIVATE ${includes})
target_link_libraries(muset ${deps_libs})
add_dependencies(muset ${deps})
############################################################
# muset_pa cpp executable
set(muset_pa_sources
src/kmat_convert.cpp
src/kmat_fafmt.cpp
src/muset_pa_cli.cpp
src/muset_pa.cpp
)
add_executable(muset_pa ${muset_pa_sources})
target_compile_definitions(muset_pa PRIVATE DMAX_C=${MAX_C})
target_include_directories(muset_pa PRIVATE ${includes})
target_link_libraries(muset_pa ${deps_libs})
add_dependencies(muset_pa ${deps})