File: CMakeLists.txt

package info (click to toggle)
bowtie2 2.4.2-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, sid
  • size: 27,104 kB
  • sloc: cpp: 60,331; perl: 7,540; sh: 1,111; python: 949; makefile: 520; ansic: 122
file content (323 lines) | stat: -rw-r--r-- 10,261 bytes parent folder | download | duplicates (2)
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
cmake_minimum_required(VERSION 2.8)

cmake_policy(SET CMP0048 NEW)
cmake_policy(SET CMP0005 NEW)

file(STRINGS ${CMAKE_SOURCE_DIR}/BOWTIE2_VERSION PROJECT_VERSION)
project(bowtie2 LANGUAGES CXX VERSION ${PROJECT_VERSION})

enable_testing()

include(CTest)
include(ExternalProject)
include(ProcessorCount)
include(CheckSymbolExists)

ProcessorCount(NUM_CORES)

option(BOWTIE_MM "enable bowtie2 memory mapping" ON)
option(BOWITE_SHARED_MM "enable shared memory mapping" ON)

set(NO_TBB ${NO_TBB})
set(NO_SPINLOCK ${NO_SPINLOCK})
set(USE_SRA ${USE_SRA})
set(WITH_THREAD_PROFILING ${WITH_THREAD_PROFILING})
set(NO_POPCNT_CAPABILITY ${NO_POPCNT_CAPABILITY})
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
set(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -m64 -g3 -Wall -msse2")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -O3 -funroll-loops")
set(INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")

set(CMAKE_EXPORT_COMPILE_COMMANDS on)

if (MINGW)
  option(BOWTIE_MM "Memory mapped files not supported on Windows" OFF)
  option(BOWTIE_SHARED_MEM "Shared memory not supported on Windows" OFF)
endif(MINGW)

if (APPLE)
  set(CMAKE_XCODE_ATTRIBUTE_DEBUG_INFORMATION_FORMAT "dwarf-with-dsym")
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif(APPLE)

set(BOWTIE2_BIN_LIST
  bowtie2-build-s
  bowtie2-build-l
  bowtie2-align-s
  bowtie2-align-l
  bowtie2-inspect-s
  bowtie2-inspect-l
  )

set(BOWTIE2_WRAPPER_SCRIPTS
  bowtie2
  bowtie2-build
  bowtie2-inspect
  )

set(SHARED_CPPS
  ccnt_lut.cpp
  ref_read.cpp
  alphabet.cpp
  shmem.cpp
  edit.cpp
  bt2_idx.cpp
  bt2_io.cpp
  bt2_util.cpp
  reference.cpp
  ds.cpp
  multikey_qsort.cpp
  limit.cpp
  random_source.cpp
  )

set(SEARCH_CPPS
  qual.cpp pat.cpp sam.cpp
  read_qseq.cpp aligner_seed_policy.cpp
  aligner_seed.cpp
  aligner_seed2.cpp
  aligner_sw.cpp
  aligner_sw_driver.cpp aligner_cache.cpp
  aligner_result.cpp ref_coord.cpp mask.cpp
  pe.cpp aln_sink.cpp dp_framer.cpp
  scoring.cpp presets.cpp unique.cpp
  simple_func.cpp
  random_util.cpp
  aligner_bt.cpp sse_util.cpp
  aligner_swsse.cpp outq.cpp
  aligner_swsse_loc_i16.cpp
  aligner_swsse_ee_i16.cpp
  aligner_swsse_loc_u8.cpp
  aligner_swsse_ee_u8.cpp
  aligner_driver.cpp
  bowtie_main.cpp
  bt2_search.cpp
  )

set(BUILD_CPPS
  bt2_build.cpp
  diff_sample.cpp
  bowtie_build_main.cpp)

set(INSPECT_CPPS
  bt2_inspect.cpp
  )

string(TIMESTAMP BUILD_DATE)
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -v OUTPUT_VARIABLE COMPILER_VERSION)

add_definitions(
  -DBOWTIE2
  -DBUILD_HOST="${CMAKE_HOST_SYSTEM}"
  -DBUILD_TIME="${BUILD_DATE}"
  -DCOMPILER_VERSION="${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_VERSION}"
  -DBOWTIE2_VERSION="${PROJECT_VERSION}"
  -D_LARGEFILE_SOURCE
  -D_FILE_OFFSET_BITS=64
  -D_GNU_SOURCE
  )

if (WITH_AFFINITY)
  add_definitions(-DWITH_AFFINITY=1)
endif()

if (NO_SPINLOCK)
  add_definitions(-DNO_SPINLOCK)
endif()

if (NOT NO_POPCNT_CAPABILITY)
  add_definitions(-DPOPCNT_CAPABILITY)
  set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I third_party")
endif()

if (USE_SRA)
  set(NGS_VER 2.9.2)
  set(NCBI_VDB_VER 2.9.2-1)

  find_package(Java COMPONENTS Development REQUIRED)
  find_package(PythonInterp REQUIRED)
  find_package(Perl REQUIRED)

  find_program(MAKE_EXE NAMES gmake nmake make)
  ExternalProject_add(ngs_project
    URL https://github.com/ncbi/ngs/archive/${NGS_VER}.tar.gz
    PREFIX ${CMAKE_CURRENT_BINARY_DIR}/ngs-${NGS_VER}
    BUILD_IN_SOURCE 1
    CONFIGURE_COMMAND ./configure --prefix=install
    BUILD_COMMAND ${MAKE_EXE}
    INSTALL_COMMAND ${MAKE_EXE} install
    )

  ExternalProject_Get_Property(ngs_project SOURCE_DIR)
  set(NGS_INSTALL_DIR ${SOURCE_DIR}/ngs-sdk/install)

  link_directories(${NGS_INSTALL_DIR}/lib64)
  include_directories(${NGS_INSTALL_DIR}/include)

  add_library(ngs-c++-static STATIC IMPORTED)
  add_dependencies(ngs-c++-static ngs_project)
  find_library(LIBNGS_CPP ngs-c++-static PATHS ${NGS_INSTALL_DIR}/lib64 NO_DEFAULT_PATH)
  set_property(TARGET ngs-c++-static PROPERTY IMPORTED_LOCATION ${LIBNGS_CPP})

  link_libraries(ngs-c++-static)

  ExternalProject_add(ncbi_vdb_project
    URL https://github.com/ncbi/ncbi-vdb/archive/${NCBI_VDB_VER}.tar.gz
    PREFIX ${CMAKE_CURRENT_BINARY_DIR}/ncbi-vdb-${NCBI_VDB_VER}
    BUILD_IN_SOURCE 1
    CONFIGURE_COMMAND ./configure --prefix=install --with-ngs-sdk=${NGS_INSTALL_DIR}
    BUILD_COMMAND ${MAKE_EXE}
    INSTALL_COMMAND ${MAKE_EXE} install
    DEPENDS ngs_project
    )

  ExternalProject_Get_Property(ncbi_vdb_project SOURCE_DIR)
  set(NCBI_VDB_INSTALL_DIR ${SOURCE_DIR}/install)

  link_directories(${NCBI_VDB_INSTALL_DIR}/lib64)
  include_directories(${NCBI_VDB_INSTALL_DIR}/include)

  add_library(ncbi-ngs-c++-static STATIC IMPORTED)
  add_dependencies(ncbi-ngs-c++-static ncbi_vdb_project)
  find_library(LIBNCBI_NGS_CPP ncbi-ngs-c++-static PATHS ${NCBI_VDB_INSTALL_DIR}/lib64 NO_DEFAULT_ATH)
  set_property(TARGET ncbi-ngs-c++-static PROPERTY IMPORTED_LOCATION ${LIBNCBI_NGS_CPP})

  add_library(ncbi-vdb-static STATIC IMPORTED)
  add_dependencies(ncbi-vdb-static ncbi_vdb_project)
  find_library(LIBNCBI_VDB ncbi-vdb-static PATHS ${NCBI_VDB_INSTALL_DIR}/lib64 NO_DEFAULT_PATH)
  set_property(TARGET ncbi-vdb-static PROPERTY IMPORTED_LOCATION ${LIBNCBI_VDB})

  link_libraries(ncbi-ngs-c++-static ncbi-vdb-static)
  add_definitions(-DUSE_SRA)
endif()

if (WITH_THREAD_PROFILING)
  add_definitions(-DPER_THREAD_TIMING=1)
endif()

if (CMAKE_BUILD_TYPE STREQUAL "Release")
  add_definitions(-DNDEBUG)
endif()

find_package(ZLIB REQUIRED)


find_package(Threads REQUIRED)
link_libraries(Threads::Threads)

if (NO_TBB)
  set(SHARED_CPPS ${SHARED_CPPS} tinythread.cpp)
else()
  find_library(TBB_LIB_PATH tbb)
  if (TBB_LIB_PATH)
    find_path(TBB_INCLUDE_PATH tbb/tbb.h)
    link_libraries(${TBB_LIB_PATH})
    find_library(TBBMALLOC_PROXY_LIB_PATH tbbmalloc_proxy)
    if (NOT TBBMALLOC_PROXY_LIB_PATH)
      find_library(TBBMALLOC_LIB_PATH tbbmalloc)
      link_libraries(${TBBMALLOC_LIB_PATH})
    else()
      link_libraries(${TBBMALLOC_PROXY_LIB_PATH})
    endif()
    include_directories(${TBB_INCLUDE_PATH})
  else()
    set(TBB_VER 2019_U4)

    if (CMAKE_SYSTEM_NAME STREQUAL Linux)
      set(tbb_os linux)
    elseif (CMAKE_SYSTEM_NAME STREQUAL Darwin)
      set(tbb_os macos)
    elseif (CMAKE_SYSTEM_NAME STREQUAL Windows)
      set(tbb_os windows)
    else()
      set(tbb_os ${CMAKE_SYSTEM_NAME})
    endif()

    find_program(MAKE_EXE NAMES gmake nmake make)
    ExternalProject_Add(tbb_project
      URL https://github.com/01org/tbb/archive/2019_U4.tar.gz
      PREFIX ${CMAKE_CURRENT_BINARY_DIR}/tbb-${TBB_VER}
      BUILD_IN_SOURCE 1
      CONFIGURE_COMMAND ""
      BUILD_COMMAND ${MAKE_EXE} tbb_build_prefix=${TBB_VER} tbb_os=${tbb_os}
      INSTALL_COMMAND ""
      PREFIX=${CMAKE_CURRENT_BINARY_DIR}/tbb_project
      )

    ExternalProject_Get_Property(tbb_project SOURCE_DIR)
    set(TBB_SOURCE_DIR ${SOURCE_DIR})
    set(TBB_RELEASE_DIR ${TBB_SOURCE_DIR}/build/${TBB_VER}_release)
    include_directories(${TBB_SOURCE_DIR}/include)
    find_path(TBB_INCLUDE_PATH PATHS ${TBB_SOURCE_DIR}/include NAMES tbb/tbb.h)

    link_directories(${TBB_RELEASE_DIR})
    add_library(tbb SHARED IMPORTED)
    add_dependencies(tbb tbb_project)
    find_library(LIBTBB tbb PATHS ${TBB_RELEASE_DIR} NO_DEFAULT_PATH)
    set_property(TARGET tbb PROPERTY IMPORTED_LOCATION ${LIBTBB})

    add_library(tbbmalloc_proxy SHARED IMPORTED)
    add_dependencies(tbbmalloc_proxy tbb_project)
    find_library(LIBTBBMALLOC_PROXY tbbmalloc_proxy PATHS ${TBB_RELEASE_DIR} NO_DEFAULT_PATH)
    if (NOT LIBTBBMALLOC_PROXY)
      add_library(tbbmalloc SHARED IMPORTED)
      add_dependencies(tbbmalloc tbb_project)
      find_library(LIBTBBMALLOC tbbmalloc PATHS ${TBB_RELEASE_DIR} NO_DEFAULT_PATH)
      set_property(TARGET tbbmalloc PROPERTY IMPORTED_LOCATION ${LIBTBBMALLOC})
      link_libraries(tbb tbbmalloc)
    else()
      set_property(TARGET tbbmalloc_proxy PROPERTY IMPORTED_LOCATION ${LIBTBBMALLOC_PROXY})
      link_libraries(tbb tbbmalloc_proxy)
    endif()
  endif()
  add_definitions(-DWITH_TBB -DWITH_QUEUELOCK=1 -DNO_SPINLOCK)
endif()

if (ZLIB_FOUND)
  link_libraries(${ZLIB_LIBRARIES})
  include_directories(${ZLIB_INCLUDE_DIRS})
endif()

include_directories(${PROJECT_SOURCE_DIR})
get_directory_property(COMPILER_DEFS COMPILE_DEFINITIONS)
string(REGEX REPLACE "-fdebug-prefix-map=[^ ]* " "" COMP_OPTS ${CMAKE_CXX_FLAGS})
string(REGEX REPLACE "-ffile-prefix-map=[^ ]* " "" COMP_OPTS ${COMP_OPTS})
add_definitions(-DCOMPILER_OPTIONS="${COMP_OPTS}")

add_executable(bowtie2-align-s ${SEARCH_CPPS} ${SHARED_CPPS})
add_executable(bowtie2-align-l ${SEARCH_CPPS} ${SHARED_CPPS})
add_executable(bowtie2-build-s ${BUILD_CPPS} ${SHARED_CPPS})
add_executable(bowtie2-build-l ${BUILD_CPPS} ${SHARED_CPPS})
add_executable(bowtie2-inspect-s ${INSPECT_CPPS} ${SHARED_CPPS})
add_executable(bowtie2-inspect-l ${INSPECT_CPPS} ${SHARED_CPPS})

set_target_properties(bowtie2-align-l bowtie2-build-l bowtie2-inspect-l PROPERTIES COMPILE_FLAGS "-DBOWTIE2_64BIT_INDEX")
set_target_properties(bowtie2-inspect-s bowtie2-inspect-l PROPERTIES COMPILE_FLAGS "-DBOWTIE_INSPECT_MAIN")
# set_target_properties(${BOWTIE2_BIN_LIST} PROPERTIES DEBUG_POSTFIX -debug)

install(TARGETS ${BOWTIE2_BIN_LIST} DESTINATION bin)
install(FILES ${BOWTIE2_WRAPPER_SCRIPTS}
  PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
  DESTINATION bin)
if (LIBTBB)
  install(FILES ${LIBTBB} DESTINATION lib)
  install(DIRECTORY ${TBB_INCLUDE_PATH} DESTINATION include)
endif()
if (LIBTBBMALLOC)
  install(FILES ${LIBTBBMALLOC} DESTINATION lib)
endif()
if (LIBTBBMALLOC_PROXY)
  install(FILES ${LIBTBBMALLOC_PROXY} DESTINATION lib)
endif()

add_test(NAME simple-align
  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
  COMMAND bowtie2 -x example/index/lambda_virus example/reads/longreads.fq -u 10)
add_test(NAME simple-build
  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
  COMMAND bowtie2-build-s -c GGGCGGCGACCTCGCGGGTTTTCGCTA out)
add_test(NAME simple-inspect
  WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
  COMMAND bowtie2-inspect-s out && rm out*)