forked from chuffed/chuffed
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
431 lines (366 loc) · 14 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
431
cmake_minimum_required(VERSION 3.1.0)
project(chuffed CXX C)
# The version number.
set(chuffed_VERSION_MAJOR 0)
set(chuffed_VERSION_MINOR 13)
set(chuffed_VERSION_PATCH 0)
### Additional Definitions:
option(STATIC "compile with the -static linker flag" OFF)
option(CP_PROFILER "Build with the CP Profiler Integration" ON)
option(SUPPORT_VAR_IMPACT "Build with support for impact branching" OFF)
# ------------- Compiler Configuration -------------
if(STATIC)
set(CMAKE_EXE_LINKER_FLAGS "-static")
endif()
set(DEFAULT_BUILD_TYPE "Release")
if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
message(STATUS "Setting build type to '${DEFAULT_BUILD_TYPE}' as none was specified.")
set(CMAKE_BUILD_TYPE "${DEFAULT_BUILD_TYPE}" CACHE STRING "Choose the type of build." FORCE)
# Set the possible values of build type for cmake-gui
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS
"Debug"
"Release"
"MinSizeRel"
"RelWithDebInfo"
)
endif()
if(APPLE)
execute_process(COMMAND xcrun --show-sdk-path OUTPUT_VARIABLE OSX_SYSROOT OUTPUT_STRIP_TRAILING_WHITESPACE)
set(CMAKE_OSX_SYSROOT ${OSX_SYSROOT})
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment version")
endif(APPLE)
set(CMAKE_CXX_STANDARD 11)
find_package(Threads)
include_directories(${CMAKE_BINARY_DIR})
include_directories(${CMAKE_SOURCE_DIR})
if(WIN32)
add_definitions(-DYY_NO_UNISTD_H)
endif()
# ------------- CP Profiler Integration -------------
add_library(thirdparty_cp_profiler OBJECT
thirdparty/cp-profiler-integration/connector.hpp
thirdparty/cp-profiler-integration/message.hpp
)
set_target_properties(thirdparty_cp_profiler PROPERTIES LINKER_LANGUAGE CXX)
set_target_properties(thirdparty_cp_profiler PROPERTIES
CXX_CLANG_TIDY ""
)
# ---------- Support for impact branching -----------
if(SUPPORT_VAR_IMPACT)
add_definitions(-DHAS_VAR_IMPACT)
set(VAR_IMPACT_SOURCES
chuffed/branching/impact.cpp
)
endif()
# ------------- Murmur Hash 3 -------------
add_library(thirdparty_murmur OBJECT
thirdparty/MurmurHash3/MurmurHash3.cpp
thirdparty/MurmurHash3/MurmurHash3.h
)
set_target_properties(thirdparty_murmur PROPERTIES
CXX_CLANG_TIDY ""
)
# ------------- Main Chuffed Definition -------------
add_library(chuffed
chuffed/vars/int-var.cpp
chuffed/vars/int-var-el.cpp
chuffed/vars/modelling.cpp
chuffed/vars/int-var-sl.cpp
chuffed/vars/bool-view.cpp
chuffed/vars/int-var-ll.cpp
chuffed/ldsb/ldsb.cpp
chuffed/globals/subcircuit.cpp
chuffed/globals/mddglobals.cpp
chuffed/globals/sym-break.cpp
chuffed/globals/linear-bool.cpp
chuffed/globals/linear-bool-decomp.cpp
chuffed/globals/well-founded.cpp
chuffed/globals/circuit.cpp
chuffed/globals/minimum.cpp
chuffed/globals/bool_arg_max.cpp
chuffed/globals/alldiff.cpp
chuffed/globals/template.cpp
chuffed/globals/directives.cpp
chuffed/globals/cumulative.cpp
chuffed/globals/cumulativeCalendar.cpp
chuffed/globals/disjunctive.cpp
chuffed/globals/regular.cpp
chuffed/globals/lex.cpp
chuffed/globals/table.cpp
chuffed/globals/edit_distance.cpp
chuffed/globals/EdExplFinder.cpp
chuffed/globals/EdExplFinder.h
chuffed/globals/value-precede.cpp
chuffed/globals/graph.cpp
chuffed/globals/tree.cpp
chuffed/globals/minimum_weight_tree.cpp
chuffed/globals/mst.cpp
chuffed/globals/dconnected.cpp
chuffed/globals/dtree.cpp
chuffed/globals/dag.cpp
chuffed/globals/bounded_path.cpp
chuffed/mdd/MDD.cpp
chuffed/mdd/mdd_prop.cpp
chuffed/mdd/mdd_to_lgraph.cpp
chuffed/mdd/opcache.cpp
chuffed/mdd/weighted_dfa.cpp
chuffed/mdd/wmdd_prop.cpp
chuffed/mip/mip.cpp
chuffed/mip/recalc.cpp
chuffed/mip/simplex.cpp
chuffed/primitives/element.cpp
chuffed/primitives/bool.cpp
chuffed/primitives/linear.cpp
chuffed/primitives/arithmetic.cpp
chuffed/primitives/domain.cpp
chuffed/primitives/binary.cpp
chuffed/branching/branching.cpp
chuffed/core/init.cpp
chuffed/core/stats.cpp
chuffed/core/engine.cpp
chuffed/core/options.cpp
chuffed/core/sat.cpp
chuffed/core/conflict.cpp
chuffed/vars/int-var.h
chuffed/vars/vars.h
chuffed/vars/int-var-sl.h
chuffed/vars/int-var-ll.h
chuffed/vars/int-view.h
chuffed/vars/int-var-el.h
chuffed/vars/modelling.h
chuffed/vars/bool-view.h
chuffed/support/BVec.h
chuffed/support/ParseUtils.h
chuffed/support/vec.h
chuffed/support/misc.h
chuffed/support/heap.h
chuffed/support/sparse_set.h
chuffed/support/union_find.h
chuffed/support/union_find.cpp
chuffed/support/trailed_cst_list.h
chuffed/support/lengauer_tarjan.h
chuffed/support/lengauer_tarjan.cpp
chuffed/support/dijkstra.h
chuffed/support/dijkstra.cpp
chuffed/support/kosaraju_scc.h
chuffed/support/kosaraju_scc.cpp
chuffed/support/dynamic_kmeans.h
chuffed/support/floyd_warshall.h
chuffed/support/set_finder.h
chuffed/ldsb/ldsb.h
chuffed/globals/globals.h
chuffed/globals/mddglobals.h
chuffed/mdd/CFG.h
chuffed/mdd/circ_fns.h
chuffed/mdd/circutil.h
chuffed/mdd/CYK.h
chuffed/mdd/MDD.h
chuffed/mdd/mdd_prop.h
chuffed/mdd/mdd_to_lgraph.h
chuffed/mdd/opcache.h
chuffed/mdd/opts.h
chuffed/mdd/sorters.h
chuffed/mdd/weighted_dfa.h
chuffed/mdd/wmdd_prop.h
chuffed/mip/mip.h
chuffed/mip/simplex.h
chuffed/primitives/primitives.h
chuffed/branching/branching.h
chuffed/core/sat.h
chuffed/core/engine.h
chuffed/core/sat-types.h
chuffed/core/options.h
chuffed/core/propagator.h
${VAR_IMPACT_SOURCES}
$<TARGET_OBJECTS:thirdparty_cp_profiler>
$<TARGET_OBJECTS:thirdparty_murmur>
)
if(CP_PROFILER)
target_compile_definitions(chuffed PRIVATE HAS_PROFILER)
endif()
# ------------- FZN Chuffed -------------
find_package(BISON 3.4)
if(BISON_FOUND)
file(MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/chuffed/flatzinc/generated_parser)
bison_target(FZNParser
${PROJECT_SOURCE_DIR}/chuffed/flatzinc/parser.yxx
${PROJECT_BINARY_DIR}/parser.tab.cpp
DEFINES_FILE ${PROJECT_BINARY_DIR}/chuffed/flatzinc/generated_parser/parser.tab.h
COMPILE_FLAGS "-l"
)
else()
message(WARNING "Bison cannot be run. Using cached file, which may be out of date.")
set(BISON_FZNParser_OUTPUTS
${PROJECT_SOURCE_DIR}/chuffed/flatzinc/generated_parser/parser.tab.cpp
${PROJECT_SOURCE_DIR}/chuffed/flatzinc/generated_parser/parser.tab.h
)
endif()
find_package(FLEX)
if(FLEX_FOUND AND BISON_FOUND)
flex_target(FZNLexer
${PROJECT_SOURCE_DIR}/chuffed/flatzinc/lexer.lxx
${PROJECT_BINARY_DIR}/lexer.yy.cpp
COMPILE_FLAGS "-L"
)
add_flex_bison_dependency(FZNLexer FZNParser)
else()
message(WARNING "Flex cannot be run. Using cached file, which may be out of date.")
set(FLEX_FZNLexer_OUTPUTS ${PROJECT_SOURCE_DIR}/chuffed/flatzinc/generated_parser/lexer.yy.cpp)
endif()
add_library(flatzinc_parser OBJECT
${FLEX_FZNLexer_OUTPUTS}
${BISON_FZNParser_OUTPUTS}
)
set_target_properties(flatzinc_parser PROPERTIES
CXX_CLANG_TIDY ""
)
add_library(chuffed_fzn
chuffed/flatzinc/registry.cpp
chuffed/flatzinc/flatzinc.cpp
chuffed/flatzinc/flatzinc.h
chuffed/flatzinc/ast.h
$<TARGET_OBJECTS:flatzinc_parser>
)
add_executable(fzn-chuffed chuffed/flatzinc/fzn-chuffed.cpp)
target_link_libraries(fzn-chuffed chuffed_fzn chuffed ${CMAKE_THREAD_LIBS_INIT})
# ------------- Chuffed Examples -------------
add_executable(bibd EXCLUDE_FROM_ALL chuffed/examples/bibd.cpp)
target_link_libraries(bibd chuffed_fzn chuffed ${CMAKE_THREAD_LIBS_INIT})
add_executable(blackhole EXCLUDE_FROM_ALL chuffed/examples/blackhole.cpp)
target_link_libraries(blackhole chuffed_fzn chuffed ${CMAKE_THREAD_LIBS_INIT})
add_executable(concert_hall EXCLUDE_FROM_ALL chuffed/examples/concert_hall.cpp)
target_link_libraries(concert_hall chuffed_fzn chuffed ${CMAKE_THREAD_LIBS_INIT})
add_executable(concert_hall_sym EXCLUDE_FROM_ALL chuffed/examples/concert_hall_sym.cpp)
target_link_libraries(concert_hall_sym chuffed_fzn chuffed ${CMAKE_THREAD_LIBS_INIT})
add_executable(golomb EXCLUDE_FROM_ALL chuffed/examples/golomb.cpp)
target_link_libraries(golomb chuffed_fzn chuffed ${CMAKE_THREAD_LIBS_INIT})
add_executable(graceful_graph EXCLUDE_FROM_ALL chuffed/examples/graceful_graph.cpp)
target_link_libraries(graceful_graph chuffed_fzn chuffed ${CMAKE_THREAD_LIBS_INIT})
add_executable(graph_colouring EXCLUDE_FROM_ALL chuffed/examples/graph_colouring.cpp)
target_link_libraries(graph_colouring chuffed_fzn chuffed ${CMAKE_THREAD_LIBS_INIT})
add_executable(graph_colouring_sym EXCLUDE_FROM_ALL chuffed/examples/graph_colouring_sym.cpp)
target_link_libraries(graph_colouring_sym chuffed_fzn chuffed ${CMAKE_THREAD_LIBS_INIT})
add_executable(graph_colouring_sym2 EXCLUDE_FROM_ALL chuffed/examples/graph_colouring_sym2.cpp)
target_link_libraries(graph_colouring_sym2 chuffed_fzn chuffed ${CMAKE_THREAD_LIBS_INIT})
add_executable(grid_colouring EXCLUDE_FROM_ALL chuffed/examples/grid_colouring.cpp)
target_link_libraries(grid_colouring chuffed_fzn chuffed ${CMAKE_THREAD_LIBS_INIT})
add_executable(latin_square EXCLUDE_FROM_ALL chuffed/examples/latin_square.cpp)
target_link_libraries(latin_square chuffed_fzn chuffed ${CMAKE_THREAD_LIBS_INIT})
add_executable(magic_square EXCLUDE_FROM_ALL chuffed/examples/magic_square.cpp)
target_link_libraries(magic_square chuffed_fzn chuffed ${CMAKE_THREAD_LIBS_INIT})
add_executable(mosp EXCLUDE_FROM_ALL chuffed/examples/mosp.cpp)
target_link_libraries(mosp chuffed_fzn chuffed ${CMAKE_THREAD_LIBS_INIT})
add_executable(nn_queens EXCLUDE_FROM_ALL chuffed/examples/nn_queens.cpp)
target_link_libraries(nn_queens chuffed_fzn chuffed ${CMAKE_THREAD_LIBS_INIT})
add_executable(non EXCLUDE_FROM_ALL chuffed/examples/non.cpp)
target_link_libraries(non chuffed_fzn chuffed ${CMAKE_THREAD_LIBS_INIT})
add_executable(photo EXCLUDE_FROM_ALL chuffed/examples/photo.cpp)
target_link_libraries(photo chuffed_fzn chuffed ${CMAKE_THREAD_LIBS_INIT})
add_executable(queens EXCLUDE_FROM_ALL chuffed/examples/queens.cpp)
target_link_libraries(queens chuffed_fzn chuffed ${CMAKE_THREAD_LIBS_INIT})
add_executable(rcpsp EXCLUDE_FROM_ALL chuffed/examples/rcpsp.cpp)
target_link_libraries(rcpsp chuffed_fzn chuffed ${CMAKE_THREAD_LIBS_INIT})
add_executable(shift EXCLUDE_FROM_ALL chuffed/examples/shift.cpp)
target_link_libraries(shift chuffed_fzn chuffed ${CMAKE_THREAD_LIBS_INIT})
add_executable(steel_mill EXCLUDE_FROM_ALL chuffed/examples/steel_mill.cpp)
target_link_libraries(steel_mill chuffed_fzn chuffed ${CMAKE_THREAD_LIBS_INIT})
add_executable(wreg_shift EXCLUDE_FROM_ALL chuffed/examples/wreg_shift.cpp)
target_link_libraries(wreg_shift chuffed_fzn chuffed ${CMAKE_THREAD_LIBS_INIT})
find_package(ZLIB)
if(ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIRS})
add_executable(cross EXCLUDE_FROM_ALL chuffed/examples/cross.cpp)
target_link_libraries(cross chuffed_fzn chuffed ${CMAKE_THREAD_LIBS_INIT} ${ZLIB_LIBRARIES})
add_executable(fdpent EXCLUDE_FROM_ALL chuffed/examples/fdpent.cpp)
target_link_libraries(fdpent chuffed_fzn chuffed ${CMAKE_THREAD_LIBS_INIT} ${ZLIB_LIBRARIES})
add_executable(nurse EXCLUDE_FROM_ALL chuffed/examples/nurse.cpp)
target_link_libraries(nurse chuffed_fzn chuffed ${CMAKE_THREAD_LIBS_INIT} ${ZLIB_LIBRARIES})
set(ZLIB_EXAMPLES
cross
fdpent
nurse
)
endif()
add_custom_target(examples)
add_dependencies(examples
bibd
blackhole
concert_hall
concert_hall_sym
golomb
graceful_graph
graph_colouring
graph_colouring_sym
graph_colouring_sym2
grid_colouring
latin_square
magic_square
mosp
nn_queens
non
photo
queens
rcpsp
shift
steel_mill
wreg_shift
${ZLIB_EXAMPLES}
)
# ------------- TARGET install -------------
include(GNUInstallDirs)
file(RELATIVE_PATH REL_INSTALL_BINARY ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_DATAROOTDIR}/minizinc/solvers ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/fzn-chuffed)
configure_file(chuffed.msc.in chuffed.msc)
install(TARGETS fzn-chuffed RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(
TARGETS chuffed chuffed_fzn
EXPORT chuffed-targets
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
install(
DIRECTORY chuffed
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
FILES_MATCHING PATTERN "*.h"
)
install(DIRECTORY chuffed/flatzinc/mznlib/ DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/minizinc/chuffed PATTERN "chuffed/flatzinc/mznlib/*")
install(FILES ${CMAKE_BINARY_DIR}/chuffed.msc DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/minizinc/solvers)
# ------------- CMake export configuration -------------
include(CMakePackageConfigHelpers)
export(EXPORT chuffed-targets FILE ${CMAKE_CURRENT_BINARY_DIR}/cmake/chuffed-targets.cmake)
configure_package_config_file(
${CMAKE_CURRENT_SOURCE_DIR}/chuffed-config.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/chuffed-config.cmake"
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/chuffed
)
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/chuffed-config-version.cmake"
VERSION "${chuffed_VERSION_MAJOR}.${chuffed_VERSION_MINOR}.${chuffed_VERSION_PATCH}"
COMPATIBILITY AnyNewerVersion
)
install(EXPORT chuffed-targets DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/chuffed)
install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/chuffed-config.cmake"
FILES "${CMAKE_CURRENT_BINARY_DIR}/chuffed-config-version.cmake"
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/chuffed
)
# ------------- TARGET format -------------
if (NOT CLANG_FORMAT_EXECUTABLE)
find_program(CLANG_FORMAT_EXECUTABLE NAMES clang-format clang-format-11 clang-format-10 clang-format-9)
endif()
set(CLANG_FORMAT_FLAGS "-i" CACHE STRING "Flags passed to the clang-format executable")
if (CLANG_FORMAT_EXECUTABLE)
file(GLOB_RECURSE FORMAT_FILES
${PROJECT_SOURCE_DIR}/*.c
${PROJECT_SOURCE_DIR}/*.cpp
${PROJECT_SOURCE_DIR}/*.h
${PROJECT_SOURCE_DIR}/*.hh
${PROJECT_SOURCE_DIR}/*.hpp
)
list(FILTER FORMAT_FILES EXCLUDE REGEX ${PROJECT_BINARY_DIR}/*)
list(FILTER FORMAT_FILES EXCLUDE REGEX ${PROJECT_SOURCE_DIR}/thirdparty/*)
list(FILTER FORMAT_FILES EXCLUDE REGEX ${PROJECT_SOURCE_DIR}/chuffed/flatzinc/generated_parser/*)
separate_arguments(CLANG_FORMAT_FLAGS_LIST NATIVE_COMMAND ${CLANG_FORMAT_FLAGS})
add_custom_target(format
COMMAND ${CLANG_FORMAT_EXECUTABLE} ${CLANG_FORMAT_FLAGS_LIST} ${FORMAT_FILES}
COMMENT "Running ${CLANG_FORMAT_EXECUTABLE} on all source files"
)
endif()