-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
125 lines (101 loc) · 4.87 KB
/
Copy pathCMakeLists.txt
File metadata and controls
125 lines (101 loc) · 4.87 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
cmake_minimum_required(VERSION 3.10)
# project and version
project(fastx LANGUAGES CXX C VERSION 0.4.3)
include_directories(vendor/htslib)
# PROJECT_BINARY_DIR default is the build dir
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
configure_file(src/version.hpp.in version.hpp)
include_directories(${CMAKE_CURRENT_BINARY_DIR})
if (NOT EXISTS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
execute_process(COMMAND mkdir -p ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
endif (NOT EXISTS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
if (NOT EXISTS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
execute_process(COMMAND mkdir -p ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
endif (NOT EXISTS ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
# CXX configure
if (CMAKE_BUILD_TYPE STREQUAL Debug)
message(STATUS "[STATUS]: Build Debug")
set(CMAKE_CXX_FLAGS "--std=c++17 -g -Wall -Wextra -pedantic")
elseif (CMAKE_BUILD_TYPE STREQUAL Release)
message(STATUS "[STATUS]: Build Release")
set(CMAKE_CXX_FLAGS "--std=c++17 -g -O3 -Wall -Wextra -pedantic -DNDEBUG")
endif ()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
set(MAKE_JOBS 4 CACHE STRING "number of jobs for run make in this cmake list")
set(USE_LIBDEFLATE ON CACHE STRING "if use libdeflate in htslib?")
# libdeflate library and include files in vendor
set(LIBDEFLATE ${CMAKE_CURRENT_SOURCE_DIR}/vendor/libdeflate)
set(LIBDEFLATE_LIB ${CMAKE_CURRENT_SOURCE_DIR}/vendor/libdeflate/libdeflate.so)
if (${USE_LIBDEFLATE})
if (NOT EXISTS ${LIBDEFLATE})
message(FATAL_ERROR "[FATAL_ERROR]: Can not find libdeflate directory in \
${CMAKE_CURRENT_SOURCE_DIR}/vendor, Please check vendor directory \
for existence of libdeflate.")
endif (NOT EXISTS ${LIBDEFLATE})
endif (${USE_LIBDEFLATE})
if (${USE_LIBDEFLATE})
if (EXISTS ${LIBDEFLATE_LIB})
message(STATUS "[STATUS]: Find libdeflate library libdeflate.so")
else (EXISTS ${LIBDEFLATE_LIB})
message(STATUS "[STATUS]: libdeflate library libdeflate.so not exist in \
${CMAKE_CURRENT_SOURCE_DIR}/vendor/libdeflate, build one ...")
execute_process(COMMAND make -j ${MAKE_JOBS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/vendor/libdeflate)
endif (EXISTS ${LIBDEFLATE_LIB})
execute_process(COMMAND cp ${LIBDEFLATE}/libdeflate.a ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
execute_process(COMMAND cp ${LIBDEFLATE}/libdeflate.so ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
execute_process(COMMAND cp ${LIBDEFLATE}/libdeflate.so.0 ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
endif (${USE_LIBDEFLATE})
# htslib library and include files in vendor
set(HTSLIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/vendor/htslib)
set(HTSLIB_LIB ${CMAKE_CURRENT_SOURCE_DIR}/vendor/htslib/libhts.so)
if (NOT EXISTS ${HTSLIB_DIR})
message(FATAL_ERROR "[FATAL_ERROR]: Can not find htslib directory in \
${CMAKE_CURRENT_SOURCE_DIR}/vendor/htslib, Please check vendor directory \
for existence of htslib.")
endif (NOT EXISTS ${HTSLIB_DIR})
if (EXISTS ${HTSLIB_LIB})
message(STATUS "[STATUS]: Find htslib shared library libhts.so")
else (EXISTS ${HTSLIB_LIB})
message(STATUS "[STATUS]: htslib shared library libhts.so not exist in ${HTSLIB_DIR}, build one ...")
execute_process(COMMAND autoheader WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/vendor/htslib)
execute_process(COMMAND autoconf WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/vendor/htslib)
if (${USE_LIBDEFLATE})
execute_process(COMMAND bash -c "./configure CPPFLAGS=-I${LIBDEFLATE} LDFLAGS='-L${CMAKE_LIBRARY_OUTPUT_DIRECTORY} -Wl,-R${CMAKE_LIBRARY_OUTPUT_DIRECTORY}' --with-libdeflate" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/vendor/htslib)
else (${USE_LIBDEFLATE})
execute_process(COMMAND bash -c "./configure" WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/vendor/htslib)
endif (${USE_LIBDEFLATE})
execute_process(COMMAND make -j ${MAKE_JOBS} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/vendor/htslib)
execute_process(COMMAND cp ${HTSLIB_LIB} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
execute_process(COMMAND cp ${HTSLIB_LIB}.3 ${CMAKE_LIBRARY_OUTPUT_DIRECTORY})
endif (EXISTS ${HTSLIB_LIB})
set(ZLIB_COMPAT ON)
set(WITH_GTEST OFF)
add_subdirectory(vendor/zlib-ng)
add_executable(fastx
src/utils.cpp
src/kseq_utils.cpp
src/fastx_cmp.cpp
src/fastx_head.cpp
src/fastx_sample.cpp
src/fastx_split.cpp
src/fastx_subseq.cpp
src/fastx.cpp)
target_include_directories(fastx PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/vendor/htslib
)
target_link_libraries(fastx
${HTSLIB_LIB}
zlibstatic m bz2 lzma pthread curl)
add_executable(test_reader
src/utils.cpp
src/kseq_utils.cpp
src/test_seq_reader.cpp)
target_include_directories(test_reader PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}/vendor/htslib
)
target_link_libraries(test_reader
${HTSLIB_LIB}
zlibstatic m bz2 lzma pthread curl)