-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
145 lines (125 loc) · 5.37 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
cmake_minimum_required(VERSION 3.12)
project(Tiler)
set(CMAKE_CXX_STANDARD 17)
# default build type is Release
if (NOT CMAKE_BUILD_TYPE OR CMAKE_BUILD_TYPE STREQUAL "")
set(CMAKE_BUILD_TYPE "Release" CACHE STRING "" FORCE)
endif()
include(cmake/CompilerWarnings.cmake)
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
set(CONAN_SYSTEM_INCLUDES ON) # so that compiler warnings don't apply to conan dependencies
conan_basic_setup()
# load src directory, excluding main.cpp
include_directories(src)
file(GLOB_RECURSE PROJECT_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp")
set(PROJECT_MAIN "${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp")
list(REMOVE_ITEM PROJECT_SOURCE ${PROJECT_MAIN})
# external libraries
set(EXTERNAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/external")
set(SOLVERS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/solvers")
option(DLX "Include Knuth's DLX algorithm." ON)
if(DLX)
add_compile_definitions(DLX)
link_directories("${EXTERNAL_DIR}/dlx1/build")
set(MY_LINK_OPTIONS ${MY_LINK_OPTIONS} dlx)
else()
list(REMOVE_ITEM PROJECT_SOURCE "${SOLVERS_DIR}/dlx/dlx_wrapper.cpp")
endif()
option(CADICAL "Include the CaDiCaL SAT solver." ON)
if(CADICAL)
add_compile_definitions(CADICAL)
include_directories(SYSTEM "${EXTERNAL_DIR}/cadical/src")
link_directories("${EXTERNAL_DIR}/cadical/build")
set(MY_LINK_OPTIONS ${MY_LINK_OPTIONS} cadical)
else()
list(REMOVE_ITEM PROJECT_SOURCE "${SOLVERS_DIR}/sat/cadical_wrapper.cpp")
endif()
option(CRYPTOMINISAT "Include the CryptoMiniSat SAT solver." ON)
if(CRYPTOMINISAT)
add_compile_definitions(CRYPTOMINISAT)
include_directories(SYSTEM "${EXTERNAL_DIR}/cryptominisat/build/include")
link_directories("${EXTERNAL_DIR}/cryptominisat/build/lib")
set(MY_LINK_OPTIONS ${MY_LINK_OPTIONS} cryptominisat5)
else()
list(REMOVE_ITEM PROJECT_SOURCE "${SOLVERS_DIR}/sat/cryptominisat_wrapper.cpp")
endif()
option(KISSAT "Include the Kissat SAT solver." ON)
if(KISSAT)
add_compile_definitions(KISSAT)
include_directories(SYSTEM "${EXTERNAL_DIR}/kissat/src")
link_directories("${EXTERNAL_DIR}/kissat/build")
set(MY_LINK_OPTIONS ${MY_LINK_OPTIONS} kissat)
else()
list(REMOVE_ITEM PROJECT_SOURCE "${SOLVERS_DIR}/sat/kissat_wrapper.cpp")
endif()
option(BREAKID "Include the BreakID CNF symmetry breaking library." ON)
if(BREAKID)
add_compile_definitions(BREAKID)
include_directories(SYSTEM "${EXTERNAL_DIR}/breakid/build/include")
link_directories("${EXTERNAL_DIR}/breakid/build/lib")
set(MY_LINK_OPTIONS ${MY_LINK_OPTIONS} breakid)
else()
list(REMOVE_ITEM PROJECT_SOURCE "${SOLVERS_DIR}/sat/breakid_wrapper.cpp")
endif()
option(SBVA "Include the SBVA CNF preprocessing library." ON)
if(SBVA)
add_compile_definitions(SBVA)
link_directories("${EXTERNAL_DIR}/SBVA/build")
set(MY_LINK_OPTIONS ${MY_LINK_OPTIONS} sbva)
else()
list(REMOVE_ITEM PROJECT_SOURCE "${SOLVERS_DIR}/sat/sbva_wrapper.cpp")
endif()
if(CADICAL OR CRYPTOMINISAT OR KISSAT)
add_compile_definitions(PBLIB)
include_directories(SYSTEM "${EXTERNAL_DIR}/pblib/pblib")
link_directories("${EXTERNAL_DIR}/pblib/build")
set(MY_LINK_OPTIONS ${MY_LINK_OPTIONS} pb)
else()
list(REMOVE_ITEM PROJECT_SOURCE "${SOLVERS_DIR}/sat/pblib_wrapper.cpp")
endif()
option(GUROBI "Link against the Gurobi ILP solver." ON)
if(GUROBI)
add_compile_definitions(GUROBI)
include_directories(SYSTEM "$ENV{GUROBI_HOME}/include")
set(MY_LINK_OPTIONS ${MY_LINK_OPTIONS} gurobi100 gurobi_g++5.2)
else()
list(REMOVE_ITEM PROJECT_SOURCE "${SOLVERS_DIR}/ilp/gurobi_wrapper.cpp")
endif()
option(MINIZINC "Include the MiniZinc and Gecode constraint solving tools." ON)
if(MINIZINC)
add_compile_definitions(MINIZINC)
include_directories(SYSTEM "${EXTERNAL_DIR}/libminizinc/include")
include_directories(SYSTEM "${EXTERNAL_DIR}/libminizinc/build/include")
link_directories("${EXTERNAL_DIR}/libminizinc/build")
link_directories("${EXTERNAL_DIR}/gecode/build")
set(MY_LINK_OPTIONS ${MY_LINK_OPTIONS} mzn gecodedriver gecodeflatzinc gecodefloat gecodeint gecodekernel gecodeminimodel gecodesearch gecodeset gecodesupport)
else()
list(REMOVE_ITEM PROJECT_SOURCE "${SOLVERS_DIR}/csp/minizinc_wrapper.cpp")
endif()
option(CHUFFED "In addition to MiniZinc with Gecode, include also the Chuffed solver." ON)
if(CHUFFED)
add_compile_definitions(CHUFFED)
endif()
# compile "tilerlib" - entire source without main.cpp so we don't have to recompile
# it when building tests
add_library(tilerlib STATIC ${PROJECT_SOURCE})
target_link_libraries(tilerlib ${MY_LINK_OPTIONS})
target_compile_options(tilerlib PRIVATE ${PROJECT_WARNINGS})
# build main executable
add_executable(tiler ${PROJECT_MAIN})
target_link_libraries(tiler tilerlib ${CONAN_LIBS})
target_compile_options(tiler PRIVATE ${PROJECT_WARNINGS})
# build test executable
option(BUILD_TESTS "Build the testing executable (from the 'test' directory)." OFF)
if(BUILD_TESTS)
file(GLOB_RECURSE TEST_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/test/*.cpp")
add_executable(tilertest ${TEST_SOURCE})
target_link_libraries(tilertest tilerlib ${CONAN_LIBS})
endif()
# build benchmark executable
option(BUILD_BENCHMARK "Build the benchmark executable (from the 'benchmark' directory)." OFF)
if(BUILD_BENCHMARK)
file(GLOB_RECURSE BENCHMARK_SOURCE "${CMAKE_CURRENT_SOURCE_DIR}/benchmark/*.cpp")
add_executable(tilerbm ${BENCHMARK_SOURCE})
target_link_libraries(tilerbm tilerlib ${CONAN_LIBS})
endif()