| 1 |
cmake_minimum_required(VERSION 3.2) |
| 2 |
include(ExternalProject) |
| 3 |
|
| 4 |
IF(NOT CMAKE_BUILD_TYPE) |
| 5 |
SET(CMAKE_BUILD_TYPE Release CACHE STRING |
| 6 |
"Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." |
| 7 |
FORCE) |
| 8 |
ENDIF(NOT CMAKE_BUILD_TYPE) |
| 9 |
|
| 10 |
project(iitii) |
| 11 |
INCLUDE(ExternalProject) |
| 12 |
include_directories(${PROJECT_SOURCE_DIR}/..) |
| 13 |
|
| •14 |
if(!DEBIAN_BUILD) |
| 15 |
# After build, double-check external/src/htslib-stamp/htslib-build-out.log |
| 16 |
# to make sure CFLAGS were set as expected |
| 17 |
ExternalProject_Add(htslib |
| 18 |
URL https://github.com/samtools/htslib/releases/download/1.9/htslib-1.9.tar.bz2 |
| 19 |
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external |
| 20 |
CONFIGURE_COMMAND "" |
| 21 |
PATCH_COMMAND sed -i "s/^CFLAGS .*$/CFLAGS = -gdwarf -O3 -DNDEBUG/" Makefile |
| 22 |
BUILD_IN_SOURCE 1 |
| 23 |
BUILD_COMMAND bash -c "make -n && make -j$(nproc)" |
| 24 |
INSTALL_COMMAND "" |
| 25 |
LOG_DOWNLOAD ON |
| 26 |
LOG_BUILD ON |
| 27 |
) |
| 28 |
ExternalProject_Get_Property(htslib source_dir) |
| 29 |
set(HTSLIB_INCLUDE_DIR ${source_dir}/htslib) |
| 30 |
include_directories(${HTSLIB_INCLUDE_DIR}) |
| 31 |
ExternalProject_Get_Property(htslib binary_dir) |
| 32 |
add_library(libhts STATIC IMPORTED) |
| 33 |
set(LIBHTS_A ${binary_dir}/libhts.a) |
| 34 |
set_property(TARGET libhts PROPERTY IMPORTED_LOCATION ${LIBHTS_A}) |
| 35 |
|
| 36 |
ExternalProject_Add(CTPL |
| 37 |
URL https://github.com/vit-vit/CTPL/archive/v.0.0.2.zip |
| 38 |
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external |
| 39 |
CONFIGURE_COMMAND "" |
| 40 |
BUILD_IN_SOURCE 1 |
| 41 |
BUILD_COMMAND "" |
| 42 |
INSTALL_COMMAND "" |
| 43 |
LOG_DOWNLOAD ON |
| 44 |
) |
| 45 |
ExternalProject_Get_Property(CTPL source_dir) |
| 46 |
set(CTPL_INCLUDE_DIR ${source_dir}) |
| 47 |
include_directories(${CTPL_INCLUDE_DIR}) |
| •48 |
else() |
| 49 |
include_directories(/usr/include/htslib) |
| 50 |
endif() |
| 51 |
|
| 52 |
ExternalProject_Add(catch |
| 53 |
URL https://github.com/philsquared/Catch/archive/v2.9.1.zip |
| 54 |
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/external |
| 55 |
CONFIGURE_COMMAND "" |
| 56 |
BUILD_COMMAND "" |
| 57 |
INSTALL_COMMAND "" |
| 58 |
LOG_DOWNLOAD ON |
| 59 |
) |
| 60 |
ExternalProject_Get_Property(catch source_dir) |
| 61 |
include_directories(${source_dir}/single_include) |
| 62 |
|
| 63 |
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread -std=c++17 -Wall -Werror=return-type -Wno-reorder -fdiagnostics-color=auto") |
| 64 |
|
| 65 |
add_executable(test_iitii util.h test_iitii.cc) |
| •66 |
find_package(PkgConfig REQUIRED) |
| 67 |
pkg_search_module(GLIB REQUIRED glib-2.0) |
| 68 |
include_directories(${GLIB_INCLUDE_DIRS}) |
| 69 |
include_directories("../src") ## FIXME: for autopkgtest this line has to be removed |
| 70 |
## target_link_libraries(test_iitii ${GLIB_LDFLAGS}) |
| 71 |
#add_dependencies(test_iitii catch libhts) |
| 72 |
target_link_libraries(test_iitii libhts libz.a libbz2.a liblzma.a) |
| 73 |
|
| 74 |
add_executable(dumb_benchmark util.h dumb_benchmark.cc) |
| •75 |
#add_dependencies(dumb_benchmark libhts) |
| 76 |
target_link_libraries(dumb_benchmark libhts libz.a libbz2.a liblzma.a) |
| 77 |
|
| 78 |
add_executable(gnomad_benchmark util.h gnomad_benchmark.cc) |
| •79 |
# add_dependencies(gnomad_benchmark libhts) |
| 80 |
target_link_libraries(gnomad_benchmark libhts libz.a libbz2.a liblzma.a) |
| 81 |
|
| 82 |
include(CTest) |
| 83 |
add_test(NAME unit_tests COMMAND bash -c "LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libjemalloc.so ./test_iitii -d yes") |