-
Notifications
You must be signed in to change notification settings - Fork 36
/
CMakeLists.txt
85 lines (68 loc) · 2.13 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
cmake_minimum_required(VERSION 3.10)
project(seqlib)
# Set the C++ standard required for the project
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
# Set O2 optimization
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
# Include directories for headers
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/fermi-lite
${CMAKE_CURRENT_SOURCE_DIR}/bwa
)
# Look for htslib on the system
find_package(htslib QUIET)
# Find required system level type libraries
find_package(Threads REQUIRED)
find_package(ZLIB REQUIRED)
## LZMA
find_path(LZMA_INCLUDE_DIR NAMES lzma.h)
find_library(LZMA_LIBRARY NAMES lzma)
if(NOT LZMA_INCLUDE_DIR OR NOT LZMA_LIBRARY)
message(FATAL_ERROR "LZMA library or headers not found!")
endif()
## BZip2
find_package(BZip2 REQUIRED)
## HTSLIB
if (htslib_FOUND)
# If htslib was found on the system, use it
message(STATUS "Using system htslib")
else()
set(HTSLIB_DIR "" CACHE PATH "Path to HTSLib root directory")
if (NOT HTSLIB_DIR)
message(FATAL_ERROR "HTSLIB_DIR not specified. Please specify -DHTSLIB_DIR=/path/to/htslib")
else()
# Automatically set include and library paths based on HTSLIB_DIR
include_directories(${HTSLIB_DIR}/include)
link_directories(${HTSLIB_DIR}/lib)
endif()
endif()
# Find all source files
file(GLOB SOURCES "src/*.cpp" "src/*.c")
# Generate the executable
add_library(seqlib ${SOURCES})
# If the submodules already have Makefiles, you can use custom commands to invoke make
# in those directories.
add_custom_target(
BuildBWA ALL
COMMAND make
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/bwa
)
add_custom_target(
BuildFermiLite ALL
COMMAND make
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/fermi-lite
)
# If MyProject depends on the submodules, you might want to ensure they're built first
add_dependencies(seqlib BuildBWA BuildFermiLite)
target_link_libraries(seqlib
${CMAKE_CURRENT_SOURCE_DIR}/bwa/libbwa.a
${CMAKE_CURRENT_SOURCE_DIR}/fermi-lite/libfml.a
Threads::Threads
ZLIB::ZLIB
hts
${LZMA_LIBRARY}
BZip2::BZip2
)