-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
277 lines (220 loc) · 10.9 KB
/
Copy pathCMakeLists.txt
File metadata and controls
277 lines (220 loc) · 10.9 KB
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
cmake_minimum_required(VERSION 3.28)
project(Pathfinder)
if(POLICY CMP0167)
cmake_policy(SET CMP0167 NEW)
endif()
# Normal variables
set(CMAKE_CXX_STANDARD 23)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/Module Properties")
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
# Cache entries
set(INCLUDE_TESTS OFF CACHE BOOL "Whether or not unit tests should be built alongside the Pathfinder.")
set(LINK_TBB OFF CACHE BOOL "Whether or not TBB should be linked.")
# Environment variables
set(ENV{CTEST_OUTPUT_ON_FAILURE} ON)
if(${LINK_TBB})
find_package(TBB REQUIRED COMPONENTS tbb)
endif()
find_package(Boost 1.83 REQUIRED COMPONENTS filesystem system)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
endif()
find_package(nlohmann_json REQUIRED)
if(${WIN32})
find_package(unofficial-getopt-win32 REQUIRED)
endif()
if(NOT "${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_LIST_DIR}")
if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/Moves)
add_custom_target(clear_moves
COMMAND rm -r "${CMAKE_CURRENT_BINARY_DIR}/Moves"
)
endif()
add_custom_target(copy_moves
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_LIST_DIR}/Moves ${CMAKE_CURRENT_BINARY_DIR}/Moves
)
add_custom_target(copy_examples
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_LIST_DIR}/docs/examples ${CMAKE_CURRENT_BINARY_DIR}/docs/examples
)
add_custom_target(copy_properties
COMMAND ${CMAKE_COMMAND} -E copy_directory "${CMAKE_CURRENT_LIST_DIR}/Module Properties" "${CMAKE_CURRENT_BINARY_DIR}/Module Properties"
)
add_custom_target(copy_resources
COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_LIST_DIR}/Test-Resources ${CMAKE_CURRENT_BINARY_DIR}/Test-Resources
)
endif()
# Base Property Library
add_library(PropertyLib SHARED pathfinder/modules/ModuleProperties.cpp)
target_link_libraries(PropertyLib ${Boost_LIBRARIES})
target_link_libraries(PropertyLib Boost::system)
target_link_libraries(PropertyLib Boost::filesystem)
set_target_properties(PropertyLib PROPERTIES PREFIX "")
# Color Property
add_library(ColorPropertyLib MODULE pathfinder/properties/Colors.cpp pathfinder/utility/color_util.cpp)
set_target_properties(ColorPropertyLib PROPERTIES PREFIX "")
target_link_libraries(ColorPropertyLib PropertyLib)
add_dependencies(ColorPropertyLib PropertyLib)
# Orientation Property
add_library(OrientationPropertyLib MODULE EXCLUDE_FROM_ALL pathfinder/properties/Orientation.cpp)
set_target_properties(OrientationPropertyLib PROPERTIES PREFIX "")
target_link_libraries(OrientationPropertyLib PropertyLib)
add_dependencies(OrientationPropertyLib PropertyLib)
# Pathfinder
if(${INCLUDE_TESTS})
set(Targets Pathfinder Pathfinder_Standard Pathfinder_Rhombic Pathfinder_Parallel Pathfinder_FullCheck)
else()
set(Targets Pathfinder)
endif()
foreach (TARGET ${Targets})
add_executable(${TARGET}
pathfinder/main.cpp
pathfinder/utility/debug_util.h
pathfinder/modules/ModuleManager.h
pathfinder/modules/ModuleManager.cpp
pathfinder/moves/MoveManager.h
pathfinder/moves/MoveManager.cpp
pathfinder/lattice/Lattice.h
pathfinder/lattice/Lattice.cpp
pathfinder/lattice/LatticeSetup.h
pathfinder/lattice/LatticeSetup.cpp
pathfinder/moves/Scenario.h
pathfinder/moves/Scenario.cpp
pathfinder/search/ConfigurationSpace.h
pathfinder/search/ConfigurationSpace.cpp
pathfinder/search/SearchAnalysis.h
pathfinder/search/SearchAnalysis.cpp
pathfinder/moves/Isometry.h
pathfinder/moves/Isometry.cpp
pathfinder/search/HeuristicCache.cpp
pathfinder/search/HeuristicCache.h
pathfinder/utility/color_util.cpp
pathfinder/utility/color_util.h)
target_link_libraries(${TARGET} PropertyLib)
if(${LINK_TBB})
target_link_libraries(${TARGET} tbb)
endif()
if(WIN32)
target_link_libraries(${TARGET} unofficial::getopt-win32::getopt)
endif()
endforeach()
if(NOT "${CMAKE_CURRENT_BINARY_DIR}" STREQUAL "${CMAKE_CURRENT_LIST_DIR}")
add_dependencies(Pathfinder copy_moves copy_examples copy_properties)
add_dependencies(ColorPropertyLib PropertyLib copy_properties)
if(EXISTS "${CMAKE_CURRENT_BINARY_DIR}/Moves")
add_dependencies(copy_moves clear_moves)
endif()
endif()
if(${INCLUDE_TESTS})
add_dependencies(copy_examples copy_resources)
target_compile_definitions(Pathfinder_Standard PUBLIC
LATTICE_RD_EDGECHECK=false
CONFIG_PARALLEL_MOVES=false
MOVEMANAGER_CHECK_BY_OFFSET=true)
# target_compile_definitions(Pathfinder_Rhombic PUBLIC
# LATTICE_RD_EDGECHECK=true
# CONFIG_PARALLEL_MOVES=false
# MOVEMANAGER_CHECK_BY_OFFSET=true)
target_compile_definitions(Pathfinder_Parallel PUBLIC
LATTICE_RD_EDGECHECK=false
CONFIG_PARALLEL_MOVES=true
MOVEMANAGER_CHECK_BY_OFFSET=true)
target_compile_definitions(Pathfinder_FullCheck PUBLIC
LATTICE_RD_EDGECHECK=false
CONFIG_PARALLEL_MOVES=false
MOVEMANAGER_CHECK_BY_OFFSET=false)
add_dependencies(Pathfinder_FullCheck OrientationPropertyLib)
enable_testing()
# Following are some very basic tests to ensure functionality of A* search and associated heuristics.
# The tests work by making sure A* final depth matches that of BFS.
# In certain cases it also checks the amounts of states processed, this is mostly to ensure that certain
# desirable properties of the MRSH-1 heuristic remain intact.
add_test(NAME Test2DSolo COMMAND Pathfinder_Standard
-I ./Test-Resources/Heuristic-Checker_initial.json
-F ./Test-Resources/Heuristic-Checker_final.json
-e ./Test-Resources/Output/2DSolo.scen
-a ./Test-Resources/Output/2DSolo_analysis.json
-m ./Test-Resources/Moves_Pivot)
set_property(TEST Test2DSolo PROPERTY PASS_REGULAR_EXPRESSION "States Processed: 9999")
set_property(TEST Test2DSolo PROPERTY PASS_REGULAR_EXPRESSION "A* Final Depth: 36")
add_test(NAME Test2D COMMAND Pathfinder_Standard
-i
-I ./Test-Resources/Z-Pentomino_initial.json
-F ./Test-Resources/Z-Pentomino_final.json
-e ./Test-Resources/Output/2D.scen
-a ./Test-Resources/Output/2D_analysis.json
-m ./Test-Resources/Moves_Pivot)
set_property(TEST Test2D PROPERTY PASS_REGULAR_EXPRESSION "A* Final Depth: 14")
add_test(NAME TestColor2D COMMAND Pathfinder_Standard
-I ./Test-Resources/Color-Shuffle_initial.json
-F ./Test-Resources/Color-Shuffle_final.json
-e ./Test-Resources/Output/Color2D.scen
-a ./Test-Resources/Output/Color2D_analysis.json
-m ./Test-Resources/Moves_Pivot)
set_property(TEST TestColor2D PROPERTY PASS_REGULAR_EXPRESSION "A* Final Depth: 10")
add_test(NAME TestColor3D COMMAND Pathfinder_Standard
-I ./Test-Resources/Color-Shuffle-3D_initial.json
-F ./Test-Resources/Color-Shuffle-3D_final.json
-e ./Test-Resources/Output/Color3D.scen
-a ./Test-Resources/Output/Color3D_analysis.json
-m ./Test-Resources/Moves_Pivot)
set_property(TEST TestColor3D PROPERTY PASS_REGULAR_EXPRESSION "A* Final Depth: 8")
add_test(NAME TestRhombicDodecahedron COMMAND Pathfinder_Standard
-I ./Test-Resources/Rhombic-Color_initial.json
-F ./Test-Resources/Rhombic-Color_final.json
-e ./Test-Resources/Output/RhombicDodecahedron.scen
-a ./Test-Resources/Output/RhombicDodecahedron_analysis.json
-m ./Test-Resources/Moves_Rhombic
-c RD)
set_property(TEST TestRhombicDodecahedron PROPERTY PASS_REGULAR_EXPRESSION "A* Final Depth: 16")
add_test(NAME TestParallelSolo COMMAND Pathfinder_Parallel
-I ./Test-Resources/Heuristic-Checker_initial.json
-F ./Test-Resources/Heuristic-Checker_final.json
-e ./Test-Resources/Output/ParallelSolo.scen
-a ./Test-Resources/Output/ParallelSolo_analysis.json
-m ./Test-Resources/Moves_Pivot)
set_property(TEST TestParallelSolo PROPERTY PASS_REGULAR_EXPRESSION "States Processed: 9")
set_property(TEST TestParallelSolo PROPERTY PASS_REGULAR_EXPRESSION "A* Final Depth: 9")
add_test(NAME TestParallelCoop COMMAND Pathfinder_Parallel
-I ./Test-Resources/Color-Shuffle_initial.json
-F ./Test-Resources/Color-Shuffle_final.json
-e ./Test-Resources/Output/ParallelCoop.scen
-a ./Test-Resources/Output/ParallelCoop_analysis.json
-m ./Test-Resources/Moves_Pivot)
set_property(TEST TestParallelCoop PROPERTY PASS_REGULAR_EXPRESSION "A* Final Depth: 5")
add_test(NAME TestMovePropertyChecks COMMAND Pathfinder_Standard
-I ./Test-Resources/Mixed-Modules_initial.json
-F ./Test-Resources/Mixed-Modules_final.json
-e ./Test-Resources/Output/MovePropertyChecks.scen
-a ./Test-Resources/Output/MovePropertyChecks_analysis.json
-m ./Test-Resources/Moves_ColorRestricted)
set_property(TEST TestMovePropertyChecks PROPERTY PASS_REGULAR_EXPRESSION "A* Final Depth: 14")
# Disabled until orientation property is repaired
# add_test(NAME TestOrientationProperty COMMAND Pathfinder_FullCheck
# -I ./Test-Resources/Orientation_initial.json
# -F ./Test-Resources/Orientation_final.json
# -e ./Test-Resources/Output/OrientationProperty.scen
# -a ./Test-Resources/Output/OrientationProperty_analysis.json
# -m ./Test-Resources/Moves_Orientation
# -s BDBFS)
#
# set_property(TEST TestOrientationProperty PROPERTY PASS_REGULAR_EXPRESSION "BDBFS Final Depth: 4")
#
# add_test(NAME TestOrientationProperty3D COMMAND Pathfinder_FullCheck
# -I ./Test-Resources/Orientation3D_initial.json
# -F ./Test-Resources/Orientation3D_final.json
# -e ./Test-Resources/Output/OrientationProperty3D.scen
# -a ./Test-Resources/Output/OrientationProperty3D_analysis.json
# -m ./Test-Resources/Moves_Orientation
# -s BDBFS)
#
# set_property(TEST TestOrientationProperty3D PROPERTY PASS_REGULAR_EXPRESSION "BDBFS Final Depth: 6")
# This test takes too long to complete
# add_test(NAME 15PuzzleGen COMMAND Pathfinder_Standard
# -I ./Test-Resources/15_Puzzle_initial.json
# -e ./Test-Resources/Output/15_Puzzle.scen
# -a ./Test-Resources/Output/15_Puzzle_analysis.json
# -m ./Test-Resources/Moves_15_Puzzle)
#
# set_property(TEST 15PuzzleGen PROPERTY PASS_REGULAR_EXPRESSION "Exporting moves... Done.")
endif()