forked from nvmd/itpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
255 lines (234 loc) · 8.05 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
#
# \file CMakeLists.txt
# \brief main cmake configuration file
# \author Bogdan Cristea
#
# -------------------------------------------------------------------------
#
# Copyright (C) 1995-2014 (see AUTHORS file for a list of contributors)
#
# This file is part of IT++ - a C++ library of mathematical, signal
# processing, speech processing, and communications classes and functions.
#
# IT++ is free software: you can redistribute it and/or modify it under the
# terms of the GNU General Public License as published by the Free Software
# Foundation, either version 3 of the License, or (at your option) any
# later version.
#
# IT++ 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. See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along
# with IT++. If not, see <http://www.gnu.org/licenses/>.
#
# -------------------------------------------------------------------------
cmake_minimum_required ( VERSION 2.8.12 )
project(ITPP)
set ( CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/Modules/ ${CMAKE_MODULE_PATH} )
#check for BLAS library
find_package ( BLAS )
if (BLAS_FOUND)
if (BLA_VENDOR MATCHES "^ACML")
set (HAVE_ACML 1)#TODO: for Windows only
set (HAVE_BLAS_ACML 1)
set (HAVE_BLAS 1)
elseif (BLA_VENDOR MATCHES "^Intel")
set (HAVE_MKL 1)#TODO: for Windows only
set (HAVE_BLAS_MKL 1)
set (HAVE_BLAS 1)
elseif (BLA_VENDOR MATCHES "^ATLAS")
set (HAVE_BLAS_ATLAS 1)
set (HAVE_BLAS 1)
elseif( (BLA_VENDOR STREQUAL "Generic") OR (BLA_VENDOR STREQUAL "All") )
set (HAVE_BLAS 1)
else()
message (WARNING "Unknown BLAS vendor: ${BLA_VENDOR}")
set(BLAS_FOUND FALSE)
endif()
endif(BLAS_FOUND)
#check for LAPACK library
find_package ( LAPACK )
if (LAPACK_FOUND)
if ((BLA_VENDOR MATCHES "^ACML") OR (BLA_VENDOR MATCHES "^Intel") OR (BLA_VENDOR MATCHES "^ATLAS") OR ( BLA_VENDOR STREQUAL "Generic" ) OR (BLA_VENDOR STREQUAL "All"))
set (HAVE_LAPACK 1)
else()
message (WARNING "Unknown LAPACK vendor: ${BLA_VENDOR}")
set(LAPACK_FOUND FALSE)
endif()
endif(LAPACK_FOUND)
#check for FFT library
find_package ( FFT )
if (FFT_FOUND)
if (FFT_VENDOR MATCHES "^ACML")
set (HAVE_FFT_ACML 1)
set (HAVE_FFT 1)
elseif (FFT_VENDOR MATCHES "^Intel")
set (HAVE_FFT_MKL 1)
set (HAVE_FFT 1)
elseif (FFT_VENDOR MATCHES "^FFTW3")
set (HAVE_FFTW3 1)
set (HAVE_FFT 1)
else()
message (WARNING "Unknown FFT vendor: ${FFT_VENDOR}")
set(FFT_FOUND FALSE)
endif()
endif(FFT_FOUND)
#check for OpenMP support
find_package ( OpenMP )
if (OPENMP_FOUND)
set (CMAKE_CXX_FLAGS "${OpenMP_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
if (MINGW)
set (CMAKE_SHARED_LINKER_FLAGS "${OpenMP_CXX_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}")
endif()
endif()
#check for Doxygen and LaTeX
find_package ( Doxygen )
find_package ( LATEX )
#check for header files
include ( CheckIncludeFile )
include ( CheckIncludeFiles )
CHECK_INCLUDE_FILES ( "sys/time.h;time.h" TIME_WITH_SYS_TIME )
CHECK_INCLUDE_FILE ( "dlfcn.h" HAVE_DLFCN_H )
CHECK_INCLUDE_FILE ( "ieeefp.h" HAVE_IEEEFP_H )
CHECK_INCLUDE_FILE ( "inttypes.h" HAVE_INTTYPES_H )
CHECK_INCLUDE_FILE ( "memory.h" HAVE_MEMORY_H )
CHECK_INCLUDE_FILE ( "stdint.h" HAVE_STDINT_H )
CHECK_INCLUDE_FILE ( "stdlib.h" HAVE_STDLIB_H )
CHECK_INCLUDE_FILE ( "strings.h" HAVE_STRINGS_H )
CHECK_INCLUDE_FILE ( "string.h" HAVE_STRING_H )
CHECK_INCLUDE_FILE ( "sys/stat.h" HAVE_SYS_STAT_H )
CHECK_INCLUDE_FILE ( "sys/types.h" HAVE_SYS_TYPES_H )
CHECK_INCLUDE_FILE ( "unistd.h" HAVE_UNISTD_H )
include ( CheckIncludeFileCXX )
CHECK_INCLUDE_FILE_CXX ( "cmath" HAVE_CMATH )
CHECK_INCLUDE_FILE_CXX ( "complex" HAVE_COMPLEX )
#check for symbols
include (CheckCXXSymbolExists)
CHECK_CXX_SYMBOL_EXISTS ( isfinite "cmath" HAVE_DECL_ISFINITE )
CHECK_CXX_SYMBOL_EXISTS ( isinf "cmath" HAVE_DECL_ISINF )
CHECK_CXX_SYMBOL_EXISTS ( isnan "cmath" HAVE_DECL_ISNAN )
CHECK_CXX_SYMBOL_EXISTS ( signgam "cmath" HAVE_DECL_SIGNGAM )
#check for functions
option(ITPP_DISABLE_MATH_LIB "Don't automatically use math library when linking" off)
if( NOT ITPP_DISABLE_MATH_LIB )
set(CMAKE_REQUIRED_LIBRARIES m)
endif()
include (CheckFunctionExists)
CHECK_FUNCTION_EXISTS ( acosh HAVE_ACOSH )
CHECK_FUNCTION_EXISTS ( asinh HAVE_ASINH )
CHECK_FUNCTION_EXISTS ( atanh HAVE_ATANH )
CHECK_FUNCTION_EXISTS ( cbrt HAVE_CBRT )
CHECK_FUNCTION_EXISTS ( erf HAVE_ERF )
CHECK_FUNCTION_EXISTS ( erfc HAVE_ERFC )
CHECK_FUNCTION_EXISTS ( expm1 HAVE_EXPM1 )
CHECK_FUNCTION_EXISTS ( finite HAVE_FPCLASS )
CHECK_FUNCTION_EXISTS ( fpclass HAVE_FPCLASS )
CHECK_FUNCTION_EXISTS ( isfinite HAVE_ISFINITE )
CHECK_FUNCTION_EXISTS ( isinf HAVE_ISINF )
CHECK_FUNCTION_EXISTS ( isnan HAVE_ISNAN )
CHECK_FUNCTION_EXISTS ( lgamma HAVE_LGAMMA )
CHECK_FUNCTION_EXISTS ( log1p HAVE_LOG1P )
CHECK_FUNCTION_EXISTS ( log2 HAVE_LOG2 )
CHECK_FUNCTION_EXISTS ( rint HAVE_RINT )
CHECK_FUNCTION_EXISTS ( tgamma HAVE_TGAMMA )
include (CheckCXXFunctionExists)
CHECK_CXX_FUNCTION_EXISTS ( std::isfinite HAVE_STD_ISFINITE )
CHECK_CXX_FUNCTION_EXISTS ( std::isinf HAVE_STD_ISINF )
CHECK_CXX_FUNCTION_EXISTS ( std::isnan HAVE_STD_ISNAN )
#package related variables
set (PACKAGE "itpp")
set (PACKAGE_BUGREPORT "http://sourceforge.net/projects/itpp/forums/forum/115656")
set (PACKAGE_NAME "IT++")
set (PACKAGE_VERSION "4.3.1")
set (PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set (PACKAGE_TARNAME ${PACKAGE})
set (PACKAGE_URL "")
string(TIMESTAMP PACKAGE_DATE "%Y-%m-%d" UTC)
if (WIN32 AND NOT MINGW)
#TODO: remove this from future versions
CONFIGURE_FILE ( ${PROJECT_SOURCE_DIR}/itpp/config.h.cmake ${CMAKE_BINARY_DIR}/itpp/config_msvc.h )
else()
CONFIGURE_FILE ( ${PROJECT_SOURCE_DIR}/itpp/config.h.cmake ${CMAKE_BINARY_DIR}/itpp/config.h )
endif()
#set library type: shared or static
option(ITPP_SHARED_LIB "Building IT++ as shared library" on)
#set library name here to be available for all targets
if (ITPP_SHARED_LIB)
if ((CMAKE_BUILD_TYPE STREQUAL Release) OR (NOT CMAKE_BUILD_TYPE))
set (libitpp_target itpp)
set (CMAKE_CXX_FLAGS "-DNDEBUG ${CMAKE_CXX_FLAGS}")
else()
set (libitpp_target itpp_debug)
endif()
else()
set (libitpp_target itpp_static)
endif()
CONFIGURE_FILE (${PROJECT_SOURCE_DIR}/itpp/itexports.h.cmake ${CMAKE_BINARY_DIR}/itpp/itexports.h)
#build HTML docs
option(HTML_DOCS "Building HTML documentation with Doxygen if available" on)
#display summary
set(DISP_GENERIC_WARNING FALSE)
if (NOT BLAS_FOUND)
message(WARNING "BLAS library not found.")
set(DISP_GENERIC_WARNING TRUE)
endif()
if (NOT LAPACK_FOUND)
message(WARNING "LAPACK library not found.")
set(DISP_GENERIC_WARNING TRUE)
endif()
if (NOT FFT_FOUND)
message(WARNING "FFT library not found.")
set(DISP_GENERIC_WARNING TRUE)
endif()
if (DISP_GENERIC_WARNING)
message(WARNING "You can still compile IT++ but the functionality will be reduced.")
else()
message(STATUS "BLAS vendor: ${BLA_VENDOR}")
endif()
#set external link libraries
set(ITPP_LIBS "")
if (BLAS_LIBRARIES)
set(ITPP_LIBS ${BLAS_LIBRARIES} ${ITPP_LIBS})
endif()
if (LAPACK_LIBRARIES)
set(ITPP_LIBS ${LAPACK_LIBRARIES} ${ITPP_LIBS})
endif()
if (FFT_LIBRARIES)
set(ITPP_LIBS ${FFT_LIBRARIES} ${ITPP_LIBS})
endif()
#set integer width for BLAS
if (BLAS_INT)
if (BLAS_INT EQUAL 32)
add_definitions( -DBLAS_INT32 )
elseif (BLAS_INT EQUAL 64)
add_definitions( -DBLAS_INT64 )
else()
message(SEND_ERROR "BLAS_INT must be either 32 or 64.")
endif()
else()
add_definitions( -DBLAS_INT32 )
endif()
#set integer width for LAPACK
if (LAPACK_INT)
if (LAPACK_INT EQUAL 32)
add_definitions( -DLAPACK_INT32 )
elseif (LAPACK_INT EQUAL 64)
add_definitions( -DLAPACK_INT64 )
else()
message(SEND_ERROR "LAPACK_INT must be either 32 or 64.")
endif()
else()
add_definitions( -DLAPACK_INT32 )
endif()
#add it++ sources
add_subdirectory ( itpp )
#add unit tests
option(OLD_TESTS "Building old unit tests (no longer maintained). Use extras/check_tests.py script to run the tests." off)
if (OLD_TESTS)
add_subdirectory ( tests )
endif()
if (GTEST_DIR)
add_subdirectory (gtests)
endif()