-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
70 lines (59 loc) · 2.79 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
# adapted from: https://raymii.org/s/tutorials/Cpp_project_setup_with_cmake_and_unit_tests.html
cmake_minimum_required(VERSION 3.15)
project(varGWAS)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(DEBUG ${CMAKE_BUILD_TYPE} STREQUAL Debug)
# packages
find_package(OpenMP REQUIRED)
find_package(ZLIB)
# include
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib/bgen/genfile/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib/bgen/3rd_party/boost_1_55_0)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib/bgen/3rd_party/zstd-1.1.0/lib)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib/bgen/3rd_party/sqlite3)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib/bgen/db/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib/fast-cpp-csv-parser)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib/eigen-3.4.0)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib/cxxopts-2.2.0/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/lib/spdlog/include)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)
# libraries
find_library(BGEN_LIB_PATH NAMES libbgen.a HINTS ${CMAKE_CURRENT_SOURCE_DIR}/lib/bgen/build)
find_library(ZSTD_LIB_PATH NAMES libzstd.so libzstd.a libzstd.dylib HINTS ${CMAKE_CURRENT_SOURCE_DIR}/lib/bgen/build/3rd_party/zstd-1.1.0)
find_library(SQLITE_LIB_PATH NAMES libsqlite3.a HINTS ${CMAKE_CURRENT_SOURCE_DIR}/lib/bgen/build/3rd_party/sqlite3)
find_library(DB_LIB_PATH NAMES libdb.a HINTS ${CMAKE_CURRENT_SOURCE_DIR}/lib/bgen/build/db)
find_library(SPDLOG_LIB_PATH NAMES libspdlog.a HINTS ${CMAKE_CURRENT_SOURCE_DIR}/lib/spdlog/build)
set(LIBS
${BGEN_LIB_PATH}
ZLIB::ZLIB
OpenMP::OpenMP_CXX
${ZSTD_LIB_PATH}
${SQLITE_LIB_PATH}
${DB_LIB_PATH}
${SPDLOG_LIB_PATH}
)
# src
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/src)
# build tests & configure for performance profiling if in debug mode
if (${DEBUG})
message("Building in DEBUG mode")
# adding test libs
message("Building tests")
enable_testing()
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/test)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/googletest-release-1.10.0)
# To make sure none of the frames are missing due to inlining
message("Setting flags for performance profiling")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0")
# compilers can use the frame pointer register as a general-purpose register for optimization purposes
# which may lead to broken stack traces
if (APPLE)
if (${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
message("Adding flags for GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-omit-frame-pointer")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} -fno-omit-frame-pointer")
endif ()
endif ()
endif ()