-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCMakeLists.txt
300 lines (258 loc) · 12.1 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
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# Licensed Materials - Property of Lorenzo Gatti & Massimo Maiolo
# Copyright (C) 2015-2019 by Lorenzo Gatti & Massimo Maiolo
# -------------------------------------------------------------------------
# This file is part of ProPIP
#
# ProPIP is a computer program whose purpose is to infer Multiple Sequence
# Alignment under an indel-aware model for nucleotide and protein datasets.
#
# This software is based and extends the following libraries:
# - the Bio++ libraries
# developed by the Bio++ Development Team <http://biopp.univ-montp2.fr>
#
# - The Tree Search Heuristic Library (TSH-LIB)
# developed by L. Gatti & M. Maiolo <http://bit.ly/tsh-lib>
#
# ProPIP is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.
#
# ProPIP is a free software: you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# You should have received a copy of the GNU Lesser General Public
# License along with ProPIP. If not, see <http://www.gnu.org/licenses/>.
# -------------------------------------------------------------------------
cmake_minimum_required(VERSION 3.5)
set(CASTOR_SOFTWARENAME "ProPIP")
set(CASTOR_DESCRIPTION "Indel-Aware Phylogenetic Tree Inference")
project(${CASTOR_SOFTWARENAME}
DESCRIPTION ${CASTOR_DESCRIPTION}
LANGUAGES "CXX")
## Store the git hash of the current head
if(EXISTS "${PROJECT_SOURCE_DIR}/.git/HEAD")
file(READ "${PROJECT_SOURCE_DIR}/.git/HEAD"
PROJECT_SOURCE_VERSION)
if("${PROJECT_SOURCE_VERSION}" MATCHES "^ref:")
string(REGEX REPLACE "^ref: *([^ \n\r]*).*" "\\1"
PROJECT_GIT_REF "${PROJECT_SOURCE_VERSION}")
file(READ "${PROJECT_SOURCE_DIR}/.git/${PROJECT_GIT_REF}"
PROJECT_SOURCE_VERSION)
endif()
string(STRIP "${PROJECT_SOURCE_VERSION}"
PROJECT_SOURCE_VERSION)
endif()
# Store the build date
if(WIN32)
execute_process(COMMAND "cmd" " /c date /t"
OUTPUT_VARIABLE DATE)
string(REGEX REPLACE "[^0-9]*(..).*" "\\1" MONTH "${DATE}")
set(MONTHS ""
"Jan" "Feb" "Mar" "Apr" "May" "Jun"
"Jul" "Aug" "Sep" "Oct" "Nov" "Dec")
list(GET MONTHS "${MONTH}" MONTH)
string(REGEX REPLACE "[^/]*/(..)/(....).*" "\\1 ${MONTH} \\2"
PROJECT_BUILD_DATE "${DATE}")
execute_process(COMMAND "cmd" " /c echo %TIME%"
OUTPUT_VARIABLE TIME)
string(REGEX REPLACE "[^0-9]*(..:..:..).*" "\\1"
PROJECT_BUILD_TIME "${TIME}")
execute_process(COMMAND git describe --abbrev=0 --tags
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_TAG_VERSION)
string(REGEX REPLACE "\n" "" GIT_TAG_VERSION_STRIPPED "${GIT_TAG_VERSION}")
else()
execute_process(COMMAND "date" "+%d %b %Y/%H:%M:%S"
OUTPUT_VARIABLE DATE_TIME)
string(REGEX REPLACE "([^/]*)/.*" "\\1"
PROJECT_BUILD_DATE "${DATE_TIME}")
string(REGEX REPLACE "[^/]*/([0-9:]*).*" "\\1"
PROJECT_BUILD_TIME "${DATE_TIME}")
execute_process(COMMAND git describe --abbrev=0 --tags
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
OUTPUT_VARIABLE GIT_TAG_VERSION)
string(REGEX REPLACE "\n" "" GIT_TAG_VERSION_STRIPPED "${GIT_TAG_VERSION}")
endif()
set(CASTOR_RELTIME ${PROJECT_BUILD_TIME})
set(CASTOR_RELDATE ${PROJECT_BUILD_DATE})
set(CASTOR_VERSION ${GIT_TAG_VERSION_STRIPPED})
project(${CASTOR_SOFTWARENAME} VERSION ${GIT_TAG_VERSION_STRIPPED})
add_definitions(-DPRJ_GITBRANCH=\"${PROJECT_GIT_REF}\"
-DPRJ_VERSION=\"${CASTOR_VERSION}\"
-DPRJ_GITREF=\"${PROJECT_SOURCE_VERSION}\"
-DPRJ_DESC=\"${CASTOR_DESCRIPTION}\"
-DPRJ_NAME=\"${CASTOR_SOFTWARENAME}\"
-DPRJ_DATE=\"${CASTOR_RELDATE}\"
-DPRJ_TIME=\"${CASTOR_RELTIME}\" )
set(CMAKE_CXX_STANDARD 14)
string(FIND "${CMAKE_BUILD_TYPE}" "static" STATIC)
# Using the icc/icpc/icl compilers
if (${USE_INTEL})
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Ofast -g -xSSE4.2 -axAVX,CORE-AVX2")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-Ofast -g -xSSE4.2 -axAVX,CORE-AVX2")
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -g0 -xSSE4.2 -axAVX,CORE-AVX2")
SET(CMAKE_C_FLAGS_RELEASE "-O3 -g0 -xSSE4.2 -axAVX,CORE-AVX2")
set(INTEL_LIB_ROOT /opt/intel/lib/intel64/)
else()
SET(CMAKE_CXX_FLAGS_RELEASE "-O3 -g0 ")
SET(CMAKE_C_FLAGS_RELEASE "-O3 -g0")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O2 -g")
endif()
SET(CMAKE_CXX_FLAGS_DEBUG "-Wall -Wshadow -Weffc++ -O0 -g")
SET(CMAKE_C_FLAGS_DEBUG "-Wall -Wshadow -O0 -g")
message("-- Compilation will be performed with the following release of the software:
\tbranch ${PROJECT_GIT_REF}
\tref ${PROJECT_SOURCE_VERSION}
\ttime ${CASTOR_RELDATE} ${CASTOR_RELTIME}
\tcurrent ${CASTOR_VERSION} (latest version)")
if (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(WINDOWS TRUE)
message(STATUS "Compilation will be performed under Windows")
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(LINUX TRUE)
message(STATUS "Compilation will be performed under Linux")
find_package(glog 0.3.5 REQUIRED)
if (${USE_INTEL})
message(STATUS "Compilation will be performed using the Intel Compilers...")
message(STATUS "Libraries will be searched in /opt/intel/lib/intel64")
set(INTEL_LIBS_SHARED ${INTEL_LIB_ROOT}libimf.so ${INTEL_LIB_ROOT}libsvml.so ${INTEL_LIB_ROOT}libirng.so ${INTEL_LIB_ROOT}libintlc.so.5)
set(INTEL_LIBS_STATIC ${INTEL_LIB_ROOT}libimf.a ${INTEL_LIB_ROOT}libsvml.a ${INTEL_LIB_ROOT}libirng.a)
endif()
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(MACOSX TRUE)
if (STATIC GREATER 0)
message(FATAL_ERROR "You can not build this project statically on Mac OS. Ask Apple why! CMake will exit.")
endif ()
message(STATUS "Compilation will be performed under Apple MacOS")
find_package(glog 0.3.5 REQUIRED)
if (${USE_INTEL})
message(STATUS "Compilation will be performed using the Intel Compilers...")
message(STATUS "Libraries will be searched in /opt/intel/lib/intel64")
set(INTEL_LIBS_SHARED ${INTEL_LIB_ROOT}libimf.dylib ${INTEL_LIB_ROOT}libsvml.dylib ${INTEL_LIB_ROOT}libirng.dylib ${INTEL_LIB_ROOT}libintlc.dylib)
set(INTEL_LIBS_STATIC ${INTEL_LIB_ROOT}libimf.a ${INTEL_LIB_ROOT}libsvml.a ${INTEL_LIB_ROOT}libirng.a)
endif()
endif ()
if (${USE_INTEL})
if(STATIC GREATER 0)
foreach (INTEL_LIB IN LISTS INTEL_LIBS_STATIC)
message(STATUS " required: ${INTEL_LIB}")
endforeach ()
else()
foreach (INTEL_LIB IN LISTS INTEL_LIBS_SHARED)
message(STATUS " required: ${INTEL_LIB}")
endforeach ()
endif()
endif()
# Dependencies not covered by find package should be found in the following directories
if (${CMAKE_PREFIX_PATH})
include_directories("${CMAKE_PREFIX_PATH}/include")
LINK_DIRECTORIES("${CMAKE_PREFIX_PATH}}/lib")
LINK_DIRECTORIES("${CMAKE_PREFIX_PATH}/lib64")
message(STATUS "Looking for libraries in the following directory: ${CMAKE_PREFIX_PATH}/lib")
message(STATUS "Looking for libraries in the following directory: ${CMAKE_PREFIX_PATH}/lib64")
message(STATUS "Looking for headers in the following directory: ${CMAKE_PREFIX_PATH}/include")
endif ()
# Find Boost Libraries
if (STATIC GREATER 0)
set(Boost_USE_STATIC_LIBS ON) # only find static libs
else ()
set(Boost_USE_STATIC_LIBS OFF) # only find dynamic libs
endif()
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
find_package(Boost REQUIRED COMPONENTS system filesystem)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
message(STATUS " static lib: ${Boost_LIBRARY_DIRS}" )
message(STATUS " include dir: ${Boost_INCLUDE_DIRS}" )
else ()
if (STATIC GREATER 0)
message(STATUS "You have requested to link the static version of the Boost libraries.")
message(STATUS "However, no static version of the Boost libraries has been found. " )
message(STATUS "If you downloaded Boost source files, run the following command: " )
message(STATUS "./b2 release --link=static install " )
endif()
endif()
# Find Tree-Search Heuristic Library
find_package(TshLib 3.0.0 REQUIRED)
if (TSHLIB_FOUND)
include_directories(${TSHLIB_INCLUDE_DIRS})
endif ()
# Find BPP dependencies
find_package(bpp-core 4.0.0 REQUIRED)
find_package(bpp-seq 12.0.0 REQUIRED)
find_package(bpp-phyl 12.0.0 REQUIRED)
# Check for a parallel framework (openMP)
if(${USE_PARALLEL})
message(STATUS "Compilation will check for a parallel framework" )
find_package(OpenMP)
if (OPENMP_FOUND)
message(STATUS "${OpenMP_VERSION}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
# Prepare static openMP libraries list
foreach(loop_var ${OpenMP_CXX_LIBRARIES})
string(REGEX MATCH "^(.*)\\.[^.]*$" dummy ${loop_var})
set(MYFILE_WITHOUT_EXT ${CMAKE_MATCH_1}.a)
list(APPEND OpenMP_CXX_LIBRARIES_STATIC ${MYFILE_WITHOUT_EXT})
endforeach()
message(STATUS "OpenMP Libraries Shared: ${OpenMP_CXX_LIBRARIES}")
message(STATUS "OpenMP Libraries Static: ${OpenMP_CXX_LIBRARIES_STATIC}")
add_definitions("-DUSE_OPENMP")
endif()
#endif()
endif()
# Add local include folder
include_directories("${PROJECT_SOURCE_DIR}/include")
# Files to compile
file(GLOB SOURCES src/*.cpp src/*.cc)
file(GLOB HEADERS include/*.hpp include/*.h)
add_executable(ProPIP ${SOURCES} ${HEADERS} include/DistanceFactory.hpp src/DistanceFactory.cpp include/DistanceFactoryML.hpp include/DistanceFactoryAlign.hpp include/DistanceFactoryAngle.hpp include/DistanceFactoryPrealigned.hpp src/DistanceFactoryAngle.cpp src/DistanceFactoryML.cpp src/DistanceFactoryPrealigned.cpp src/DistanceFactoryAlign.cpp)
set_target_properties(ProPIP PROPERTIES PUBLIC_HEADER "${HEADERS}")
# EIGEN3
SET(EIGEN_INCLUDE_DIR "/usr/local/include/eigen3/" CACHE STRING "path to libEigen3 headers")
message(STATUS "EIGEN_INCLUDE_DIR: ${EIGEN_INCLUDE_DIR}")
if (STATIC GREATER 0)
message(STATUS "Compilation will produce a static executable")
if(INTELCOMPILERVARS GREATER 0)
message(STATUS "Adding static compilation flag to ICPC and ICC")
SET(CMAKE_CXX_FLAGS_INTEL "${CMAKE_CXX_FLAGS_INTEL} -static-intel -static")
SET(CMAKE_C_FLAGS_INTEL "${CMAKE_C_FLAGS_INTEL} -static-intel -static")
SET(CMAKE_CXX_FLAGS_RELWITHINFOINTEL "${CMAKE_CXX_FLAGS_RELWITHINFOINTEL} -static-intel -static")
SET(CMAKE_C_FLAGS_RELWITHINFOINTEL "${CMAKE_C_FLAGS_RELWITHINFOINTEL} -static-intel -static")
SET(CMAKE_CXX_FLAGS_DEBUGINTEL "${CMAKE_CXX_FLAGS_DEBUGINTEL} -static-intel -static")
SET(CMAKE_C_FLAGS_DEBUGINTEL "${CMAKE_C_FLAGS_DEBUGINTEL} -static-intel -static")
endif()
set_target_properties(ProPIP PROPERTIES LINK_FLAGS "-static")
target_link_libraries(ProPIP tshlib-static)
target_link_libraries(ProPIP glog::glog)
target_link_libraries(ProPIP ${INTEL_LIBS_STATIC})
target_link_libraries(ProPIP ${BPP_LIBS_STATIC})
target_link_libraries(ProPIP ${Boost_LIBRARIES})
target_link_libraries(ProPIP ${OpenMP_CXX_LIBRARIES_STATIC})
# GSL
find_package(GSL REQUIRED)
message("Libraries: ${GSL_LIBRARIES} ${GSLCBLAS_LIBRARIES}")
include_directories(ProPIP ${GSL_INCLUDE_DIR})
target_link_libraries(ProPIP ${GSL_LIBRARIES})
else ()
target_link_libraries(ProPIP tshlib)
target_link_libraries(ProPIP glog::glog)
target_link_libraries(ProPIP ${INTEL_LIBS_SHARED})
target_link_libraries(ProPIP ${BPP_LIBS_SHARED})
target_link_libraries(ProPIP ${Boost_LIBRARIES})
target_link_libraries(ProPIP ${OpenMP_CXX_LIBRARIES})
# GSL
find_package(GSL REQUIRED)
message("Libraries: ${GSL_LIBRARIES} ${GSLCBLAS_LIBRARIES}")
include_directories(ProPIP ${GSL_INCLUDE_DIR})
target_link_libraries(ProPIP ${GSL_LIBRARIES})
endif()
include (CTest)
add_test(example_test ProPIP)
# Test target
#enable_testing()
#add_subdirectory (tests)