forked from hiruna72/slow5-dorado
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
executable file
·287 lines (251 loc) · 9.64 KB
/
CMakeLists.txt
File metadata and controls
executable file
·287 lines (251 loc) · 9.64 KB
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
287
cmake_minimum_required(VERSION 3.25)
set(CMAKE_POLICY_DEFAULT_CMP0063 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
set(CMAKE_POLICY_DEFAULT_CMP0091 NEW)
project(slow5-dorado LANGUAGES C CXX)
if(APPLE)
enable_language(OBJC OBJCXX)
endif()
# BUILD_SHARED_LIBS is a global variable, so if we don't set it here at the start, we won't get
# the same behaviour if we re-configure CMake compared to a clean configure, because it's
# eventually set elsewhere
set(BUILD_SHARED_LIBS OFF)
# All static libraries should be position-independent, as they are liable to be compiled into shared
# libraries
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Allow targets with no side effects to be built in parallel when using Makefiles.
# Koi uses OBJECT targets which are (currently) incompatible with this.
# See https://gitlab.kitware.com/cmake/cmake/-/issues/24058.
if (NOT BUILD_KOI_FROM_SOURCE)
set(CMAKE_OPTIMIZE_DEPENDENCIES ON)
endif()
get_cmake_property(MULTI_CONFIG GENERATOR_IS_MULTI_CONFIG)
if (NOT MULTI_CONFIG)
if (NOT EXISTS ${CMAKE_BINARY_DIR}/CMakeCache.txt AND NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif()
endif()
message(STATUS "Build type: " ${CMAKE_BUILD_TYPE})
# If no prefix is provided we install next to the binary directory.
if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set(CMAKE_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/../dist CACHE PATH "" FORCE)
endif()
if(WIN32)
# all third parties are release builds, so we must match the windows runtime
set(CMAKE_MSVC_RUNTIME_LIBRARY MultiThreadedDLL)
message(STATUS "toolset: ${CMAKE_GENERATOR_TOOLSET}")
message(STATUS "platform: ${CMAKE_GENERATOR_PLATFORM}")
message(STATUS "vs platform: ${CMAKE_VS_PLATFORM_NAME}")
# MSVC won't parallelise individual targets unless you tell it to.
add_compile_options("$<$<NOT:$<COMPILE_LANGUAGE:CUDA>>:/MP${WIN_THREADS}>")
endif()
if (APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
message(FATAL_ERROR "MacOS x86_64 builds are no longer supported.")
endif()
if (APPLE AND NOT ECM_ENABLE_SANITIZERS)
# Prefer static libs if they exist so that we don't run into issues
# linking to dynamic libraries that live in brew.
list(PREPEND CMAKE_FIND_LIBRARY_SUFFIXES ".a")
endif()
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_EXTENSIONS OFF)
# Set warnings and RPATH before we create any targets.
include(cmake/Warnings.cmake)
include(cmake/SetRPATH.cmake)
set(DORADO_3RD_PARTY_SOURCE ${CMAKE_CURRENT_SOURCE_DIR}/dorado/3rdparty)
set(DORADO_3RD_PARTY_DOWNLOAD ${CMAKE_CURRENT_BINARY_DIR}/download
CACHE PATH "Location to download 3rdparty libraries into")
find_package(CUDAToolkit QUIET)
if(${CUDAToolkit_FOUND})
file(REAL_PATH ${CUDAToolkit_TARGET_DIR} CUDAToolkit_REAL_DIR)
message(STATUS "Found CUDA ${CUDAToolkit_VERSION} (${CUDAToolkit_TARGET_DIR} -> ${CUDAToolkit_REAL_DIR})")
endif()
if(DEFINED ENV{DORADO_CDN_URL_OVERRIDE})
set(DORADO_CDN_URL "$ENV{DORADO_CDN_URL_OVERRIDE}")
else()
set(DORADO_CDN_URL "https://cdn.oxfordnanoportal.com/software/analysis")
endif()
message(STATUS "Using CDN URL ${DORADO_CDN_URL} for downloads")
# Repo setup and helpers.
include(cmake/DoradoVersion.cmake)
include(cmake/UpdateSubmodules.cmake)
include(cmake/DownloadAndExtract.cmake)
include(cmake/SharedLibHelpers.cmake)
include(cmake/DoradoTarget.cmake)
include(cmake/DoradoCheckDeps.cmake)
include(cmake/Slow5.cmake)
# Add sanitizer options to compilation flags
include(cmake/ECMEnableSanitizers.cmake)
if (ECM_ENABLE_SANITIZERS)
# Always emit debug info to provide better stack traces
add_compile_options(-g)
# Silence overeager GCC warnings that only show up when sanitizers are enabled.
if ((CMAKE_CXX_COMPILER_ID MATCHES "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 13.0))
add_compile_options(-Wno-error=array-bounds)
endif()
endif()
if(DORADO_USING_OLD_CPP_ABI)
# We need to force the use of the old ABI here, if we are building in an old ABI context, as otherwise elzip builds
# with the libc++11 ABI and we can't link against it.
add_compile_definitions(_GLIBCXX_USE_CXX11_ABI=0)
endif()
# For capturing test coverage.
option(GENERATE_TEST_COVERAGE "Build with code coverage enabled" OFF)
if (GENERATE_TEST_COVERAGE)
# Ignore negative values due to a bug in gcov https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68080
set(GCOVR_ADDITIONAL_ARGS "--gcov-ignore-parse-errors=negative_hits.warn")
include(cmake/CodeCoverage.cmake)
if (NOT DORADO_DISABLE_TESTS)
setup_target_for_coverage_gcovr_html(
NAME dorado_test_coverage
EXECUTABLE ctest --test-dir ${CMAKE_BINARY_DIR} --verbose -R dorado_tests
DEPENDENCIES dorado_tests
BASE_DIRECTORY "${PROJECT_SOURCE_DIR}"
EXCLUDE
"${DORADO_3RD_PARTY_SOURCE}/*"
"${DORADO_3RD_PARTY_DOWNLOAD}/*"
"${PROJECT_SOURCE_DIR}/tests/*"
"${CMAKE_BINARY_DIR}/3rdparty/*"
)
endif()
endif()
set(CHOCO_CCACHE_HINT)
file(GLOB CHOCO_CACHE_LIST LIST_DIRECTORIES true "C:/ProgramData/chocolatey/lib/ccache/tools/ccache-*")
if (CHOCO_CACHE_LIST)
list(SORT CHOCO_CACHE_LIST)
list(GET CHOCO_CACHE_LIST -1 CHOCO_CCACHE_HINT)
endif()
# Use ccache for C and C++ if it's available
find_program(CCACHE_EXE ccache
HINTS
"C:/Program\ Files/ccache/"
${CHOCO_CCACHE_HINT}
)
option(DORADO_DISABLE_CCACHE "Explicitly disable the use of ccache" OFF)
if (CCACHE_EXE AND NOT DORADO_DISABLE_CCACHE)
if(MSVC)
# See https://github.com/ccache/ccache/wiki/MS-Visual-Studio#usage-with-cmake
file(COPY_FILE
${CCACHE_EXE} ${CMAKE_BINARY_DIR}/cl.exe
ONLY_IF_DIFFERENT
)
# By default Visual Studio generators will use /Zi which is not compatible
# with ccache, so tell Visual Studio to use /Z7 instead.
message(STATUS "Setting MSVC debug information format to 'Embedded'")
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT "$<$<CONFIG:Debug,RelWithDebInfo>:Embedded>")
set(CMAKE_VS_GLOBALS
"CLToolExe=cl.exe"
"CLToolPath=${CMAKE_BINARY_DIR}"
"UseMultiToolTask=true"
"DebugInformationFormat=OldStyle"
)
else()
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_EXE})
set(CMAKE_CXX_COMPILER_LAUNCHER ${CCACHE_EXE})
endif()
message(STATUS "Using ccache at: ${CCACHE_EXE}")
set(DORADO_ENABLE_PCH FALSE)
else()
# Fallback to using a PCH if we don't have ccache support, since making them work together isn't simple.
set(DORADO_ENABLE_PCH TRUE)
endif()
# By default, make per-read trace-logging a no-op. Turn this option on to enable it.
option(DORADO_PER_READ_TRACE "Enable per-read trace logging" OFF)
# Bring in 3rdparty libs
include(cmake/Zlib.cmake)
include(cmake/Koi.cmake)
include(cmake/Pod5.cmake)
include(cmake/Torch.cmake)
include(cmake/OpenSSL.cmake)
include(cmake/Htslib.cmake)
if (APPLE)
include(cmake/Metal.cmake)
endif()
add_subdirectory(dorado/3rdparty)
enable_testing()
# CMake can't REUSE_FROM targets that it doesn't know about, so include
# torch_utils first for its PCH.
add_subdirectory(dorado/torch_utils)
add_subdirectory(dorado/aligner)
add_subdirectory(dorado/alignment)
add_subdirectory(dorado/api)
add_subdirectory(dorado/basecall)
add_subdirectory(dorado/compat)
add_subdirectory(dorado/config)
add_subdirectory(dorado/correct)
add_subdirectory(dorado/data_loader)
add_subdirectory(dorado/demux)
add_subdirectory(dorado/devtools)
add_subdirectory(dorado/file_info)
add_subdirectory(dorado/hts_utils)
add_subdirectory(dorado/hts_writer)
add_subdirectory(dorado/modbase)
add_subdirectory(dorado/model_downloader)
add_subdirectory(dorado/models)
add_subdirectory(dorado/nn)
add_subdirectory(dorado/polish)
add_subdirectory(dorado/poly_tail)
add_subdirectory(dorado/read_pipeline)
add_subdirectory(dorado/resume_loader)
add_subdirectory(dorado/secondary)
add_subdirectory(dorado/splitter)
add_subdirectory(dorado/summary)
add_subdirectory(dorado/utils)
add_subdirectory(tests)
if (NOT DORADO_DISABLE_DORADO)
add_subdirectory(dorado/cli)
endif()
# Stopgap target to keep things linking.
# Eventually this will be removed and dependents should link only
# to what they need.
add_library(dorado_lib INTERFACE)
target_link_libraries(dorado_lib
INTERFACE
dorado_aligner
dorado_alignment
dorado_api
dorado_basecall
dorado_correct
dorado_demux
dorado_hts_utils
dorado_hts_writer
dorado_modbase
dorado_poly_tail
dorado_read_pipeline
dorado_resume_loader
dorado_secondary
dorado_splitter
dorado_version
)
# Packaging setup.
include(cmake/InstallRedistLibs.cmake)
if(NOT DORADO_DISABLE_PACKAGING)
include(cmake/DoradoPackaging.cmake)
endif()
if(CMAKE_COMPILER_IS_GNUCXX AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL "11.0") )
find_library(
LIBSTDCPP_LINK_LOCATION
NAMES "libstdc++.so.6"
HINTS /usr/lib/x86_64-linux-gnu/
)
if (NOT LIBSTDCPP_LINK_LOCATION)
message(FATAL_ERROR "Could not find libstdc++")
endif()
# Follow the softlink from LIBSTDCPP_LINK_LOCATION to the real library
execute_process(
COMMAND "readlink" "-e" "${LIBSTDCPP_LINK_LOCATION}"
OUTPUT_VARIABLE LIBSTDCPP_LOCATION
RESULT_VARIABLE LIBSTDCPP_READLINK_RESULT
OUTPUT_STRIP_TRAILING_WHITESPACE
)
if (NOT LIBSTDCPP_READLINK_RESULT EQUAL 0)
message(
FATAL_ERROR
"Unable to follow ${LIBSTDCPP_LINK_LOCATION} to a real file, return-code ${LIBSTDCPP_READLINK_RESULT}"
)
endif ()
install(
FILES ${LIBSTDCPP_LOCATION} ${LIBSTDCPP_LINK_LOCATION}
DESTINATION lib
)
endif()