-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
265 lines (246 loc) · 10.5 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
cmake_minimum_required(VERSION 2.8.12)
project(mSWEEP)
## Determine build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release) ## Build Release by default
elseif(CMAKE_BUILD_TYPE MATCHES Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall -Wextra -Wpedantic")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -g -Wall -Wextra -Wpedantic")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -g -Wall -Wextra -Wpedantic")
endif()
if(CMAKE_BUILD_TYPE MATCHES Release)
if(CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -xHost -fp-model fast=2 -no-prec-div -fimf-use-svml=true -ipo -m64")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -O3 -xHost -fp-model fast=2 -no-prec-div -fimf-use-svml=true -ipo -m64")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -O3 -xHost -fp-model fast=2 -no-prec-div -fimf-use-svml=true -ipo -m64")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ffast-math -funroll-loops")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -ffast-math -funroll-loops")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -ffast-math -funroll-loops")
endif()
endif()
## Check dependencies
find_package(OpenMP)
if (OPENMP_FOUND)
set(MSWEEP_OPENMP_SUPPORT 1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -D_GLIBCXX_PARALLEL")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -D_GLIBCXX_PARALLEL")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -D_GLIBCXX_PARALLEL")
else()
set(MSWEEP_OPENMP_SUPPORT 0)
endif()
set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
### MPI
find_package(MPI)
if (MPI_FOUND)
set(MSWEEP_MPI_SUPPORT 1)
include_directories(MPI_C_INCLUDE_DIRS)
if (CMAKE_MPI_MAX_PROCESSES)
set(MSWEEP_MPI_MAX_PROCESSES ${CMAKE_MPI_MAX_PROCESSES})
else()
set(MSWEEP_MPI_MAX_PROCESSES 1024)
endif()
else()
set(MSWEEP_MPI_SUPPORT 0)
endif()
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
## Get version number from git tags
find_package(Git)
if(GIT_FOUND)
execute_process(
COMMAND ${GIT_EXECUTABLE} describe --tags
WORKING_DIRECTORY "${local_dir}"
OUTPUT_VARIABLE _BUILD_VERSION
ERROR_QUIET
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message( STATUS "mSWEEP version: ${_BUILD_VERSION}")
else()
message(STATUS "GIT not found, version numbering disabled")
set(_BUILD_VERSION "unknown")
endif()
string(TIMESTAMP _BUILD_TIMESTAMP)
## Generate a version.h file containing build version and timestamp
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/version.h.in ${CMAKE_BINARY_DIR}/include/version.h @ONLY)
## Configure OpenMP if it supported on the system.
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/openmp_config.hpp.in ${CMAKE_BINARY_DIR}/include/openmp_config.hpp @ONLY)
## Configure MPI if it's supported on the system.
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/mpi_config.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/include/mpi_config.hpp @ONLY)
add_executable(mSWEEP
${CMAKE_SOURCE_DIR}/src/BootstrapSample.cpp
${CMAKE_SOURCE_DIR}/src/Reference.cpp
${CMAKE_SOURCE_DIR}/src/Grouping.cpp
${CMAKE_SOURCE_DIR}/src/Sample.cpp
${CMAKE_SOURCE_DIR}/src/likelihood.cpp
${CMAKE_SOURCE_DIR}/src/mSWEEP.cpp
${CMAKE_SOURCE_DIR}/src/parse_arguments.cpp
${CMAKE_SOURCE_DIR}/src/main.cpp)
## Check supported compression types
find_package(BZip2)
if (BZIP2_FOUND)
include_directories(${BZIP2_INCLUDE_DIRS})
target_link_libraries(mSWEEP ${BZIP2_LIBRARIES})
endif()
find_package(LibLZMA)
if (LIBLZMA_FOUND)
include_directories(${LIBLZMA_INCLUDE_DIRS})
target_link_libraries(mSWEEP ${LIBLZMA_LIBRARIES})
endif()
find_package(ZLIB)
if (ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIRS})
target_link_libraries(mSWEEP ${ZLIB_LIBRARIES})
endif()
if(NOT ZLIB_FOUND OR CMAKE_BUILD_ZLIB)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/CMakeLists-zlib.txt.in ${CMAKE_BINARY_DIR}/external/zlib-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/external/zlib-download )
if(result)
message(FATAL_ERROR "CMake step for zlib failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/external/zlib-download )
if(result)
message(FATAL_ERROR "Build step for zlib failed: ${result}")
endif()
set(ZLIB ${CMAKE_BINARY_DIR}/lib/libz.a)
else()
set(ZLIB ZLIB::ZLIB)
endif()
## bxzstr
if (DEFINED CMAKE_BXZSTR_HEADERS)
message(STATUS "bxzstr headers provided in: ${CMAKE_BXZSTR_HEADERS}")
else()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/CMakeLists-bxzstr.txt.in ${CMAKE_BINARY_DIR}/external/bxzstr-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/external/bxzstr-download )
if(result)
message(FATAL_ERROR "CMake step for bxzstr failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/external/bxzstr-download )
if(result)
message(FATAL_ERROR "Build step for bxzstr failed: ${result}")
endif()
set(CMAKE_BXZSTR_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/external/bxzstr/include)
endif()
include_directories(${CMAKE_BXZSTR_HEADERS})
## Check dependencies and download them if not given
## cxxio
if (DEFINED CMAKE_CXXIO_HEADERS)
message(STATUS "cxxio headers provided in: ${CMAKE_CXXIO_HEADERS}")
else()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/CMakeLists-cxxio.txt.in ${CMAKE_BINARY_DIR}/external/cxxio-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/external/cxxio-download )
if(result)
message(FATAL_ERROR "CMake step for cxxio failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/external/cxxio-download )
if(result)
message(FATAL_ERROR "Build step for cxxio failed: ${result}")
endif()
set(CMAKE_CXXIO_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/external/cxxio/include)
endif()
include_directories("${CMAKE_CXXIO_HEADERS}")
## cxxargs
if (DEFINED CMAKE_CXXARGS_HEADERS)
message(STATUS "cxxargs headers provided in: ${CMAKE_CXXARGS_HEADERS}")
else()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/CMakeLists-cxxargs.txt.in ${CMAKE_BINARY_DIR}/external/cxxargs-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/external/cxxargs-download )
if(result)
message(FATAL_ERROR "CMake step for cxxargs failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/external/cxxargs-download )
if(result)
message(FATAL_ERROR "Build step for cxxargs failed: ${result}")
endif()
set(CMAKE_CXXARGS_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/external/cxxargs/include)
endif()
include_directories("${CMAKE_CXXARGS_HEADERS}")
## telescope
if (DEFINED CMAKE_TELESCOPE_LIBRARY AND DEFINED CMAKE_TELESCOPE_HEADERS)
find_library(TELESCOPE NAMES telescope HINTS ${CMAKE_TELESCOPE_LIBRARY})
target_link_libraries(mSWEEP ${TELESCOPE})
else()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/CMakeLists-telescope.txt.in ${CMAKE_BINARY_DIR}/external/telescope-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/external/telescope-download )
if(result)
message(FATAL_ERROR "CMake step for telescope failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/external/telescope-download )
if(result)
message(FATAL_ERROR "Build step for telescope failed: ${result}")
endif()
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/external/telescope
${CMAKE_CURRENT_BINARY_DIR}/external/telescope/build)
set_target_properties(telescope PROPERTIES EXCLUDE_FROM_ALL 1)
target_link_libraries(mSWEEP libtelescope)
set(CMAKE_TELESCOPE_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/external/telescope/include)
endif()
include_directories(${CMAKE_TELESCOPE_HEADERS})
## rcgpar
if (DEFINED CMAKE_RCGPAR_LIBRARY AND DEFINED CMAKE_RCGPAR_HEADERS)
find_library(RCGPAR NAMES rcgpar HINTS ${CMAKE_RCGPAR_LIBRARY})
target_link_libraries(mSWEEP ${RCGPAR})
else()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config/CMakeLists-rcgpar.txt.in ${CMAKE_BINARY_DIR}/external/rcgpar-download/CMakeLists.txt)
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/external/rcgpar-download )
if(result)
message(FATAL_ERROR "CMake step for rcgpar failed: ${result}")
endif()
execute_process(COMMAND ${CMAKE_COMMAND} --build .
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/external/rcgpar-download )
if(result)
message(FATAL_ERROR "Build step for rcgpar failed: ${result}")
endif()
add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/external/rcgpar
${CMAKE_CURRENT_BINARY_DIR}/external/rcgpar/build)
target_link_libraries(mSWEEP rcgomp)
set(CMAKE_RCGPAR_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/external/rcgpar/include)
endif()
include_directories(${CMAKE_RCGPAR_HEADERS})
include_directories(${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/external ${CMAKE_SOURCE_DIR}/include/tools
${CMAKE_SOURCE_DIR}/external/cxxio
${CMAKE_CURRENT_BINARY_DIR}/include)
## Handle compiling zlib from source
if(CMAKE_BUILD_ZLIB)
add_subdirectory(${CMAKE_BINARY_DIR}/external/zlib
${CMAKE_BINARY_DIR}/external/zlib)
set_target_properties(example PROPERTIES EXCLUDE_FROM_ALL 1)
set_target_properties(minigzip PROPERTIES EXCLUDE_FROM_ALL 1)
set_target_properties(zlib PROPERTIES EXCLUDE_FROM_ALL 1)
add_dependencies(mSWEEP zlibstatic)
endif()
add_library(msweeptools ${CMAKE_CURRENT_SOURCE_DIR}/src/tools/matchfasta.cpp)
add_executable(matchfasta ${CMAKE_CURRENT_SOURCE_DIR}/src/tools/main.cpp)
# Link libraries
target_link_libraries(mSWEEP ${ZLIB} msweeptools)
target_link_libraries(matchfasta msweeptools)
if (OPENMP_FOUND)
target_link_libraries(mSWEEP OpenMP::OpenMP_CXX)
target_link_libraries(matchfasta OpenMP::OpenMP_CXX)
target_link_libraries(msweeptools OpenMP::OpenMP_CXX)
endif()