-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
372 lines (343 loc) · 13.8 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
cmake_minimum_required(VERSION 2.9)
project(StraightSkel)
include_directories(src)
include_directories(test)
# set default options
# to configure it, use:
# $ ccmake .
option(BUILD_OWN_KERNEL "Build our own Kernel (double precision)" ON)
option(USE_CGAL "Use the CGAL Kernel" OFF)
option(BUILD_TESTS "Use Boost's Unit Test Framework to test the implementation" OFF)
option(BUILD_DOCUMENTATION "Use Doxygen to create the HTML based API documentation" OFF)
# it may be useful to set CGAL_DONT_OVERRIDE_CMAKE_FLAGS
# /usr/lib/CGAL/CGAL_SetupFlags.cmake
# set(CGAL_DONT_OVERRIDE_CMAKE_FLAGS ON)
if (CMAKE_COMPILER_IS_GNUCXX)
message(STATUS "== GCC C++ Compiler detected ==")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
endif()
# create config.h
if(CMAKE_BUILD_TYPE MATCHES Debug)
set(DEBUG ON)
endif()
configure_file(${CMAKE_SOURCE_DIR}/src/config.h.in ${CMAKE_SOURCE_DIR}/src/config.h)
# to get help about a cmake module run:
# $ cmake --help-module FindBoost
if(BUILD_TESTS)
set(BOOST_COMPONENTS ${BOOST_COMPONENTS} unit_test_framework)
find_package(Boost REQUIRED ${BOOST_COMPONENTS})
endif()
# build util
set(util_SOURCES
src/util/StringFactory.cpp
src/util/StringFuncs.cpp
src/util/StackTrace.cpp
src/util/Configuration.cpp
src/util/Timer.cpp)
add_library(skelutil SHARED ${util_SOURCES})
if(BUILD_OWN_KERNEL)
set(kernel_SOURCES
src/kernel/Point2.cpp
src/kernel/Vector2.cpp
src/kernel/Line2.cpp
src/kernel/Segment2.cpp
src/kernel/Ray2.cpp
src/kernel/Point3.cpp
src/kernel/Vector3.cpp
src/kernel/Line3.cpp
src/kernel/Segment3.cpp
src/kernel/Plane3.cpp
src/kernel/Sphere3.cpp
src/kernel/intersection.cpp
src/kernel/distance.cpp
src/kernel/bisector.cpp
src/kernel/projection.cpp)
add_library(skelkernel SHARED ${kernel_SOURCES})
target_link_libraries(skelkernel m)
endif()
# build data structures
set(data_2d_SOURCES
src/data/2d/KernelFactory.cpp
src/data/2d/Vertex.cpp
src/data/2d/VertexData.cpp
src/data/2d/Edge.cpp
src/data/2d/EdgeData.cpp
src/data/2d/Polygon.cpp
src/data/2d/skel/StraightSkeleton.cpp
src/data/2d/skel/Node.cpp
src/data/2d/skel/Arc.cpp
src/data/2d/skel/AbstractEvent.cpp
src/data/2d/skel/ConstOffsetEvent.cpp
src/data/2d/skel/EdgeEvent.cpp
src/data/2d/skel/SplitEvent.cpp
src/data/2d/skel/TriangleEvent.cpp
src/data/2d/skel/SkelVertexData.cpp
src/data/2d/skel/SkelEdgeData.cpp
src/data/2d/mesh/Mesh.cpp
src/data/2d/mesh/MeshVertex.cpp
src/data/2d/mesh/MeshCell.cpp
src/data/2d/mesh/MeshRay.cpp
src/data/2d/mesh/MeshEdgeData.cpp)
set(data_3d_SOURCES
src/data/3d/KernelFactory.cpp
src/data/3d/Vertex.cpp
src/data/3d/VertexData.cpp
src/data/3d/Edge.cpp
src/data/3d/EdgeData.cpp
src/data/3d/Facet.cpp
src/data/3d/FacetData.cpp
src/data/3d/Triangle.cpp
src/data/3d/Polyhedron.cpp
src/data/3d/CircularVertex.cpp
src/data/3d/CircularVertexData.cpp
src/data/3d/CircularEdge.cpp
src/data/3d/CircularEdgeData.cpp
src/data/3d/SphericalPolygon.cpp
src/data/3d/skel/StraightSkeleton.cpp
src/data/3d/skel/Node.cpp
src/data/3d/skel/Arc.cpp
src/data/3d/skel/Sheet.cpp
src/data/3d/skel/AbstractEvent.cpp
src/data/3d/skel/ConstOffsetEvent.cpp
src/data/3d/skel/SaveOffsetEvent.cpp
src/data/3d/skel/EdgeEvent.cpp
src/data/3d/skel/EdgeMergeEvent.cpp
src/data/3d/skel/TriangleEvent.cpp
src/data/3d/skel/DblEdgeMergeEvent.cpp
src/data/3d/skel/DblTriangleEvent.cpp
src/data/3d/skel/TetrahedronEvent.cpp
src/data/3d/skel/VertexEvent.cpp
src/data/3d/skel/FlipVertexEvent.cpp
src/data/3d/skel/SurfaceEvent.cpp
src/data/3d/skel/PolyhedronSplitEvent.cpp
src/data/3d/skel/SplitMergeEvent.cpp
src/data/3d/skel/EdgeSplitEvent.cpp
src/data/3d/skel/PierceEvent.cpp
src/data/3d/skel/SkelVertexData.cpp
src/data/3d/skel/SkelEdgeData.cpp
src/data/3d/skel/SkelFacetData.cpp
src/data/3d/skel/SphericalSkeleton.cpp
src/data/3d/skel/CircularNode.cpp
src/data/3d/skel/CircularArc.cpp
src/data/3d/skel/SphericalAbstractEvent.cpp
src/data/3d/skel/SphericalConstOffsetEvent.cpp
src/data/3d/skel/SphericalEdgeEvent.cpp
src/data/3d/skel/SphericalSplitEvent.cpp
src/data/3d/skel/SphericalTriangleEvent.cpp
src/data/3d/skel/SphericalDblEdgeEvent.cpp
src/data/3d/skel/SphericalLeaveEvent.cpp
src/data/3d/skel/SphericalReturnEvent.cpp
src/data/3d/skel/SphericalDblLeaveEvent.cpp
src/data/3d/skel/SphericalDblReturnEvent.cpp
src/data/3d/skel/SphericalVertexEvent.cpp
src/data/3d/skel/SphericalEdgeMergeEvent.cpp
src/data/3d/skel/SphericalInversionEvent.cpp
src/data/3d/skel/SphericalSkelVertexData.cpp
src/data/3d/skel/SphericalSkelEdgeData.cpp
src/data/3d/skel/SphericalOffset.cpp)
add_library(skeldata2d SHARED ${data_2d_SOURCES})
add_library(skeldata3d SHARED ${data_3d_SOURCES})
if(USE_CGAL)
find_package(CGAL REQUIRED Core)
if(CGAL_FOUND)
include(${CGAL_USE_FILE})
target_link_libraries(skeldata2d skelutil ${Boost_LIBRARIES} ${CGAL_LIBRARIES})
target_link_libraries(skeldata3d skeldata2d skelutil ${Boost_LIBRARIES} ${CGAL_LIBRARIES})
endif()
else()
target_link_libraries(skeldata2d skelutil skelkernel ${Boost_LIBRARIES})
target_link_libraries(skeldata3d skeldata2d skelutil skelkernel ${Boost_LIBRARIES})
endif()
# build database connector
set(db_SOURCES
src/db/SQLiteDatabase.cpp
src/db/SQLiteStmt.cpp)
set(db_2d_SOURCES
src/db/2d/DAOFactory.cpp
src/db/2d/PointDAO.cpp
src/db/2d/VertexDAO.cpp
src/db/2d/EdgeDAO.cpp
src/db/2d/PolygonDAO.cpp
src/db/2d/NodeDAO.cpp
src/db/2d/ArcDAO.cpp
src/db/2d/EventDAO.cpp
src/db/2d/StraightSkeletonDAO.cpp
src/db/2d/AbstractFile.cpp
src/db/2d/FLMAFile.cpp)
set(db_3d_SOURCES
src/db/3d/DAOFactory.cpp
src/db/3d/PointDAO.cpp
src/db/3d/PlaneDAO.cpp
src/db/3d/VertexDAO.cpp
src/db/3d/EdgeDAO.cpp
src/db/3d/TriangleDAO.cpp
src/db/3d/FacetDAO.cpp
src/db/3d/PolyhedronDAO.cpp
src/db/3d/NodeDAO.cpp
src/db/3d/ArcDAO.cpp
src/db/3d/SheetDAO.cpp
src/db/3d/EventDAO.cpp
src/db/3d/StraightSkeletonDAO.cpp
src/db/3d/AbstractFile.cpp
src/db/3d/OBJFile.cpp
src/db/3d/FLMAFile.cpp)
add_library(skeldb SHARED ${db_SOURCES} ${db_2d_SOURCES} ${db_3d_SOURCES})
target_link_libraries(skeldb skeldata2d skeldata3d skelutil sqlite3 dl)
# build algorithm
set(algo_SOURCES
src/algo/Controller.cpp)
set(algo_2d_SOURCES
src/algo/2d/KernelWrapper.cpp
src/algo/2d/PolygonTransformation.cpp
src/algo/2d/SimpleStraightSkel.cpp
src/algo/2d/FastStraightSkel.cpp
src/algo/2d/MeshModifier.cpp
src/algo/2d/SkelMeshGenerator.cpp)
set(algo_3d_SOURCES
src/algo/3d/KernelWrapper.cpp
src/algo/3d/SimpleStraightSkel.cpp
src/algo/3d/PolyhedronBuilder.cpp
src/algo/3d/LineInFacet.cpp
src/algo/3d/SelfIntersection.cpp
src/algo/3d/AbstractVertexSplitter.cpp
src/algo/3d/AngleVertexSplitter.cpp
src/algo/3d/CombiVertexSplitter.cpp
src/algo/3d/ConvexVertexSplitter.cpp
src/algo/3d/VolumeVertexSplitter.cpp
src/algo/3d/WeightVertexSplitter.cpp
src/algo/3d/SphereVertexSplitter.cpp
src/algo/3d/PolyhedronTransformation.cpp
src/algo/3d/PolyhedronIntersection.cpp
src/algo/3d/AbstractSimpleSphericalSkel.cpp
src/algo/3d/ProjSimpleSphericalSkel.cpp
src/algo/3d/RotSimpleSphericalSkel.cpp
src/algo/3d/TransSimpleSphericalSkel.cpp
src/algo/3d/SpeedSimpleSphericalSkel.cpp
src/algo/3d/GraphChecker.cpp)
add_library(skelalgo2d SHARED ${algo_SOURCES} ${algo_2d_SOURCES})
add_library(skelalgo3d SHARED ${algo_3d_SOURCES})
target_link_libraries(skelalgo2d skeldata2d)
target_link_libraries(skelalgo3d skelalgo2d skeldata3d)
# build user interface
set(ui_SOURCES
src/ui/vecmath.cpp)
set(ui_gl_SOURCES
src/ui/gl/Camera.cpp
src/ui/gl/OpenGLWindow.cpp
src/ui/gl/MainOpenGLWindow.cpp
src/ui/gl/KeyboardAdapter.cpp
src/ui/gl/MouseAdapter.cpp)
set(ui_ps_SOURCES
src/ui/ps/PSPrinter.cpp
src/ui/ps/SpacePSPrinter.cpp
src/ui/ps/PlanePSPrinter.cpp
src/ui/ps/CutPatternPrinter.cpp)
add_library(skelui SHARED ${ui_SOURCES} ${ui_gl_SOURCES} ${ui_ps_SOURCES})
target_link_libraries(skelui skelutil m GL GLU glut ${Boost_LIBRARIES})
# build executable
set(StraightSkel_SOURCES
src/main.cpp)
add_executable(StraightSkel ${StraightSkel_SOURCES})
target_link_libraries(StraightSkel skeldata2d skelalgo2d skeldata3d skelalgo3d skeldb skelui)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/res/StraightSkel.ini
${CMAKE_CURRENT_BINARY_DIR}/StraightSkel.ini COPYONLY)
if(BUILD_TESTS)
# run the tests:
# $ make test
enable_testing()
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
set(UtilTest_SOURCES
test/util/UtilTestRunner.cpp
test/util/StringFuncsTest.cpp)
add_executable(UtilTestRunner ${UtilTest_SOURCES})
target_link_libraries(UtilTestRunner skelutil ${Boost_LIBRARIES})
add_test(UtilTestRunner UtilTestRunner)
if(BUILD_OWN_KERNEL)
set(KernelTest_SOURCES
test/kernel/KernelTestRunner.cpp
test/kernel/Vector2Test.cpp
test/kernel/Point2Test.cpp
test/kernel/Line2Test.cpp
test/kernel/Segment2Test.cpp
test/kernel/Vector3Test.cpp
test/kernel/Point3Test.cpp
test/kernel/Line3Test.cpp
test/kernel/Segment3Test.cpp
test/kernel/Plane3Test.cpp
test/kernel/IntersectionTest.cpp
test/kernel/DistanceTest.cpp
test/kernel/BisectorTest.cpp)
add_executable(KernelTestRunner ${KernelTest_SOURCES})
target_link_libraries(KernelTestRunner skelkernel ${Boost_LIBRARIES})
add_test(KernelTestRunner KernelTestRunner)
endif()
set(Data2DTest_SOURCES
test/data/2d/Data2DTestRunner.cpp
test/data/2d/KernelFactoryTest.cpp
test/data/2d/VertexTest.cpp
test/data/2d/EdgeTest.cpp
test/data/2d/PolygonTest.cpp)
add_executable(Data2DTestRunner ${Data2DTest_SOURCES})
target_link_libraries(Data2DTestRunner skeldata2d ${Boost_LIBRARIES})
add_test(Data2DTestRunner Data2DTestRunner)
set(Data3DTest_SOURCES
test/data/3d/Data3DTestRunner.cpp
test/data/3d/EdgeTest.cpp
test/data/3d/FacetTest.cpp
test/data/3d/PolyhedronTest.cpp)
add_executable(Data3DTestRunner ${Data3DTest_SOURCES})
target_link_libraries(Data3DTestRunner skeldata3d ${Boost_LIBRARIES})
add_test(Data3DTestRunner Data3DTestRunner)
set(DBTest_SOURCES
test/db/DBTestRunner.cpp
test/db/2d/VertexDAOTest.cpp
test/db/2d/EdgeDAOTest.cpp
test/db/2d/PolygonDAOTest.cpp
test/db/3d/PolyhedronDAOTest.cpp)
add_executable(DBTestRunner ${DBTest_SOURCES})
target_link_libraries(DBTestRunner skeldb ${Boost_LIBRARIES})
add_test(DBTestRunner DBTestRunner)
set(Algo2DTest_SOURCES
test/algo/2d/Algo2DTestRunner.cpp
test/algo/2d/KernelWrapperTest.cpp)
add_executable(Algo2DTestRunner ${Algo2DTest_SOURCES})
target_link_libraries(Algo2DTestRunner skelalgo2d ${Boost_LIBRARIES})
add_test(Algo2DTestRunner Algo2DTestRunner)
set(Algo3DTest_SOURCES
test/algo/3d/Algo3DTestRunner.cpp
test/algo/3d/KernelWrapperTest.cpp
test/algo/3d/PolyhedronBuilderTest.cpp
test/algo/3d/LineInFacetTest.cpp
test/algo/3d/CombiVertexSplitterTest.cpp
test/algo/3d/VolumeVertexSplitterTest.cpp)
add_executable(Algo3DTestRunner ${Algo3DTest_SOURCES})
target_link_libraries(Algo3DTestRunner skelalgo3d ${Boost_LIBRARIES})
add_test(Algo3DTestRunner Algo3DTestRunner)
endif()
endif()
if(BUILD_DOCUMENTATION)
# build documentation:
# $ make doc
find_package(Doxygen REQUIRED)
if(DOXYGEN_FOUND)
set(DOXYGEN_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/doc)
set(DOXYGEN_INPUT ${PROJECT_SOURCE_DIR}/src)
configure_file(Doxyfile.in ${PROJECT_BINARY_DIR}/Doxyfile @ONLY)
add_custom_target(doc
COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/Doxyfile
SOURCES ${PROJECT_BINARY_DIR}/Doxyfile)
endif()
endif()
install(TARGETS skelutil DESTINATION lib${LIB_SUFFIX})
if(BUILD_OWN_KERNEL)
install(TARGETS skelkernel DESTINATION lib${LIB_SUFFIX})
endif()
install(TARGETS skeldata2d DESTINATION lib${LIB_SUFFIX})
install(TARGETS skeldata3d DESTINATION lib${LIB_SUFFIX})
install(TARGETS skeldb DESTINATION lib${LIB_SUFFIX})
install(TARGETS skelalgo2d DESTINATION lib${LIB_SUFFIX})
install(TARGETS skelalgo3d DESTINATION lib${LIB_SUFFIX})
install(TARGETS skelui DESTINATION lib${LIB_SUFFIX})
install(TARGETS StraightSkel DESTINATION bin)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/StraightSkel.ini DESTINATION etc/StraightSkel)