-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
268 lines (225 loc) · 9.93 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
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
# ===========================================================================
# LaRA -- Lagrangian Relaxed structural Alignment
# ===========================================================================
cmake_minimum_required (VERSION 3.0.0)
string(ASCII 27 Esc)
set(ColourBold "${Esc}[1m")
set(ColourReset "${Esc}[m")
set(ColourRed "${Esc}[31m")
# ----------------------------------------------------------------------------
# Compiler detection
# ----------------------------------------------------------------------------
message ("${ColourBold}Compiler detection${ColourReset}")
# change version after every release
project(lara
VERSION 2.0.1
LANGUAGES CXX)
set(PROJECT_DESCRIPTION "LaRA: Lagrangian Relaxed structural Alignment")
set (LARA_SOURCE_FILES src/lara.cpp)
add_executable (lara ${LARA_SOURCE_FILES})
# Make "Release" the default cmake build type
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Release CACHE STRING
"Choose the type of build, options are: Debug Release RelWithDebInfo"
FORCE)
endif ()
set(CMAKE_CXX_STANDARD 14)
# Compiler specifics: Clang
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set (SEQAN_CXX_FLAGS "${SEQAN_CXX_FLAGS} -ftemplate-depth-1024")
# do not warn for variable length arrays
set (SEQAN_CXX_FLAGS "${SEQAN_CXX_FLAGS} -Wno-vla-extension")
endif ()
# Compiler specifics: GCC
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
# do not warn for variable length arrays
set (SEQAN_CXX_FLAGS "${SEQAN_CXX_FLAGS} -Wno-vla")
# parallelize parts of build even for one translation unit
if (NOT DEFINED LARA_COMPILE_THREADS)
include(ProcessorCount)
ProcessorCount(LARA_COMPILE_THREADS)
endif ()
if (LARA_COMPILE_THREADS GREATER 1)
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -flto=${LARA_COMPILE_THREADS}")
endif()
# strip binaries to make them smaller
set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -s")
endif ()
# Compiler specifics: All but Intel
if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Intel")
# -Wextra not met by current SeqAn on intel
set (SEQAN_CXX_FLAGS "${SEQAN_CXX_FLAGS} -Wextra")
endif ()
# ----------------------------------------------------------------------------
# Dependency detection
# ----------------------------------------------------------------------------
message ("\n${ColourBold}Dependency detection${ColourReset}")
# SeqAn
set (MINIMUM_SEQAN_VERSION "2.4.0")
if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/include/seqan/include/seqan/version.h")
set (CMAKE_INCLUDE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/include/seqan/include
${CMAKE_INCLUDE_PATH})
set (CMAKE_PREFIX_PATH
${CMAKE_CURRENT_SOURCE_DIR}/include/seqan/util/cmake
${CMAKE_PREFIX_PATH})
set (CMAKE_MODULE_PATH
${CMAKE_CURRENT_SOURCE_DIR}/include/seqan/util/cmake
${CMAKE_MODULE_PATH})
endif ()
find_package(SeqAn REQUIRED CONFIG)
# LEMON
set (LEMON_FOUND "FALSE")
find_path(LEMON_PATH NAMES lemon/smart_graph.h HINTS ${CMAKE_CURRENT_SOURCE_DIR}/include/lemon/include)
if (LEMON_PATH)
set (CMAKE_INCLUDE_PATH ${LEMON_PATH} ${CMAKE_INCLUDE_PATH})
add_definitions(-DLEMON_FOUND)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DLEMON_ONLY_TEMPLATES")
set (LEMON_FOUND "TRUE")
else()
message (STATUS "Cannot find header files of the LEMON library, which is required to compute matchings.")
endif ()
# Include MPFR in case ViennaRNA is compiled with it.
find_library (MPFR mpfr)
if (MPFR)
target_link_libraries (lara PUBLIC ${MPFR})
endif ()
#ViennaRNA
set (VIENNA_FOUND "FALSE")
find_library (VIENNA_RNA_LIB libRNA.a)
find_path (VIENNA_RNA_PATH NAMES ViennaRNA/part_func.h)
if (VIENNA_RNA_LIB AND VIENNA_RNA_PATH)
add_definitions (-DVIENNA_RNA_FOUND)
set (VIENNA_FOUND "TRUE")
target_link_libraries (lara PUBLIC ${VIENNA_RNA_LIB})
target_include_directories (lara SYSTEM PUBLIC ${VIENNA_RNA_PATH})
endif ()
# others
find_package(OpenMP QUIET)
find_package(ZLIB QUIET)
find_package(BZip2 QUIET)
message(STATUS "These dependencies where found:")
message( " SEQAN ${SEQAN_FOUND} \t${SEQAN_VERSION_STRING}")
message( " ZLIB ${ZLIB_FOUND} \t${ZLIB_VERSION_STRING}")
message( " BZIP2 ${BZIP2_FOUND} \t${BZIP2_VERSION_STRING}")
message( " OPENMP ${OPENMP_FOUND} \t${OpenMP_CXX_FLAGS}")
message( " ViennaRNA ${VIENNA_FOUND} \t${VIENNA_RNA_PATH}")
message( " Lemon ${LEMON_FOUND} \t${LEMON_PATH}")
# Warn if OpenMP was not found.
if (OPENMP_FOUND)
add_definitions(-DWITH_OPENMP)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
else ()
message (WARNING "WARNING WARNING WARNING\nWARNING: OpenMP not found. LaRA will be built without multi-threading! "
"This is probably not what you want! Use GCC >= 4.9.1, Clang >= 3.8.0 or ICC >= 16.0.2\nWARNING WARNING WARNING")
endif (OPENMP_FOUND)
# Warn if Zlib was not found.
if (NOT ZLIB_FOUND)
message (WARNING "WARNING: Zlib not found. Building LaRA without support for gzipped input and output.")
endif (NOT ZLIB_FOUND)
# Warn if BZip2 was not found.
if (NOT BZIP2_FOUND)
message (WARNING "WARNING: BZip2 not found. Building LaRA without support for bzipped input and output.")
endif (NOT BZIP2_FOUND)
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.9.1)
message (FATAL_ERROR "Your GCC version is too old. Minimum version is GCC-4.9.1!")
return ()
endif ()
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.8)
message (FATAL_ERROR "Your Clang version is too old. Please upgrade to 3.8.0 or use GCC.")
return()
endif ()
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Intel")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 17)
message(WARNING "Your Intel Compiler version is too old. Please upgrade to 17.0.0 or newer!")
endif ()
else ()
message(WARNING "Unknown compiler, you are on your own!")
endif ()
# SeqAn version check
if (SEQAN_VERSION_STRING VERSION_LESS "${MINIMUM_SEQAN_VERSION}")
message (FATAL_ERROR "The minimum SeqAn version required is ${MINIMUM_SEQAN_VERSION}!")
return ()
endif ()
# deactivate the version check on old seqan releases
if (SEQAN_VERSION_STRING VERSION_LESS "2.3.2")
add_definitions (-DSEQAN_DISABLE_VERSION_CHECK="YES")
endif ()
set (SEQAN_APP_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
set (SEQAN_APP_VERSION_MINOR ${PROJECT_VERSION_MINOR})
set (SEQAN_APP_VERSION_PATCH ${PROJECT_VERSION_PATCH})
set (SEQAN_APP_VERSION "${PROJECT_VERSION}")
target_link_libraries (lara PUBLIC ${SEQAN_LIBRARIES})
message(STATUS "The requirements where met.")
# ----------------------------------------------------------------------------
# Build Setup
# ----------------------------------------------------------------------------
# Enable global exception handler for all seqan apps.
set (SEQAN_DEFINITIONS ${SEQAN_DEFINITIONS} -DSEQAN_GLOBAL_EXCEPTION_HANDLER=1)
# Add include directories.
include_directories (SYSTEM ${SEQAN_INCLUDE_DIRS} ${LEMON_PATH})
# Add definitions set by find_package (SeqAn).
add_definitions (${SEQAN_DEFINITIONS})
# Add definitions set by the build system.
add_definitions (-DSEQAN_APP_VERSION="${SEQAN_APP_VERSION}")
add_definitions (-DCMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE}")
# Set the right output directory
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
# Add CXX flags found by find_package (SeqAn).
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SEQAN_CXX_FLAGS} -Wall -pedantic")
# Warn if cmake build type is not "Release"
if (NOT CMAKE_BUILD_TYPE STREQUAL Release)
message (STATUS "${ColourRed}CMAKE_BUILD_TYPE is not \"Release\", your binaries will be slow.${ColourReset}")
endif ()
# ----------------------------------------------------------------------------
# Add Tests
# ----------------------------------------------------------------------------
# message ("\n${ColourBold}Setting up unit tests${ColourReset}")
# add_subdirectory(tests)
# ----------------------------------------------------------------------------
# CPack Install
# ----------------------------------------------------------------------------
# Information
set (CPACK_PACKAGE_NAME "lara")
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "LaRA: Lagrangian Relaxed structural Alignment")
set (CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README.rst")
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE")
set (CPACK_PACKAGE_VENDOR "Jörg Winkler <[email protected]>")
set (CPACK_PACKAGE_CONTACT "${CPACK_PACKAGE_VENDOR}")
set (CPACK_PACKAGE_VERSION_MAJOR "${PROJECT_VERSION_MAJOR}")
set (CPACK_PACKAGE_VERSION_MINOR "${PROJECT_VERSION_MINOR}")
set (CPACK_PACKAGE_VERSION_PATCH "${PROJECT_VERSION_PATCH}")
set (CPACK_PACKAGE_VERSION "${SEQAN_APP_VERSION}")
set (CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}")
# Package format(s)
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
set(CPACK_GENERATOR "ZIP;NSIS")
elseif (CMAKE_SYSTEM_NAME MATCHES "Darwin")
set(CPACK_GENERATOR "ZIP;DragNDrop")
elseif (CMAKE_VERSION VERSION_LESS "3.1") # TXZ support since 3.1
set(CPACK_GENERATOR "TBZ2")
else()
set(CPACK_GENERATOR "TXZ")
endif ()
if (CMAKE_SYSTEM_NAME MATCHES "Linux")
set(CPACK_GENERATOR "${CPACK_GENERATOR};DEB;RPM")
endif ()
# Package architecture
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "amd64")
set(CMAKE_SYSTEM_PROCESSOR "x86_64")
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "amd64")
endif ()
if (CMAKE_CXX_FLAGS MATCHES "avx2")
set (CMAKE_SYSTEM_PROCESSOR "${CMAKE_SYSTEM_PROCESSOR}_avx2")
elseif (CMAKE_CXX_FLAGS MATCHES "sse4")
set (CMAKE_SYSTEM_PROCESSOR "${CMAKE_SYSTEM_PROCESSOR}_sse4")
endif()
# Include architecture in package name
if (NOT DEFINED CPACK_SYSTEM_NAME)
set(CPACK_SYSTEM_NAME "${CMAKE_SYSTEM_NAME}-${CMAKE_SYSTEM_PROCESSOR}")
endif (NOT DEFINED CPACK_SYSTEM_NAME)
include (CPack)