forked from pirovc/ganon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
executable file
·165 lines (122 loc) · 5.56 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
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
# =============================================================================
# ganon
# =============================================================================
cmake_minimum_required( VERSION 3.10 FATAL_ERROR )
project( ganon VERSION 0.4.0 LANGUAGES CXX )
# -----------------------------------------------------------------------------
# build setup
# -----------------------------------------------------------------------------
set( CMAKE_CXX_STANDARD 17 )
set( CMAKE_CXX_STANDARD_REQUIRED ON )
set( CMAKE_CXX_EXTENSIONS OFF )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR} )
if( NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang|GNU" )
message( FATAL_ERROR
"Compiler id '${CMAKE_CXX_COMPILER_ID}' is not supported, please \
check the documentation." )
endif()
option( VERBOSE_CONFIG "Verbose mode for quick build setup debugging" OFF )
option( GANON_OFFSET "Enable offset for ganon-classify" ON )
option( CONDA "Flag for compilation in conda env." OFF )
option( INCLUDE_DIRS "Include directories to look for libraries" "" )
# -----------------------------------------------------------------------------
# build types
# -----------------------------------------------------------------------------
get_property( isMultiConfig GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG )
if( isMultiConfig )
if( NOT "Coverage" IN_LIST CMAKE_CONFIGURATION_TYPES )
list( APPEND CMAKE_CONFIGURATION_TYPES Coverage )
endif()
else()
set( allowableBuildTypes Debug Release RelWithDebInfo MinSizeRel Coverage )
set_property( CACHE CMAKE_BUILD_TYPE
PROPERTY STRINGS "${allowableBuildTypes}" )
if( NOT CMAKE_BUILD_TYPE )
set( CMAKE_BUILD_TYPE Release CACHE STRING "" FORCE )
elseif( NOT CMAKE_BUILD_TYPE IN_LIST allowableBuildTypes )
message( FATAL_ERROR "Invalid build type: ${CMAKE_BUILD_TYPE}" )
endif()
endif()
# Release flags:
set( CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG" )
# Coverage flags:
set( CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_CXX_FLAGS_DEBUG} -O0 --coverage" )
set( CMAKE_EXE_LINKER_FLAGS_COVERAGE
"${CMAKE_EXE_LINKER_FLAGS_DEBUG} -lgcov --coverage" )
set( CMAKE_SHARED_LINKER_FLAGS_COVERAGE "${CMAKE_SHARED_LINKER_FLAGS_DEBUG}" )
set( CMAKE_STATIC_LINKER_FLAGS_COVERAGE "${CMAKE_STATIC_LINKER_FLAGS_DEBUG}" )
set( CMAKE_MODULE_LINKER_FLAGS_COVERAGE "${CMAKE_MODULE_LINKER_FLAGS_DEBUG}" )
# warning flags:
add_compile_options( -Wall -Wextra -Wshadow -Wuninitialized -Wnon-virtual-dtor
-Wold-style-cast -Wcast-align -Wunused -Woverloaded-virtual -Wpedantic
-Wno-conversion -Wno-sign-conversion -Wnull-dereference -Wdouble-promotion
-Wformat=2 -Wstrict-aliasing -Wno-long-long -Wno-variadic-macros )
if( CMAKE_CXX_COMPILER_ID MATCHES "GNU" )
add_compile_options( -Wmisleading-indentation -Wduplicated-cond
-Wduplicated-branches -Wlogical-op -Wuseless-cast )
endif()
# seqan specific flags:
if ( NOT CONDA )
add_compile_options( -static -march=native )
endif()
# Enable offset:
if( GANON_OFFSET )
add_compile_options(-DGANON_OFFSET)
endif()
# -----------------------------------------------------------------------------
# dependencies and 3rd party libraries
# -----------------------------------------------------------------------------
# 1. threads:
find_package( Threads REQUIRED )
# 2. cxxopts:
add_library( cxxopts INTERFACE )
if( INCLUDE_DIRS )
target_include_directories( cxxopts SYSTEM INTERFACE ${INCLUDE_DIRS} )
else()
target_include_directories( cxxopts SYSTEM INTERFACE libs/cxxopts/include )
endif()
# 3. sdsl-lite:
add_library( sdsl-lite INTERFACE )
target_include_directories( sdsl-lite SYSTEM INTERFACE libs/sdsl-lite/include )
# 4. Zlib (optional for SeqAn):
find_package( ZLIB )
# 5. SeqAn:
set( SEQAN_INCLUDE_PATH libs/seqan/include )
find_package( SeqAn CONFIG REQUIRED PATHS libs/seqan/util/cmake )
add_library( seqan INTERFACE )
target_include_directories( seqan SYSTEM INTERFACE ${SEQAN_INCLUDE_DIRS} )
target_link_libraries( seqan INTERFACE ${SEQAN_LIBRARIES} )
add_compile_options( ${SEQAN_DEFINITIONS} )
set( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SEQAN_CXX_FLAGS}" )
# 6. Catch2:
add_library( Catch2 INTERFACE )
if( INCLUDE_DIRS )
target_include_directories( Catch2 SYSTEM INTERFACE ${INCLUDE_DIRS} )
else()
target_include_directories( Catch2 SYSTEM INTERFACE libs/Catch2/single_include )
endif()
# -----------------------------------------------------------------------------
# verbose log
# -----------------------------------------------------------------------------
if( VERBOSE_CONFIG )
message( STATUS "SeqAn symbols")
message( STATUS " SEQAN_DEFINITIONS : ${SEQAN_DEFINITIONS}" )
message( STATUS " SEQAN_CXX_FLAGS : ${SEQAN_CXX_FLAGS}" )
message( STATUS " SEQAN_INCLUDE_DIRS : ${SEQAN_INCLUDE_DIRS}" )
message( STATUS " SEQAN_LIBRARIES : ${SEQAN_LIBRARIES}" )
message( STATUS "Misc symbols")
message( STATUS " Build type : ${CMAKE_BUILD_TYPE}" )
message( STATUS " CMAKE_CXX_FLAGS : ${CMAKE_CXX_FLAGS}" )
message( STATUS " INCLUDE_DIRS : ${INCLUDE_DIRS}" )
message( STATUS " CMAKE_INSTALL_PREFIX: ${CMAKE_INSTALL_PREFIX}" )
message( STATUS " CONDA : ${CONDA}" )
message( STATUS " GANON_OFFSET : ${GANON_OFFSET}" )
get_directory_property( dirCompileOptions COMPILE_OPTIONS )
message( STATUS " COMPILE_OPTIONS : ${dirCompileOptions}" )
endif()
# -----------------------------------------------------------------------------
# folders
# -----------------------------------------------------------------------------
enable_testing()
add_subdirectory( src )
add_subdirectory( tests )