forked from openscad/openscad
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
434 lines (381 loc) · 11.9 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
432
433
#
# CMake build system for OpenSCAD
#
# Configuration variables
# -DHEADLESS=<ON|OFF>
#
#
if(APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.8)
endif()
cmake_minimum_required(VERSION 3.5.0)
if(HEADLESS)
list(APPEND CONFIG_OPTIONS "HEADLESS")
endif(HEADLESS)
message(STATUS "Configuration: ${CONFIG_OPTIONS}")
project(openscad)
set(CMAKE_CXX_STANDARD 11)
if(APPLE)
# Needed for deployment target 10.8 as cmake doesn't know about the libc++
set(CMAKE_CXX_FLAGS "-stdlib=libc++")
endif()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
set(CMAKE_PREFIX_PATH "$ENV{OPENSCAD_LIBRARIES}")
find_package(Eigen3 REQUIRED QUIET)
message(STATUS "Eigen3: ${EIGEN3_VERSION_STRING}")
include_directories(${EIGEN3_INCLUDE_DIRS})
find_package(Boost 1.36 REQUIRED COMPONENTS filesystem system thread regex program_options QUIET)
message(STATUS "Boost: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
include_directories(${Boost_INCLUDE_DIRS})
find_package(CGAL REQUIRED QUIET)
message(STATUS "CGAL: ${CGAL_MAJOR_VERSION}.${CGAL_MINOR_VERSION}")
include_directories(${CGAL_INCLUDE_DIRS})
add_definitions(-DENABLE_CGAL)
find_package(HarfBuzz 0.9.19 REQUIRED QUIET)
message(STATUS "Harfbuzz: ${HARFBUZZ_VERSION}")
include_directories(${HARFBUZZ_INCLUDE_DIRS})
find_package(FontConfig 2.8.0 REQUIRED QUIET)
message(STATUS "Fontconfig: ${FONTCONFIG_VERSION}")
find_package(Freetype 2.4.9 REQUIRED QUIET)
message(STATUS "Freetype: ${FREETYPE_VERSION_STRING}")
include_directories(${FREETYPE_INCLUDE_DIRS})
find_package(GLIB2 2.26 REQUIRED QUIET)
message(STATUS "Glib: ${GLIB2_VERSION}")
include_directories(${GLIB2_INCLUDE_DIRS})
find_package(LibXml2 2.9 REQUIRED QUIET)
message(STATUS "LibXml2: ${LIBXML2_VERSION_STRING}")
include_directories(${LIBXML2_INCLUDE_DIR})
find_package(FLEX REQUIRED QUIET)
message(STATUS "Flex: ${FLEX_VERSION}")
find_package(BISON REQUIRED QUIET)
message(STATUS "Bison: ${BISON_VERSION}")
include(CheckIncludeFileCXX)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include_directories(src)
FLEX_TARGET(openscad_lexer src/lexer.l ${CMAKE_CURRENT_BINARY_DIR}/lexer.cxx DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/lexer.hxx)
BISON_TARGET(openscad_parser src/parser.y ${CMAKE_CURRENT_BINARY_DIR}/parser.cxx DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/parser.hxx COMPILE_FLAGS "-d -p parser")
ADD_FLEX_BISON_DEPENDENCY(openscad_lexer openscad_parser)
FLEX_TARGET(comment_lexer src/comment_lexer.l ${CMAKE_CURRENT_BINARY_DIR}/comment_lexer.cxx DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/comment_lexer.hxx)
BISON_TARGET(comment_parser src/comment_parser.y ${CMAKE_CURRENT_BINARY_DIR}/comment_parser.cxx DEFINES_FILE ${CMAKE_CURRENT_BINARY_DIR}/comment_parser.hxx COMPILE_FLAGS "-d -p comment_parser")
ADD_FLEX_BISON_DEPENDENCY(comment_lexer comment_parser)
if(NOT HEADLESS)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
find_package(Qt5 COMPONENTS Core Widgets OpenGL Concurrent REQUIRED QUIET)
message(STATUS "Qt5: ${Qt5_VERSION}")
set(CMAKE_INCLUDE_CURRENT_DIR ON)
if (Qt5_POSITION_INDEPENDENT_CODE)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif()
if (("${Qt5_VERSION}" VERSION_EQUAL "5.4") OR ("${Qt5_VERSION}" VERSION_GREATER "5.4"))
add_definitions(-DUSE_QOPENGLWIDGET)
endif()
find_package(Qt5QScintilla 2.8.0 REQUIRED QUIET)
message(STATUS "QScintilla: ${QT5QSCINTILLA_VERSION_STRING}")
add_definitions(-DUSE_SCINTILLA_EDITOR)
add_definitions(-DENABLE_MDI)
# add_definitions(${Qt5Widgets_DEFINITIONS})
# add_definitions(${Qt5OpenGL_DEFINITIONS})
# add_definitions(${Qt5Widgets_EXECUTABLE_COMPILE_FLAGS})
# add_definitions(${Qt5OpenGL_EXECUTABLE_COMPILE_FLAGS})
find_package(OpenGL REQUIRED QUIET)
find_package(GLEW REQUIRED QUIET)
message(STATUS "GLEW: ${GLEW_FOUND}")
find_package(OpenCSG REQUIRED QUIET)
message(STATUS "OpenCSG: ${OPENCSG_VERSION_STRING}")
endif()
# NULLGL - Allow us to build without OpenGL(TM). run 'cmake .. -DNULLGL=1'
# Most tests will fail, but it can be used for testing/experiments
if(NULLGL)
add_definitions(-DNULLGL)
else()
add_definitions(-DENABLE_OPENCSG)
endif()
# -DENABLE_LIBZIP -DDEBUG
add_definitions(-DENABLE_EXPERIMENTAL)
# Stack size 8MB; github issue 116
add_definitions(-DSTACKSIZE=8388608)
# Setup ccache (if available) to speed up recompiles. It's especially useful
# when switching back and forth between branches where large numbers of files
# would otherwise need to be re-compiled each time.
find_program(CCACHE_PATH ccache)
if (CCACHE_PATH)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE_PATH})
set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE_PATH})
endif()
#
# Version
#
string(TIMESTAMP VERSION "%Y.%m.%d")
string(REPLACE "-" ";" SPLITVERSION ${VERSION})
list(GET SPLITVERSION 0 OPENSCAD_SHORTVERSION)
string(REGEX MATCHALL "^[0-9]+|[0-9]+|[0-9]+$" VERSIONLIST "${OPENSCAD_SHORTVERSION}")
list(GET VERSIONLIST 0 OPENSCAD_YEAR)
list(GET VERSIONLIST 1 OPENSCAD_MONTH)
math(EXPR OPENSCAD_MONTH ${OPENSCAD_MONTH}) # get rid of leading zero
list(LENGTH VERSIONLIST VERSIONLEN)
if (${VERSIONLEN} EQUAL 3)
list(GET VERSIONLIST 2 OPENSCAD_DAY)
math(EXPR OPENSCAD_DAY ${OPENSCAD_DAY}) # get rid of leading zero
endif()
add_definitions(-DOPENSCAD_VERSION=${VERSION} -DOPENSCAD_SHORTVERSION=${OPENSCAD_SHORTVERSION} -DOPENSCAD_YEAR=${OPENSCAD_YEAR} -DOPENSCAD_MONTH=${OPENSCAD_MONTH})
if (DEFINED OPENSCAD_DAY)
add_definitions(-DOPENSCAD_DAY=${OPENSCAD_DAY})
endif()
#
# Platform specific settings
#
if(APPLE)
message(STATUS "Offscreen OpenGL Context - using Apple CGL")
set(PLATFORM_SOURCES src/PlatformUtils-mac.mm src/OffscreenContextCGL.mm src/imageutils-macosx.cc src/CocoaUtils.mm src/AppleEvents.cc src/EventFilter.cc)
find_library(COCOA_LIBRARY Cocoa)
set(PLATFORM_LIBS ${COCOA_LIBRARY})
elseif(UNIX)
message(STATUS "Offscreen OpenGL Context - using Unix GLX on X11")
set(PLATFORM_SOURCES src/OffscreenContextGLX.cc src/imageutils-lodepng.cc src/PlatformUtils-posix.cc)
find_library(X11_LIBRARY X11)
set(PLATFORM_LIBS ${X11_LIBRARY})
elseif(WIN32)
message(STATUS "Offscreen OpenGL Context - using Microsoft WGL")
set(PLATFORM_SOURCES src/OffscreenContextWGL.cc src/imageutils-lodepng.cc src/PlatformUtils-win.cc)
endif()
set(CORE_SOURCES
src/parsersettings.cc
src/linalg.cc
src/colormap.cc
src/Camera.cc
src/handle_dep.cc
src/value.cc
src/calc.cc
src/grid.cc
src/hash.cc
src/expr.cc
src/func.cc
src/function.cc
src/stackcheck.cc
src/localscope.cc
src/module.cc
src/FileModule.cc
src/UserModule.cc
src/GroupModule.cc
src/AST.cc
src/ModuleInstantiation.cc
src/ModuleCache.cc
src/StatCache.cc
src/node.cc
src/NodeVisitor.cc
src/context.cc
src/modcontext.cc
src/evalcontext.cc
src/feature.cc
src/csgnode.cc
src/CSGTreeNormalizer.cc
src/Geometry.cc
src/Polygon2d.cc
src/csgops.cc
src/transform.cc
src/color.cc
src/primitives.cc
src/projection.cc
src/cgaladv.cc
src/surface.cc
src/control.cc
src/render.cc
src/rendersettings.cc
src/settings.cc
src/dxfdata.cc
src/dxfdim.cc
src/offset.cc
src/linearextrude.cc
src/rotateextrude.cc
src/text.cc
src/printutils.cc
src/fileutils.cc
src/progress.cc
src/boost-utils.cc
src/FontCache.cc
src/DrawingCallback.cc
src/FreetypeRenderer.cc
src/lodepng.cpp
src/PlatformUtils.cc
src/libsvg/circle.cc
src/libsvg/ellipse.cc
src/libsvg/group.cc
src/libsvg/libsvg.cc
src/libsvg/line.cc
src/libsvg/path.cc
src/libsvg/polygon.cc
src/libsvg/polyline.cc
src/libsvg/rect.cc
src/libsvg/shape.cc
src/libsvg/svgpage.cc
src/libsvg/transformation.cc
src/libsvg/util.cc
src/clipper-utils.cc
src/assignment.cc
src/annotation.cc
src/polyclipping/clipper.cpp
${PLATFORM_SOURCES}
${FLEX_openscad_lexer_OUTPUTS}
${BISON_openscad_parser_OUTPUTS}
${FLEX_comment_lexer_OUTPUTS}
${BISON_comment_parser_OUTPUTS})
set(NOCGAL_SOURCES
src/builtin.cc
src/import.cc
src/import_stl.cc
src/import_amf.cc
src/import_off.cc
src/import_svg.cc
src/export.cc
src/export_stl.cc
src/export_amf.cc
src/export_off.cc
src/export_dxf.cc
src/export_svg.cc
src/LibraryInfo.cc
src/polyset.cc
src/polyset-gl.cc
src/polyset-utils.cc
src/GeometryUtils.cc)
set(CGAL_SOURCES
${NOCGAL_SOURCES}
src/CSGTreeEvaluator.cc
src/CGAL_Nef_polyhedron.cc
src/export_nef.cc
src/import_nef.cc
src/cgalutils.cc
src/cgalutils-applyops.cc
src/cgalutils-project.cc
src/cgalutils-tess.cc
src/cgalutils-polyhedron.cc
src/CGALCache.cc
src/Polygon2d-CGAL.cc
src/svg.cc
src/GeometryEvaluator.cc)
include_directories("src/libtess2/Include")
set(COMMON_SOURCES
src/nodedumper.cc
src/GeometryCache.cc
src/clipper-utils.cc
src/Tree.cc
src/polyclipping/clipper.cpp
src/libtess2/Source/bucketalloc.c
src/libtess2/Source/dict.c
src/libtess2/Source/geom.c
src/libtess2/Source/mesh.c
src/libtess2/Source/priorityq.c
src/libtess2/Source/sweep.c
src/libtess2/Source/tess.c
src/Tree.cc)
#
# Offscreen OpenGL context source code
#
set(OFFSCREEN_SOURCES
src/GLView.cc
src/OffscreenView.cc
src/imageutils.cc
src/fbo.cc
src/system-gl.cc
src/export_png.cc
src/CGALRenderer.cc
src/ThrownTogetherRenderer.cc
src/renderer.cc
src/render.cc
src/OpenCSGRenderer.cc)
set(GUI_SOURCES
src/mainwin.cc
src/OpenSCADApp.cc
src/WindowManager.cc
src/Preferences.cc
src/FontListDialog.cc
src/FontListTableView.cc
src/LibraryInfoDialog.cc
src/OpenCSGWarningDialog.cc
src/ProgressWidget.cc
src/AutoUpdater.cc
src/QGLView.cc
src/Dock.cc
src/UIUtils.cc
src/scadlexer.cpp
src/highlighter.cc
src/cgalworker.cc
src/editor.cc
src/legacyeditor.cc
src/scintillaeditor.cpp
src/launchingscreen.cc
src/QWordSearchField.cc
src/QSettingsCached.cc
src/comment.cpp
src/parameter/ParameterWidget.cc
src/parameter/groupwidget.cpp
src/parameter/parametercheckbox.cpp
src/parameter/parametercombobox.cpp
src/parameter/parameterextractor.cpp
src/parameter/parameterobject.cpp
src/parameter/parameterset.cpp
src/parameter/parameterslider.cpp
src/parameter/parameterspinbox.cpp
src/parameter/parametertext.cpp
src/parameter/parametervector.cpp
src/parameter/parametervirtualwidget.cpp
)
# header-only code
set(GUI_HEADERS
src/AboutDialog.h
src/MainWindow.h
)
if(NULLGL)
message(STATUS "NULLGL is set. Overriding previous OpenGL(TM) settings")
set(OFFSCREEN_SOURCES
src/NULLGL.cc # contains several 'nullified' versions of above .cc files
src/OffscreenView.cc
src/OffscreenContextNULL.cc
src/export_png.cc
src/${OFFSCREEN_IMGUTILS_SOURCE}
src/imageutils.cc
src/renderer.cc
src/render.cc)
endif()
#file(GLOB Headers src/*.h src/*.hpp src/polyclipping/*.hpp)
#list(REMOVE_ITEM Headers ${CMAKE_SOURCE_DIR}/src/SparkleAutoUpdater.h)
file(GLOB UIs src/*.ui)
file(GLOB Resources *.qrc)
set(Sources src/openscad.cc ${CORE_SOURCES} ${COMMON_SOURCES} ${CGAL_SOURCES} ${OFFSCREEN_SOURCES} ${Resources})
if(HEADLESS)
add_definitions(-DOPENSCAD_NOGUI)
else()
list(APPEND Sources ${GUI_SOURCES} ${GUI_HEADERS})
endif()
set(RESOURCE_FILES icons/OpenSCAD.icns)
add_executable(OpenSCAD ${Sources} ${RESOURCE_FILES})
# FIXME: snapshot, ICON = icons/icon-nightly.icns
if(APPLE)
set_target_properties(OpenSCAD PROPERTIES
MACOSX_BUNDLE_INFO_PLIST ${CMAKE_SOURCE_DIR}/Info.plist.in
MACOSX_BUNDLE TRUE
MACOSX_BUNDLE_ICON_FILE OpenSCAD.icns
MACOSX_BUNDLE_BUNDLE_VERSION 2017.03
MACOSX_BUNDLE_SHORT_VERSION_STRING 2017.03
RESOURCE "${RESOURCE_FILES}"
)
endif(APPLE)
set(COMMON_LIBRARIES
${CGAL_LIBRARY}
${GMP_LIBRARIES}
${MPFR_LIBRARIES}
${Boost_LIBRARIES}
${HARFBUZZ_LIBRARIES}
${FONTCONFIG_LIBRARIES}
${FREETYPE_LIBRARIES}
${GLIB2_LIBRARIES}
${LIBXML2_LIBRARIES}
${OPENGL_LIBRARIES}
${GLEW_LIBRARY}
${OPENCSG_LIBRARY}
${PLATFORM_LIBS})
target_link_libraries(OpenSCAD ${COMMON_LIBRARIES})
if(NOT HEADLESS)
target_link_libraries(OpenSCAD Qt5::Core Qt5::Widgets Qt5::OpenGL Qt5::Concurrent ${QT5QSCINTILLA_LIBRARY})
endif()