-
Notifications
You must be signed in to change notification settings - Fork 39
/
CMakeLists.txt
118 lines (98 loc) · 3.13 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
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
cmake_minimum_required(VERSION 3.11 FATAL_ERROR)
project(mashmap VERSION 3.0.0)
include(GNUInstallDirs)
include(CheckCXXCompilerFlag)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON) # Falling back to different standard it not allowed.
set(CMAKE_CXX_EXTENSIONS OFF) # Make sure no compiler-specific features are used.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
#set(CMAKE_BUILD_TYPE Release)
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: Release Debug Generic." FORCE)
endif()
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
option(SKIP_VERSION_FILE "Do not create src/mashmap_git_version.hpp" OFF)
option(OPTIMIZE_FOR_NATIVE "Build with -march=native" ON)
option(LARGE_CONTIG "Use 64-bit integers instead of 32 bit for sequence coordinates" OFF)
if (LARGE_CONTIG)
add_definitions(-DLARGE_CONTIG)
endif()
option(USE_HTSLIB "Compile with htslib for --targetPrefix and --targetList" OFF)
if (USE_HTSLIB)
add_definitions(-DUSE_HTSLIB)
find_package(PkgConfig)
pkg_check_modules(HTSLIB REQUIRED IMPORTED_TARGET htslib)
endif()
option(PROFILE "Prevent inlining and add debug symbols" OFF)
if (${CMAKE_BUILD_TYPE} MATCHES Release)
if (OPTIMIZE_FOR_NATIVE)
set(EXTRA_FLAGS "${EXTRA_FLAGS} -march=native")
endif ()
if (PROFILE)
set(EXTRA_FLAGS "${EXTRA_FLAGS} -g -fno-inline")
endif()
endif ()
if (${CMAKE_BUILD_TYPE} MATCHES Debug)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O -g")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O -g")
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
else()
# Use all standard-compliant optimizations - always add these:
set (CMAKE_C_FLAGS "${OpenMP_C_FLAGS} ${PIC_FLAG} ${EXTRA_FLAGS}")
set (CMAKE_CXX_FLAGS "${OpenMP_CXX_FLAGS} ${PIC_FLAG} ${EXTRA_FLAGS}")
endif ()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
add_compile_options(-Wfatal-errors)
#include(FetchContent)
#FetchContent_Declare(
#assert
#URL https://github.com/jeremy-rifkin/libassert/archive/refs/tags/v1.1.tar.gz
#)
#FetchContent_MakeAvailable(assert)
add_executable(mashmap
src/common/utils.cpp
src/map/mash_map.cpp)
add_executable(mashmap-align
src/common/utils.cpp
src/align/align.cpp)
target_include_directories(mashmap PRIVATE
src
src/common
)
target_include_directories(mashmap-align PRIVATE
src
src/common
)
if (USE_HTSLIB)
target_link_libraries(mashmap PkgConfig::HTSLIB)
target_link_libraries(mashmap-align PkgConfig::HTSLIB)
endif()
target_link_libraries(mashmap
gsl
gslcblas
m
pthread
#rt
z
#assert
)
target_link_libraries(mashmap-align
gsl
gslcblas
m
pthread
#rt
z
#assert
)
install(TARGETS mashmap DESTINATION bin)
install(TARGETS mashmap-align DESTINATION bin)
# version stuff
if (NOT SKIP_VERSION_FILE)
file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/include)
execute_process(COMMAND bash ${CMAKE_SOURCE_DIR}/scripts/generate_git_version.sh ${CMAKE_SOURCE_DIR}/src)
endif ()