-
Notifications
You must be signed in to change notification settings - Fork 2.1k
/
CMakeLists.txt
311 lines (289 loc) · 10.4 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
# ##############################################################################
# SWIG (WIN32)
# ##############################################################################
if(WIN32
AND (BUILD_PYTHON
OR BUILD_JAVA
OR BUILD_DOTNET))
message(CHECK_START "Fetching SWIG")
list(APPEND CMAKE_MESSAGE_INDENT " ")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/SWIG.CMakeLists.txt.in
${CMAKE_CURRENT_BINARY_DIR}/SWIG/CMakeLists.txt @ONLY)
execute_process(
COMMAND ${CMAKE_COMMAND} -H. -Bproject_build -G "${CMAKE_GENERATOR}"
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/SWIG)
if(result)
message(FATAL_ERROR "CMake step for SWIG failed: ${result}")
endif()
execute_process(
COMMAND ${CMAKE_COMMAND} --build project_build --config Release
RESULT_VARIABLE result
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/SWIG)
if(result)
message(FATAL_ERROR "Build step for SWIG failed: ${result}")
endif()
set(SWIG_EXECUTABLE
${CMAKE_CURRENT_BINARY_DIR}/SWIG/source/swig.exe
CACHE INTERNAL "swig.exe location" FORCE)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()
include(FetchContent)
set(FETCHCONTENT_QUIET OFF)
set(FETCHCONTENT_UPDATES_DISCONNECTED ON)
set(BUILD_SHARED_LIBS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
set(BUILD_TESTING OFF)
# ##############################################################################
# ZLIB
# ##############################################################################
if(BUILD_ZLIB)
message(CHECK_START "Fetching ZLIB")
list(APPEND CMAKE_MESSAGE_INDENT " ")
FetchContent_Declare(
zlib
GIT_REPOSITORY "https://github.com/madler/ZLIB.git"
GIT_TAG "v1.2.11"
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/ZLIB.patch")
FetchContent_MakeAvailable(zlib)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()
# ##############################################################################
# ABSEIL-CPP
# ##############################################################################
if(BUILD_absl)
message(CHECK_START "Fetching Abseil-cpp")
list(APPEND CMAKE_MESSAGE_INDENT " ")
set(ABSL_ENABLE_INSTALL ON)
FetchContent_Declare(
absl
GIT_REPOSITORY "https://github.com/abseil/abseil-cpp.git"
GIT_TAG "20211102.0"
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/abseil-cpp-20211102.0.patch")
FetchContent_MakeAvailable(absl)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()
# ##############################################################################
# Protobuf
# ##############################################################################
if(BUILD_Protobuf)
message(CHECK_START "Fetching Protobuf")
list(APPEND CMAKE_MESSAGE_INDENT " ")
set(protobuf_BUILD_TESTS OFF)
set(protobuf_BUILD_EXPORT OFF)
set(protobuf_MSVC_STATIC_RUNTIME OFF)
# FetchContent_Declare(SOURCE_SUBDIR) was introduced in 3.18
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.18")
FetchContent_Declare(
protobuf
GIT_REPOSITORY "https://github.com/protocolbuffers/protobuf.git"
GIT_TAG "v3.19.4"
GIT_SUBMODULES ""
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/protobuf-v3.19.4.patch"
SOURCE_SUBDIR cmake)
FetchContent_MakeAvailable(protobuf)
else()
fetch_git_dependency(
NAME Protobuf
REPOSITORY "https://github.com/protocolbuffers/protobuf.git"
TAG "v3.19.4"
PATCH_COMMAND "git apply --ignore-whitespace \"${CMAKE_CURRENT_LIST_DIR}/../../patches/protobuf-v3.19.4.patch\""
SOURCE_SUBDIR cmake
)
endif()
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()
# ##############################################################################
# RE2
# ##############################################################################
if(BUILD_re2)
message(CHECK_START "Fetching re2")
list(APPEND CMAKE_MESSAGE_INDENT " ")
set(ABSL_ENABLE_INSTALL ON)
FetchContent_Declare(
re2
GIT_REPOSITORY "https://github.com/google/re2.git"
GIT_TAG "2022-04-01"
#PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/re2-2022-04-01.patch"
)
FetchContent_MakeAvailable(re2)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()
# ##############################################################################
# EIGEN3
# ##############################################################################
if(BUILD_Eigen3)
message(CHECK_START "Fetching Eigen3")
list(APPEND CMAKE_MESSAGE_INDENT " ")
set(EIGEN_BUILD_PKGCONFIG OFF)
set(EIGEN_BUILD_DOC OFF)
set(EIGEN_BUILD_TESTING OFF)
set(EIGEN_BUILD_DOC OFF)
FetchContent_Declare(
eigen3
GIT_REPOSITORY "https://gitlab.com/libeigen/eigen.git"
GIT_TAG "3.4.0"
PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/eigen3-3.4.0.patch"
)
FetchContent_MakeAvailable(eigen3)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()
# ##############################################################################
# pybind11
# ##############################################################################
if(BUILD_PYTHON AND BUILD_pybind11)
# Find Python 3
find_package(Python3 REQUIRED COMPONENTS Interpreter Development.Module)
message(CHECK_START "Fetching pybind11")
list(APPEND CMAKE_MESSAGE_INDENT " ")
set(PYBIND11_INSTALL ON)
set(PYBIND11_TEST OFF)
FetchContent_Declare(
pybind11
GIT_REPOSITORY "https://github.com/pybind/pybind11.git"
GIT_TAG "v2.9.1"
#PATCH_COMMAND git apply --ignore-whitespace "${CMAKE_CURRENT_LIST_DIR}/../../patches/pybind11-2.9.1.patch"
)
FetchContent_MakeAvailable(pybind11)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()
# ##############################################################################
# SCIP
# ##############################################################################
if(BUILD_SCIP)
message(CHECK_START "Fetching SCIP")
list(APPEND CMAKE_MESSAGE_INDENT " ")
set(SHARED OFF)
set(READLINE OFF)
set(GMP OFF)
set(PAPILO OFF)
set(ZIMPL OFF)
set(IPOPT OFF)
set(AMPL OFF)
set(TPI "tny" CACHE STRING "Scip param")
set(EXPRINT "none" CACHE STRING "Scip param")
set(LPS "none" CACHE STRING "Scip param")
set(SYM "none" CACHE STRING "Scip param")
FetchContent_Declare(
scip
GIT_REPOSITORY "https://github.com/scipopt/scip.git"
GIT_TAG "v800"
)
FetchContent_MakeAvailable(scip)
set(LPI_GLOP_SRC ${scip_SOURCE_DIR}/src/lpi/lpi_glop.cpp PARENT_SCOPE)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()
# ##############################################################################
# GLPK
# ##############################################################################
if(BUILD_GLPK)
message(CHECK_START "Fetching GLPK")
list(APPEND CMAKE_MESSAGE_INDENT " ")
set(BUILD_EXAMPLES OFF)
set(WITH_GMP OFF)
set(WITH_ODBC OFF)
set(WITH_MYSQL OFF)
FetchContent_Declare(
glpk
GIT_REPOSITORY "https://github.com/Mizux/GLPK.git"
GIT_TAG "5.0"
)
FetchContent_MakeAvailable(glpk)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()
# ##############################################################################
# Coinutils
# ##############################################################################
# Coin-OR does not support C++17/C++20 (use of 'register' storage class specifier)
set(CMAKE_CXX_STANDARD 11)
if(BUILD_CoinUtils)
message(CHECK_START "Fetching CoinUtils")
list(APPEND CMAKE_MESSAGE_INDENT " ")
FetchContent_Declare(
CoinUtils
GIT_REPOSITORY "https://github.com/Mizux/CoinUtils.git"
GIT_TAG "cmake/2.11.6"
PATCH_COMMAND git apply --ignore-whitespace
"${CMAKE_CURRENT_LIST_DIR}/../../patches/coinutils-2.11.patch")
FetchContent_MakeAvailable(CoinUtils)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()
# ##############################################################################
# Osi
# ##############################################################################
if(BUILD_Osi)
message(CHECK_START "Fetching Osi")
list(APPEND CMAKE_MESSAGE_INDENT " ")
FetchContent_Declare(
Osi
GIT_REPOSITORY "https://github.com/Mizux/Osi.git"
GIT_TAG "cmake/0.108.7"
PATCH_COMMAND git apply --ignore-whitespace
"${CMAKE_CURRENT_LIST_DIR}/../../patches/osi-0.108.patch")
FetchContent_MakeAvailable(Osi)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()
# ##############################################################################
# Clp
# ##############################################################################
if(BUILD_Clp)
message(CHECK_START "Fetching Clp")
list(APPEND CMAKE_MESSAGE_INDENT " ")
FetchContent_Declare(
Clp
GIT_REPOSITORY "https://github.com/Mizux/Clp.git"
GIT_TAG "cmake/1.17.7"
PATCH_COMMAND git apply --ignore-whitespace
"${CMAKE_CURRENT_LIST_DIR}/../../patches/clp-1.17.4.patch")
FetchContent_MakeAvailable(Clp)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()
# ##############################################################################
# Cgl
# ##############################################################################
if(BUILD_Cgl)
message(CHECK_START "Fetching Cgl")
list(APPEND CMAKE_MESSAGE_INDENT " ")
FetchContent_Declare(
Cgl
GIT_REPOSITORY "https://github.com/Mizux/Cgl.git"
GIT_TAG "cmake/0.60.5"
PATCH_COMMAND git apply --ignore-whitespace
"${CMAKE_CURRENT_LIST_DIR}/../../patches/cgl-0.60.patch")
FetchContent_MakeAvailable(Cgl)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()
# ##############################################################################
# Cbc
# ##############################################################################
if(BUILD_Cbc)
message(CHECK_START "Fetching Cbc")
list(APPEND CMAKE_MESSAGE_INDENT " ")
FetchContent_Declare(
Cbc
GIT_REPOSITORY "https://github.com/Mizux/Cbc.git"
GIT_TAG "cmake/2.10.7"
PATCH_COMMAND git apply --ignore-whitespace
"${CMAKE_CURRENT_LIST_DIR}/../../patches/cbc-2.10.patch")
FetchContent_MakeAvailable(Cbc)
list(POP_BACK CMAKE_MESSAGE_INDENT)
message(CHECK_PASS "fetched")
endif()
if(MSVC)
set(CMAKE_CXX_STANDARD 20)
else()
set(CMAKE_CXX_STANDARD 17)
endif()