1
+ # VolEsti (volume computation and sampling library)
2
+
3
+ # Copyright (c) 2012-2024 Vissarion Fisikopoulos
4
+ # Copyright (c) 2018-2024 Apostolos Chalkis
5
+ # Copyright (c) 2024 Vladimir Necula
6
+
7
+ # Contributed and/or modified by Vladimir Necula, as part of Google Summer of
8
+ # Code 2024 program.
9
+
10
+ # Licensed under GNU LGPL.3, see LICENCE file
11
+
12
+ project ( VolEsti )
13
+
14
+
15
+ CMAKE_MINIMUM_REQUIRED (VERSION 3.11)
16
+
17
+ set (CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true )
18
+
19
+ # Locate Intel MKL root (in case it is enabled)
20
+ if (APPLE )
21
+ set (MKLROOT /opt/intel/oneapi/mkl/latest)
22
+ elseif (UNIX )
23
+ #set(MKLROOT /opt/intel/oneapi/mkl/latest)
24
+ set (MKLROOT $ENV{HOME} /intel/mkl)
25
+ endif ()
26
+
27
+ if (COMMAND cmake_policy)
28
+ cmake_policy (SET CMP0003 NEW)
29
+ endif (COMMAND cmake_policy)
30
+
31
+
32
+ option (DISABLE_NLP_ORACLES "Disable non-linear oracles (used in collocation)" ON )
33
+ option (BUILTIN_EIGEN "Use eigen from ../../external" OFF )
34
+ option (USE_MKL "Use MKL library to build eigen" OFF )
35
+
36
+
37
+ if (DISABLE_NLP_ORACLES)
38
+ add_definitions (-DDISABLE_NLP_ORACLES)
39
+ else ()
40
+ find_library (IFOPT NAMES libifopt_core.so PATHS /usr/local/lib)
41
+ find_library (IFOPT_IPOPT NAMES libifopt_ipopt.so PATHS /usr/local/lib)
42
+ find_library (GMP NAMES libgmp.so PATHS /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu)
43
+ find_library (MPSOLVE NAMES libmps.so PATHS /usr/local/lib)
44
+ find_library (PTHREAD NAMES libpthread.so PATHS /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu)
45
+ find_library (FFTW3 NAMES libfftw3.so.3 PATHS /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu)
46
+
47
+ if (NOT IFOPT)
48
+
49
+ message (FATAL_ERROR "This program requires the ifopt library, and will not be compiled." )
50
+
51
+ elseif (NOT GMP)
52
+
53
+ message (FATAL_ERROR "This program requires the gmp library, and will not be compiled." )
54
+
55
+ elseif (NOT MPSOLVE)
56
+
57
+ message (FATAL_ERROR "This program requires the mpsolve library, and will not be compiled." )
58
+
59
+ elseif (NOT FFTW3)
60
+
61
+ message (FATAL_ERROR "This program requires the fftw3 library, and will not be compiled." )
62
+
63
+ else ()
64
+ message (STATUS "Library ifopt found: ${IFOPT} " )
65
+ message (STATUS "Library gmp found: ${GMP} " )
66
+ message (STATUS "Library mpsolve found: ${MPSOLVE} " )
67
+ message (STATUS "Library fftw3 found:" ${FFTW3} )
68
+
69
+ endif (NOT IFOPT)
70
+
71
+ endif (DISABLE_NLP_ORACLES)
72
+
73
+ include ("../../external/cmake-files/Eigen.cmake" )
74
+ GetEigen()
75
+
76
+ include ("../../external/cmake-files/Boost.cmake" )
77
+ GetBoost()
78
+
79
+ include ("../../external/cmake-files/LPSolve.cmake" )
80
+ GetLPSolve()
81
+
82
+ include ("../../external/cmake-files/QD.cmake" )
83
+ GetQD()
84
+
85
+ # Find lpsolve library
86
+ find_library (LP_SOLVE NAMES liblpsolve55.so PATHS /usr/lib/lp_solve)
87
+
88
+ if (NOT LP_SOLVE)
89
+ message (FATAL_ERROR "This program requires the lp_solve library, and will not be compiled." )
90
+ else ()
91
+ message (STATUS "Library lp_solve found: ${LP_SOLVE} " )
92
+
93
+ set (CMAKE_EXPORT_COMPILE_COMMANDS "ON" )
94
+
95
+ if (USE_MKL)
96
+ find_library (BLAS NAMES libblas.so libblas.dylib PATHS /usr/local/Cellar/lapack/3.9.1_1/lib /usr/lib/x86_64-linux-gnu /usr/lib/i386-linux-gnu /usr/local/Cellar/openblas/0.3.15_1/lib /usr/lib)
97
+ find_library (GFORTRAN NAME libgfortran.dylib PATHS /usr/local/Cellar/gcc/10.2.0_4/lib/gcc/10)
98
+ find_library (LAPACK NAME liblapack.dylib PATHS /usr/lib)
99
+ find_library (OPENMP NAME libiomp5.dylib PATHS /opt/intel/oneapi/compiler/2021.1.1/mac/compiler/lib)
100
+
101
+ include_directories (BEFORE ${MKLROOT} /include )
102
+ set (PROJECT_LIBS ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES} ${GFORTRAN_LIBRARIES} )
103
+ set (MKL_LINK "-L${MKLROOT} /lib -Wl,-rpath,${MKLROOT} /lib -lmkl_intel_ilp64 -lmkl_sequential -lmkl_core -lpthread -lm -ldl" )
104
+ add_definitions (-DEIGEN_USE_MKL_ALL)
105
+ else ()
106
+ set (MKL_LINK "" )
107
+ endif (USE_MKL)
108
+
109
+ include_directories (BEFORE ../../external)
110
+ include_directories (BEFORE ../../external/minimum_ellipsoid)
111
+ include_directories (BEFORE ../../include /)
112
+
113
+ # for Eigen
114
+ if (${CMAKE_VERSION} VERSION_LESS "3.12.0" )
115
+ add_compile_options (-D "EIGEN_NO_DEBUG" )
116
+ else ()
117
+ add_compile_definitions ("EIGEN_NO_DEBUG" )
118
+ endif ()
119
+
120
+
121
+ add_definitions (${CMAKE_CXX_FLAGS} "-std=c++17" ) # enable C++17 standard
122
+ set (ADDITIONAL_FLAGS "-march=native -DSIMD_LEN=0 -DTIME_KEEPING" )
123
+ add_definitions (${CMAKE_CXX_FLAGS} "-O3 -DTIME_KEEPING" ${ADDITIONAL_FLAGS} ) # optimization of the compiler
124
+ #add_definitions(${CXX_COVERAGE_COMPILE_FLAGS} "-lgsl")
125
+ add_definitions (${CXX_COVERAGE_COMPILE_FLAGS} "-lm" )
126
+ add_definitions (${CXX_COVERAGE_COMPILE_FLAGS} "-ldl" )
127
+ add_definitions (${CXX_COVERAGE_COMPILE_FLAGS} "-DBOOST_NO_AUTO_PTR" )
128
+
129
+ add_executable (volume_example volume_example.cpp)
130
+ target_link_libraries (volume_example QD_LIB ${MKL_LINK} ${LP_SOLVE} )
131
+
132
+ endif ()
0 commit comments