forked from zhou-lab/biscuit
-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
138 lines (119 loc) · 4.59 KB
/
Copy pathCMakeLists.txt
File metadata and controls
138 lines (119 loc) · 4.59 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
# Minimum CMake version
cmake_minimum_required(VERSION 3.21)
# Define BISCUIT version from biscuit.h
file(READ "src/biscuit.h" VER_FILE)
string(REGEX MATCH "#define BISCUIT_VERSION_MAJOR ([0-9]*)" _ ${VER_FILE})
set(VER_MAJOR ${CMAKE_MATCH_1})
string(REGEX MATCH "#define BISCUIT_VERSION_MINOR ([0-9]*)" _ ${VER_FILE})
set(VER_MINOR ${CMAKE_MATCH_1})
string(REGEX MATCH "#define BISCUIT_VERSION_PATCH ([0-9]*)" _ ${VER_FILE})
set(VER_PATCH ${CMAKE_MATCH_1})
# Setup project
project(biscuit
VERSION "${VER_MAJOR}.${VER_MINOR}.${VER_PATCH}"
DESCRIPTION "BISulfite-seq Command line User Interface Toolkit"
HOMEPAGE_URL "https://github.com/huishenlab/biscuit"
LANGUAGES C
)
# Set C standards
set(CMAKE_C_STANDARD 99)
set(CMAKE_C_STANDARD_REQUIRED True)
# Find module paths
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
# Standard installation paths
include(GNUInstallDirs)
# Setup directories used
set(LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib)
set(SCRIPT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/scripts)
# Default build in release mode
# Can be overridden with: cmake -DCMAKE_BUILD_TYPE=Debug
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
# External libraries
include(ExternalProject)
# Utils
ExternalProject_Add(utils
GIT_REPOSITORY https://github.com/huishenlab/utils
GIT_TAG 5f4aeabb42229440a99a5286f8052d3e5dc665cb
DOWNLOAD_DIR ${LIB_DIR}
SOURCE_DIR ${LIB_DIR}/utils
CONFIGURE_COMMAND ""
BUILD_COMMAND make libutils.a
INSTALL_COMMAND ""
BUILD_IN_SOURCE 1
)
# GSL subset
ExternalProject_Add(sgsl
GIT_REPOSITORY https://github.com/huishenlab/sgsl
GIT_TAG 6533277fd490b68b0c664efc168a1f05de54b010
DOWNLOAD_DIR ${LIB_DIR}
SOURCE_DIR ${LIB_DIR}/sgsl
CONFIGURE_COMMAND ""
BUILD_COMMAND make libgsl.a
INSTALL_COMMAND ""
BUILD_IN_SOURCE 1
)
# libdeflate
find_package(LIBDEFLATE)
if(LIBDEFLATE_FOUND)
set(LIBDEFLATE_FLAG "--with-libdeflate")
message(STATUS "found a system libdeflate. will build htslib with libdeflate")
else()
set(LIBDEFLATE_FLAG "--without-libdeflate")
message(STATUS "could not find a system libdeflate. will build htslib without libdeflate")
endif()
# htslib
find_package(CURL REQUIRED)
set(SHA_CHECK ${SCRIPT_DIR}/confirm_download.sh)
set(htslib_version "1.18")
set(htslib_base "htslib-${htslib_version}")
# NOTE: Will make CRAM files potentially unreadable.
# If planning to add CRAM functionality in the future, will need to remove --disable-bz2 and --disable-lzma
if(APPLE)
ExternalProject_Add(htslib
DOWNLOAD_DIR ${LIB_DIR}
DOWNLOAD_COMMAND curl --silent --show-error -k -L https://github.com/samtools/htslib/releases/download/${htslib_version}/${htslib_base}.tar.bz2 -o ${htslib_base}.tar.bz2 &&
echo "Building on macOS, skipping verification" &&
mkdir -p ${htslib_base} &&
tar -jxf ${htslib_base}.tar.bz2 --strip-components=1 -C ${htslib_base} &&
rm -rf htslib &&
mv -f ${htslib_base} htslib
SOURCE_DIR ${LIB_DIR}/htslib
INSTALL_DIR ${LIB_DIR}/install
CONFIGURE_COMMAND ${LIB_DIR}/htslib/configure --prefix=<INSTALL_DIR> --disable-bz2 --disable-lzma --disable-libcurl ${LIBDEFLATE_FLAG}
BUILD_COMMAND make lib-static
INSTALL_COMMAND ""
BUILD_IN_SOURCE 1
)
else()
ExternalProject_Add(htslib
DOWNLOAD_DIR ${LIB_DIR}
DOWNLOAD_COMMAND curl --silent --show-error -k -L https://github.com/samtools/htslib/releases/download/${htslib_version}/${htslib_base}.tar.bz2 -o ${htslib_base}.tar.bz2 &&
${SHA_CHECK} ${htslib_base}.tar.bz2 f1ab53a593a2320a1bfadf4ef915dae784006c5b5c922c8a8174d7530a9af18f &&
mkdir -p ${htslib_base} &&
tar -jxf ${htslib_base}.tar.bz2 --strip-components=1 -C ${htslib_base} &&
rm -rf htslib &&
mv -f ${htslib_base} htslib
SOURCE_DIR ${LIB_DIR}/htslib
INSTALL_DIR ${LIB_DIR}/install
CONFIGURE_COMMAND ${LIB_DIR}/htslib/configure --prefix=<INSTALL_DIR> --disable-bz2 --disable-lzma --disable-libcurl ${LIBDEFLATE_FLAG}
BUILD_COMMAND make lib-static
INSTALL_COMMAND ""
BUILD_IN_SOURCE 1
)
endif(APPLE)
# Include directories
include_directories(${utils_PREFIX} ${sgsl_PREFIX} ${htslib_PREFIX}/htslib)
# Build subcommands
add_subdirectory(${LIB_DIR}/aln)
add_subdirectory(src)
include_directories(${LIB_DIR})
# Install
install(TARGETS biscuit DESTINATION "${CMAKE_INSTALL_BINDIR}")
install(PROGRAMS
${SCRIPT_DIR}/QC.sh
${SCRIPT_DIR}/build_biscuit_QC_assets.pl
${SCRIPT_DIR}/flip_pbat_strands.sh
TYPE BIN
)