-
Notifications
You must be signed in to change notification settings - Fork 68
/
CMakeLists.txt
executable file
·499 lines (454 loc) · 17.5 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
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
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(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)
# 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 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 17)
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")
# We don't support GPU builds on macOS/x64
if (APPLE AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
set(DORADO_GPU_BUILD FALSE)
else()
set(DORADO_GPU_BUILD TRUE)
endif()
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()
include(cmake/DoradoVersion.cmake)
include(cmake/UpdateSubmodules.cmake)
include(cmake/DownloadAndExtract.cmake)
include(cmake/SharedLibHelpers.cmake)
include(cmake/HDF5.cmake)
include(cmake/VbzPlugin.cmake)
include(cmake/Koi.cmake)
include(cmake/Pod5.cmake)
include(cmake/Torch.cmake)
include(cmake/OpenSSL.cmake)
include(cmake/Htslib.cmake)
if (DORADO_GPU_BUILD AND APPLE)
include(cmake/Metal.cmake)
endif()
# 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)
# Add a way to detect if we're compiling with sanitizers enabled, since UBSan
# detection isn't available in GCC
foreach (SANITIZER ${ECM_ENABLE_SANITIZERS})
string(TOUPPER ${SANITIZER} SANITIZER)
add_compile_definitions(DORADO_SANITIZE_${SANITIZER})
endforeach()
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()
# Use ccache for C and C++ if it's available
find_program(CCACHE_EXE ccache)
option(DORADO_DISABLE_CCACHE "Explicitly disable the use of ccache" OFF)
if (CCACHE_EXE AND NOT DORADO_DISABLE_CCACHE)
set(CMAKE_C_COMPILER_LAUNCHER ${CCACHE_EXE})
set(CMAKE_CXX_COMPILER_LAUNCHER ${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()
if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND (CMAKE_SYSTEM_PROCESSOR MATCHES "^aarch64*|^arm*"))
if(${CUDAToolkit_VERSION} VERSION_LESS 11.0)
add_compile_definitions(DORADO_TX2)
else()
add_compile_definitions(DORADO_ORIN)
endif()
endif()
# Bring in 3rdparty libs
add_subdirectory(dorado/3rdparty)
enable_testing()
add_subdirectory(dorado/compat)
add_subdirectory(dorado/utils)
add_subdirectory(dorado/torch_utils)
add_subdirectory(dorado/models)
add_subdirectory(dorado/model_downloader)
add_subdirectory(dorado/basecall)
add_subdirectory(dorado/modbase)
add_subdirectory(dorado/devtools)
configure_file(
dorado/dorado_version.h.in
${CMAKE_CURRENT_BINARY_DIR}/dorado_generated/dorado_version.h
)
add_library(dorado_lib
dorado/alignment/alignment_info.h
dorado/alignment/alignment_processing_items.cpp
dorado/alignment/alignment_processing_items.h
dorado/alignment/bed_file.cpp
dorado/alignment/bed_file.h
dorado/alignment/BedFileAccess.cpp
dorado/alignment/BedFileAccess.h
dorado/alignment/IndexFileAccess.cpp
dorado/alignment/IndexFileAccess.h
dorado/alignment/minimap2_args.cpp
dorado/alignment/minimap2_args.h
dorado/alignment/minimap2_wrappers.h
dorado/alignment/Minimap2Aligner.cpp
dorado/alignment/Minimap2Aligner.h
dorado/alignment/Minimap2Index.cpp
dorado/alignment/Minimap2Index.h
dorado/alignment/Minimap2IndexSupportTypes.h
dorado/alignment/Minimap2Options.cpp
dorado/alignment/Minimap2Options.h
dorado/alignment/sam_utils.cpp
dorado/alignment/sam_utils.h
dorado/api/caller_creation.cpp
dorado/api/caller_creation.h
dorado/api/runner_creation.cpp
dorado/api/runner_creation.h
dorado/api/pipeline_creation.cpp
dorado/api/pipeline_creation.h
dorado/demux/adapter_primer_kits.cpp
dorado/demux/adapter_primer_kits.h
dorado/demux/adapter_info.h
dorado/demux/AdapterDetector.cpp
dorado/demux/AdapterDetector.h
dorado/demux/AdapterDetectorSelector.h
dorado/demux/AdapterDetectorSelector.cpp
dorado/demux/BarcodeClassifier.cpp
dorado/demux/BarcodeClassifier.h
dorado/demux/BarcodeClassifierSelector.cpp
dorado/demux/BarcodeClassifierSelector.h
dorado/demux/barcoding_info.h
dorado/demux/KitInfoProvider.cpp
dorado/demux/KitInfoProvider.h
dorado/demux/Trimmer.cpp
dorado/demux/Trimmer.h
dorado/demux/parse_custom_kit.cpp
dorado/demux/parse_custom_kit.h
dorado/demux/parse_custom_sequences.cpp
dorado/demux/parse_custom_sequences.h
dorado/read_pipeline/AdapterDetectorNode.cpp
dorado/read_pipeline/AdapterDetectorNode.h
dorado/read_pipeline/AlignerNode.cpp
dorado/read_pipeline/AlignerNode.h
dorado/read_pipeline/BarcodeClassifierNode.cpp
dorado/read_pipeline/BarcodeClassifierNode.h
dorado/read_pipeline/BarcodeDemuxerNode.cpp
dorado/read_pipeline/BarcodeDemuxerNode.h
dorado/read_pipeline/BasecallerNode.cpp
dorado/read_pipeline/BasecallerNode.h
dorado/read_pipeline/BaseSpaceDuplexCallerNode.cpp
dorado/read_pipeline/BaseSpaceDuplexCallerNode.h
dorado/read_pipeline/ClientInfo.h
dorado/read_pipeline/context_container.h
dorado/read_pipeline/CorrectionInferenceNode.cpp
dorado/read_pipeline/CorrectionInferenceNode.h
dorado/read_pipeline/CorrectionMapperNode.cpp
dorado/read_pipeline/CorrectionMapperNode.h
dorado/read_pipeline/CorrectionPafReaderNode.cpp
dorado/read_pipeline/CorrectionPafReaderNode.h
dorado/read_pipeline/CorrectionPafWriterNode.cpp
dorado/read_pipeline/CorrectionPafWriterNode.h
dorado/read_pipeline/DefaultClientInfo.h
dorado/read_pipeline/DuplexReadTaggingNode.cpp
dorado/read_pipeline/DuplexReadTaggingNode.h
dorado/read_pipeline/FakeDataLoader.cpp
dorado/read_pipeline/FakeDataLoader.h
dorado/read_pipeline/HtsReader.cpp
dorado/read_pipeline/HtsReader.h
dorado/read_pipeline/HtsWriter.cpp
dorado/read_pipeline/HtsWriter.h
dorado/read_pipeline/MessageSink.cpp
dorado/read_pipeline/MessageSink.h
dorado/read_pipeline/ModBaseCallerNode.cpp
dorado/read_pipeline/ModBaseCallerNode.h
dorado/read_pipeline/ModBaseChunkCallerNode.cpp
dorado/read_pipeline/ModBaseChunkCallerNode.h
dorado/read_pipeline/NullNode.h
dorado/read_pipeline/NullNode.cpp
dorado/read_pipeline/PairingNode.cpp
dorado/read_pipeline/PairingNode.h
dorado/read_pipeline/PolyACalculatorNode.cpp
dorado/read_pipeline/PolyACalculatorNode.h
dorado/read_pipeline/ProgressTracker.cpp
dorado/read_pipeline/ProgressTracker.h
dorado/read_pipeline/ReadFilterNode.cpp
dorado/read_pipeline/ReadFilterNode.h
dorado/read_pipeline/ReadForwarderNode.cpp
dorado/read_pipeline/ReadForwarderNode.h
dorado/read_pipeline/ReadPipeline.cpp
dorado/read_pipeline/ReadPipeline.h
dorado/read_pipeline/ReadSplitNode.cpp
dorado/read_pipeline/ReadSplitNode.h
dorado/read_pipeline/ReadToBamTypeNode.cpp
dorado/read_pipeline/ReadToBamTypeNode.h
dorado/read_pipeline/ResumeLoader.cpp
dorado/read_pipeline/ResumeLoader.h
dorado/read_pipeline/ScalerNode.cpp
dorado/read_pipeline/ScalerNode.h
dorado/read_pipeline/StereoDuplexEncoderNode.cpp
dorado/read_pipeline/StereoDuplexEncoderNode.h
dorado/read_pipeline/SubreadTaggerNode.cpp
dorado/read_pipeline/SubreadTaggerNode.h
dorado/read_pipeline/TrimmerNode.cpp
dorado/read_pipeline/TrimmerNode.h
dorado/read_pipeline/messages.cpp
dorado/read_pipeline/messages.h
dorado/read_pipeline/flush_options.h
dorado/read_pipeline/read_output_progress_stats.cpp
dorado/read_pipeline/read_output_progress_stats.h
dorado/read_pipeline/read_utils.cpp
dorado/read_pipeline/read_utils.h
dorado/read_pipeline/stereo_features.cpp
dorado/read_pipeline/stereo_features.h
dorado/read_pipeline/stitch.cpp
dorado/read_pipeline/stitch.h
dorado/splitter/DuplexReadSplitter.cpp
dorado/splitter/DuplexReadSplitter.h
dorado/splitter/RNAReadSplitter.cpp
dorado/splitter/RNAReadSplitter.h
dorado/splitter/myers.cpp
dorado/splitter/myers.h
dorado/splitter/splitter_utils.cpp
dorado/splitter/splitter_utils.h
dorado/poly_tail/dna_poly_tail_calculator.cpp
dorado/poly_tail/dna_poly_tail_calculator.h
dorado/poly_tail/plasmid_poly_tail_calculator.cpp
dorado/poly_tail/plasmid_poly_tail_calculator.h
dorado/poly_tail/poly_tail_calculator.cpp
dorado/poly_tail/poly_tail_calculator.h
dorado/poly_tail/poly_tail_calculator_selector.cpp
dorado/poly_tail/poly_tail_calculator_selector.h
dorado/poly_tail/poly_tail_config.cpp
dorado/poly_tail/poly_tail_config.h
dorado/poly_tail/rna_poly_tail_calculator.cpp
dorado/poly_tail/rna_poly_tail_calculator.h
dorado/summary/summary.cpp
dorado/summary/summary.h
dorado/hts_io/FastxRandomReader.cpp
dorado/hts_io/FastxRandomReader.h
dorado/correct/features.cpp
dorado/correct/features.h
dorado/correct/windows.cpp
dorado/correct/windows.h
dorado/correct/conversions.cpp
dorado/correct/conversions.h
dorado/correct/decode.cpp
dorado/correct/decode.h
dorado/correct/infer.cpp
dorado/correct/infer.h
dorado/correct/CorrectionProgressTracker.cpp
dorado/correct/CorrectionProgressTracker.h
dorado/polish/consensus_result.h
dorado/polish/bam_file.cpp
dorado/polish/bam_file.h
dorado/polish/interval.h
dorado/polish/polish_impl.cpp
dorado/polish/polish_impl.h
dorado/polish/polish_progress_tracker.cpp
dorado/polish/polish_progress_tracker.h
dorado/polish/polish_utils.cpp
dorado/polish/polish_utils.h
dorado/polish/region.cpp
dorado/polish/region.h
dorado/polish/sample.h
dorado/polish/trim.cpp
dorado/polish/trim.h
dorado/polish/window.cpp
dorado/polish/window.h
dorado/polish/features/decoder_base.cpp
dorado/polish/features/decoder_base.h
dorado/polish/features/decoder_factory.cpp
dorado/polish/features/decoder_factory.h
dorado/polish/features/encoder_base.h
dorado/polish/features/encoder_counts.cpp
dorado/polish/features/encoder_counts.h
dorado/polish/features/encoder_factory.cpp
dorado/polish/features/encoder_factory.h
dorado/polish/features/encoder_read_alignment.cpp
dorado/polish/features/encoder_read_alignment.h
dorado/polish/features/medaka_bamiter.cpp
dorado/polish/features/medaka_bamiter.h
dorado/polish/features/medaka_counts.cpp
dorado/polish/features/medaka_counts.h
dorado/polish/features/medaka_read_matrix.cpp
dorado/polish/features/medaka_read_matrix.h
dorado/polish/architectures/model_config.cpp
dorado/polish/architectures/model_config.h
dorado/polish/architectures/model_factory.cpp
dorado/polish/architectures/model_factory.h
dorado/polish/architectures/model_gru.cpp
dorado/polish/architectures/model_gru.h
dorado/polish/architectures/model_latent_space_lstm.cpp
dorado/polish/architectures/model_latent_space_lstm.h
dorado/polish/architectures/model_torch_base.cpp
dorado/polish/architectures/model_torch_base.h
dorado/polish/architectures/model_torch_script.cpp
dorado/polish/architectures/model_torch_script.h
dorado/utils/ssize.h
dorado/utils/span.h
)
enable_warnings_as_errors(dorado_lib)
set_target_properties(dorado_lib
PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
)
target_include_directories(dorado_lib
PUBLIC
${CMAKE_CURRENT_BINARY_DIR}/dorado_generated
${CMAKE_CURRENT_SOURCE_DIR}/dorado
)
# 3rdparty libs should be considered SYSTEM headers
target_include_directories(dorado_lib
SYSTEM
PUBLIC
${DORADO_3RD_PARTY_SOURCE}/argparse
${DORADO_3RD_PARTY_SOURCE}/toml11
${DORADO_3RD_PARTY_SOURCE}/hdf_plugins/vbz_plugin
${DORADO_3RD_PARTY_SOURCE}/cxxpool/src
${DORADO_3RD_PARTY_SOURCE}/NVTX/c/include
${DORADO_3RD_PARTY_SOURCE}/indicators/include
${DORADO_3RD_PARTY_SOURCE}/intervaltree
)
enable_testing()
if(NOT SKIP_HDF_PLUGINS)
# Can skip this if we're consuming the lib from a parent project that already has hdf_plugins
add_hdf_vbz_plugin()
endif()
if (DORADO_ENABLE_PCH)
target_precompile_headers(dorado_lib REUSE_FROM dorado_torch_utils)
endif()
target_link_libraries(dorado_lib
PUBLIC
torch_lib
htslib
edlib
dorado_basecall
dorado_modbase
PRIVATE
minimap2
)
if(NOT WIN32)
add_dependencies(dorado_lib htslib_project)
endif()
if(NOT DORADO_DISABLE_DORADO)
add_executable(dorado
dorado/main.cpp
dorado/cli/aligner.cpp
dorado/cli/basecall_output_args.cpp
dorado/cli/basecall_output_args.h
dorado/cli/demux.cpp
dorado/cli/duplex.cpp
dorado/cli/trim.cpp
dorado/cli/basecaller.cpp
dorado/cli/benchmark.cpp
dorado/cli/download.cpp
dorado/cli/summary.cpp
dorado/cli/correct.cpp
dorado/cli/polish.cpp
dorado/cli/cli.h
dorado/cli/cli_utils.h
dorado/cli/model_resolution.h
)
set_target_properties(dorado
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin"
)
if(MSVC)
set_property(TARGET dorado APPEND PROPERTY LINK_OPTIONS "/ignore:4099")
endif()
enable_warnings_as_errors(dorado)
check_linked_libs(dorado)
if (DORADO_ENABLE_PCH)
target_precompile_headers(dorado REUSE_FROM dorado_lib)
endif()
target_link_libraries(dorado
dorado_lib
dorado_io_lib
dorado_file_info
dorado_models_lib
dorado_model_downloader_lib
dorado_compat
minimap2
)
install(TARGETS dorado RUNTIME)
endif()
if(NOT CMAKE_SYSTEM_NAME STREQUAL "iOS")
add_subdirectory(dorado/data_loader)
add_subdirectory(dorado/file_info)
endif()
add_subdirectory(tests)
include(cmake/InstallRedistLibs.cmake)
if(NOT DORADO_DISABLE_PACKAGING)
include(cmake/DoradoPackaging.cmake)
endif()
# For capturing test coverage.
if (GENERATE_TEST_COVERAGE)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" AND NOT DORADO_DISABLE_TESTS)
include(cmake/CodeCoverage.cmake)
foreach(COVERAGE_TARGET dorado_tests dorado_lib dorado_io_lib dorado_models_lib dorado_torch_utils dorado_utils dorado_file_info)
append_coverage_compiler_flags_to_target(${COVERAGE_TARGET})
endforeach()
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()
# GCC 8 ICEs trying to compile this file with ASAN+optimisations enabled, so knock down the optimisation to try and help it out.
if (ECM_ENABLE_SANITIZERS AND (CMAKE_CXX_COMPILER_ID MATCHES "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0))
set_source_files_properties(dorado/read_pipeline/stereo_features.cpp PROPERTIES COMPILE_OPTIONS "-O0")
endif()