-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
430 lines (353 loc) · 13.6 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
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
##########################################################################
######################## Basso #################################
##########################################################################
cmake_minimum_required (VERSION 2.6)
project (Basso C CXX)
# set debug and release flags
set(CMAKE_CXX_FLAGS_DEBUG "-Wall -g3 -O0")
set(CMAKE_CXX_FLAGS_RELEASE "-g0 -O3 -DNDEBUG")
# The version number.
#EXECUTE_PROCESS(
# COMMAND ${GIT_EXECUTABLE} describe --dirty --always
# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
# OUTPUT_VARIABLE VERSION
# OUTPUT_STRIP_TRAILING_WHITESPACE
#)
#string(REGEX REPLACE "^v([0-9]+)\\..*" "\\1" Basso_VERSION_MAJOR "${VERSION}")
#string(REGEX REPLACE "^v[0-9]+\\.([0-9]+).*" "\\1" Basso_VERSION_MINOR "${VERSION}")
#string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.([0-9]+).*" "\\1" Basso_VERSION_PATCH "${VERSION}")
#string(REGEX REPLACE "^v[0-9]+\\.[0-9]+\\.[0-9]+(.*)" "\\1" Basso_VERSION_SHA1 "${VERSION}")
set (Basso_VERSION_MAJOR 1)
set (Basso_VERSION_MINOR 11)
set (Basso_VERSION_PATCH 1)
set(Basso_PACKAGE_VERSION "${Basso_VERSION_MAJOR}.${Basso_VERSION_MINOR}.${Basso_VERSION_PATCH}")
set (ISSUE_REPORT_MSG "Please consider opening an issue at https://github.com/FrederikHeber/BASSO with anything that is helpful.")
# should we count and measure the time of all operations?
option (USE_TIMINGS
"Use counter and timings on all vector space operations" OFF)
# use operator norm instead of matrix norm
option (FULLMATRIXNORM
"Use operator norm instead of matrix norm, requires SVD calculation" OFF)
# use MPI or OpenMP
option (USE_MPI
"Use MPI parallelization for MatrixFactorizer" OFF)
option (USE_OPENMP
"Use OPENMP parallelization for MatrixFactorizer" OFF)
if (USE_MPI)
if (USE_OPENMP)
error("Cannot activate both MPI and OpenMP parallelization.")
endif (USE_OPENMP)
set (USE_MPI $USE_MPI)
endif (USE_MPI)
if (USE_OPENMP)
set (USE_OPENMP $USE_OPENMP)
endif (USE_OPENMP)
###################### GIT VERSION HEADER ################################
# create a version target which must be added to every executable
FIND_PACKAGE(Git)
FILE(WRITE ${CMAKE_BINARY_DIR}/version.h.in
"\#define VERSION \"@VERSION@\""
)
FILE(WRITE ${CMAKE_BINARY_DIR}/version.cmake
"EXECUTE_PROCESS(
COMMAND ${GIT_EXECUTABLE} describe --dirty --always
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE VERSION
OUTPUT_STRIP_TRAILING_WHITESPACE
)
CONFIGURE_FILE(\${SRC} \${DST} @ONLY)
")
#INCLUDE_DIRECTORIES(${CMAKE_BINARY_DIR})
ADD_CUSTOM_TARGET(
version
${CMAKE_COMMAND} -D SRC=${CMAKE_BINARY_DIR}/version.h.in
-D DST=${CMAKE_BINARY_DIR}/version.h
-P ${CMAKE_BINARY_DIR}/version.cmake
)
######################## CHECK HEADERS ##################################
# does the system provide the log and exp functions?
set(CMAKE_REQUIRED_INCLUDES math.h)
set(CMAKE_REQUIRED_LIBRARIES m)
include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
check_function_exists (log HAVE_LOG)
check_function_exists (exp HAVE_EXP)
# find MPI
if (USE_MPI)
set ( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/ )
FIND_PACKAGE(MPI REQUIRED)
if (MPI_FOUND)
include_directories( ${MPI_CXX_INCLUDE_PATH})
FIND_PROGRAM(MPIRUN NAME mpirun PATHS usr/bin/ /bin ENV PATH NO_DEFAULT_PATH)
set (MPIRUN_FOUND ${MPIRUN_FOUND})
set (MPIRUN ${MPIRUN} CACHE STRING "command to launch multiple mpi jobs")
endif (MPI_FOUND)
endif (USE_MPI)
# find OpenMP
if (USE_OPENMP)
set ( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/ )
FIND_PACKAGE(OpenMP REQUIRED)
endif (USE_OPENMP)
####################### CHECK LIBRARIES #################################
# find eigen3 package for linear algebra routines
set ( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/ )
FIND_PACKAGE(Eigen3 3.2.0)
include_directories( ${EIGEN3_INCLUDE_DIR} )
# find cppunit for unit tests
set ( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/ )
FIND_PACKAGE(CppUnit REQUIRED)
if (CPPUNIT_FOUND)
include_directories( ${CPPUNIT_INCLUDE_DIR} )
#set (EXTRA_LIBS ${EXTRA_LIBS} ${CPPUNIT_LIBRARY})
endif (CPPUNIT_FOUND)
# looking for blas
set (BLA_VENDOR "Generic")
FIND_PACKAGE(BLAS REQUIRED)
if (BLAS_FOUND)
# find gsl for function minimization
set ( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/ )
FIND_PACKAGE(GSL REQUIRED)
if (GSL_FOUND)
include_directories( ${GSL_INCLUDE_DIR} )
set (GSL_LIBRARY ${GSL_LIBRARIES} ${BLAS_blas_LIBRARY})
endif (GSL_FOUND)
endif (BLAS_FOUND)
# find NLopt
set ( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/ )
find_package (NLopt)
if (NLOPT_FOUND)
include_directories( ${NLOPT_INCLUDE_DIR} )
endif (NLOPT_FOUND)
# find (p)thread
find_package (Threads REQUIRED)
# find librt (required by boost_thread)
set ( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/ )
find_package (Librt REQUIRED)
# find boost
ADD_DEFINITIONS(-DBOOST_LOG_DYN_LINK)
set ( Boost_ADDITIONAL_VERSIONS "1.61" "1.61.0" )
set ( Boost_USE_STATIC_LIBS OFF )
if (MPI_FOUND)
find_package ( Boost 1.61 COMPONENTS
chrono
log_setup
log
filesystem
mpi
program_options
python3
serialization
system
thread
REQUIRED )
else (MPI_FOUND)
find_package ( Boost 1.61 COMPONENTS
chrono
log_setup
log
filesystem
program_options
python3
serialization
system
thread
REQUIRED )
endif (MPI_FOUND)
set (BOOST_CORE_LIBRARIES
${Boost_CHRONO_LIBRARY}
${Boost_LOG_LIBRARY}
${Boost_FILESYSTEM_LIBRARY}
${Boost_PROGRAM_OPTIONS_LIBRARY}
${Boost_SYSTEM_LIBRARY})
include_directories( ${Boost_INCLUDE_DIR} )
# find pocosqlite
set ( CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/ )
find_package (Poco REQUIRED)
include_directories(${Poco_INCLUDE_DIRS})
link_directories(${Poco_LIBRARY_DIR})
if (Poco_SQLite_LIBRARY_RELEASE)
set (POCO_SQL_LIBRARIES
${Poco_Data_LIBRARY_RELEASE}
${Poco_SQLite_LIBRARY_RELEASE}
${Poco_Foundation_LIBRARY_RELEASE}
)
else(Poco_SQLite_LIBRARY_RELEASE)
set (POCO_SQL_LIBRARIES
${Poco_Data_LIBRARY_RELEASE}
${Poco_DataSQLite_LIBRARY_RELEASE}
${Poco_Foundation_LIBRARY_RELEASE}
)
endif(Poco_SQLite_LIBRARY_RELEASE)
# find libpng
find_package(PNG)
if (PNG_FOUND)
find_package(png++)
if (png++_FOUND)
include_directories(${PNG_INCLUDE_DIRS} ${png++_INCLUDE_DIRS})
set (PNG_LIBRARIES ${PNG_LIBRARIES})
set( PNG_FOUND ${PNG_FOUND})
set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${PNG_DEFINITIONS})
endif (png++_FOUND)
endif (PNG_FOUND)
# find libarpack
find_package(ARPACK)
if (ARPACK_FOUND)
set (ARPACK_LIBRARIES ${ARPACK_LIBRARIES})
set( ARPACK_FOUND ${ARPACK_FOUND})
endif (ARPACK_FOUND)
####################### CHECK given DIFF #################################
# should ndiff be used instead of diff
option (USE_NDIFF
"Use ndiff instead of diff" OFF)
if (USE_NDIFF)
set (NDIFF_PATH ${NDIFF_PATH} CACHE STRING "path to numerical diff")
FIND_PROGRAM(NDIFF NAME ndiff PATHS ${NDIFF_PATH} /usr/bin/ /bin ENV PATH NO_DEFAULT_PATH)
if (NDIFF EQUAL NDIFF-NOTFOUND)
set (DIFFCMD diff CACHE STRING "command to compare result files")
else (NDIFF EQUAL NDIFF-NOTFOUND)
set (NDIFF_FOUND ${NDIFF_FOUND})
set (DIFFCMD ${NDIFF} CACHE STRING "command to compare result files")
endif (NDIFF EQUAL NDIFF-NOTFOUND)
if (NDIFF_OPTIONS)
set (NDIFF_OPTIONS ${NDIFF_OPTIONS} CACHE STRING "Options for (numerical) diff")
endif (NDIFF_OPTIONS)
else (USE_NDIFF)
set (DIFFCMD diff CACHE STRING "command to compare result files")
endif (USE_NDIFF)
###################### CHECK given SQLite ################################
# sqlite is only used in tests which are skipped of not found
FIND_PROGRAM(SQLITE NAME sqlite sqlite3 PATHS /usr/bin/ /bin ENV PATH NO_DEFAULT_PATH)
if (NOT SQLITE EQUAL SQLITE-NOTFOUND)
set (SQLITECMD ${SQLITE} CACHE STRING "command to extract values from sqlite database")
set (SQLITE_FOUND TRUE CACHE BOOL "whether sqlite was found or not")
else (NOT SQLITE EQUAL SQLITE-NOTFOUND)
set (SQLITE_FOUND FALSE CACHE BOOL "whether sqlite was found or not")
endif (NOT SQLITE EQUAL SQLITE-NOTFOUND)
######################## BassoConfig.hpp #################################
# configure a header file to pass some CMake settings
# to the source code
configure_file (
"${PROJECT_SOURCE_DIR}/BassoConfig.h.in"
"${PROJECT_BINARY_DIR}/BassoConfig.h"
)
# add the binary tree to the search path for include files
# so that we will find BassoConfig.h
include_directories ("${PROJECT_BINARY_DIR}")
# install targets for config
install (FILES "${PROJECT_BINARY_DIR}/BassoConfig.h" DESTINATION include)
######################## RPATH settings ##################################
#
# see https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
#
##########################################################################
# use, i.e. don't skip the full RPATH for the build tree
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# the RPATH to be used when installing, but only if it's not a system directory
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
ENDIF("${isSystemDir}" STREQUAL "-1")
################## BRANCH INTO SUBDIRECTORIES ############################
#### LIBRARIES ####
# include source folder
include_directories ("${PROJECT_SOURCE_DIR}/src")
# include Examples folder
include_directories ("${PROJECT_SOURCE_DIR}/Examples")
# add the Options library
add_subdirectory (src/Options)
set (EXTRA_LIBS ${EXTRA_LIBS} Options)
# add the MatrixIO library
add_subdirectory (src/MatrixIO)
# is header only
# add the Solvers folder
add_subdirectory (src/Solvers)
set (EXTRA_LIBS ${EXTRA_LIBS} Solvers)
# add the Minimizations library
add_subdirectory (src/Minimizations)
set (EXTRA_LIBS ${EXTRA_LIBS} Minimizations)
# add the Math library
add_subdirectory (src/Math)
set (EXTRA_LIBS ${EXTRA_LIBS} Math)
# add the Database folder
add_subdirectory (src/Database)
set (EXTRA_LIBS ${EXTRA_LIBS} Database)
# add the Log folder
add_subdirectory (src/Log)
set (EXTRA_LIBS ${EXTRA_LIBS} Log)
#### PYTHON BINDINGS ####
add_subdirectory(src/Python)
#### EXECUTABLES ####
# add Examples folders of executables
add_subdirectory (Examples)
#### TESTS AND UNITTESTS ####
# add test folder
enable_testing () # must reside here
add_subdirectory (tests)
add_subdirectory (src/Database/unittests)
add_subdirectory (src/Math/unittests)
add_subdirectory (src/Minimizations/Elements/unittests)
add_subdirectory (src/Minimizations/Functions/unittests)
add_subdirectory (src/Minimizations/Mappings/unittests)
add_subdirectory (src/Minimizations/Minimizers/StoppingCriteria/unittests)
add_subdirectory (src/Minimizations/Norms/unittests)
add_subdirectory (src/Solvers/AuxiliaryConstraints/unittests)
add_subdirectory (Examples/ComputerTomography/DiscretizedRadon/unittests)
### DOXYGEN DOCUMENTATION
add_subdirectory (src/Documentation)
### Userguide
add_subdirectory (doc)
######################## RPATH settings ##################################
#
# see https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/RPATH-handling
#
##########################################################################
# use, i.e. don't skip the full RPATH for the build tree
SET(CMAKE_SKIP_BUILD_RPATH FALSE)
# when building, don't use the install RPATH already
# (but later on when installing)
SET(CMAKE_BUILD_WITH_INSTALL_RPATH FALSE)
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
# add the automatically determined parts of the RPATH
# which point to directories outside the build tree to the install RPATH
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# the RPATH to be used when installing, but only if it's not a system directory
LIST(FIND CMAKE_PLATFORM_IMPLICIT_LINK_DIRECTORIES "${CMAKE_INSTALL_PREFIX}/lib" isSystemDir)
IF("${isSystemDir}" STREQUAL "-1")
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib")
ENDIF("${isSystemDir}" STREQUAL "-1")
##################### PACKING INSTRUCTIONS ###############################
# build a CPack driven installer package
include (InstallRequiredSystemLibraries)
set (CPACK_RESOURCE_FILE_LICENSE
"${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
SET(CPACK_SET_DESTDIR "on")
SET(CPACK_PACKAGING_INSTALL_PREFIX "/tmp")
set(CPACK_GENERATOR "DEB")
SET(CPACK_PACKAGE_DESCRIPTION "Library for non-linear optimization in Banach spaces")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Solve (non-)linear system of equations in arbitrary lp-spaces")
SET(CPACK_PACKAGE_VENDOR "Frederik Heber")
SET(CPACK_PACKAGE_CONTACT "[email protected]")
set (CPACK_PACKAGE_VERSION_MAJOR "${Basso_VERSION_MAJOR}")
set (CPACK_PACKAGE_VERSION_MINOR "${Basso_VERSION_MINOR}")
SET(CPACK_PACKAGE_VERSION_PATCH "${Basso_VERSION_PATCH}")
SET(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${Basso_VERSION_MAJOR}.${Basso_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}_${Basso_VERSION_MAJOR}.${Basso_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set(CPACK_DEBIAN_PACKAGE_MAINTAINER "Frederik Heber")
SET(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
SET(CPACK_DEBIAN_PACKAGE_SECTION "science")
SET(CPACK_DEBIAN_ARCHITECTURE ${CMAKE_SYSTEM_PROCESSOR})
#set (CPACK_DEBIAN_PACKAGE_DEPENDS
# "libboost-chrono (>=1.61),
# libboost-log (>=1.61),
# libboost-filesystem (>=1.61),
# libboost-program_options (>=1.61),
# libboost-system (>=1.61)"
# )
include (CPack)
##########################################################################