forked from openscad/openscad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
700 lines (619 loc) · 22.4 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
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
#
# CMake build system for OpenSCAD
#
# Configuration variables
# -DHEADLESS=<ON|OFF>
# -DNULLGL=<ON|OFF>
# -DSNAPSHOT=<ON|OFF>
# -DEXPERIMENTAL=<ON|OFF>
#
# TODO
# find packages for spnav, hidapi
if(APPLE)
set(CMAKE_OSX_DEPLOYMENT_TARGET 10.9)
endif()
cmake_minimum_required(VERSION 3.3)
if(POLICY CMP0071)
cmake_policy(SET CMP0071 OLD)
endif()
project(openscad)
option(INFO "Display build configuration info at end of cmake config" ON)
option(EXPERIMENTAL "Enable Experimental Features" OFF)
option(SNAPSHOT "Create dev snapshot, uses nightly icons" OFF)
option(HEADLESS "Build without GUI frontend" OFF)
option(NULLGL "Build without OpenGL, (implies HEADLESS=ON) " OFF)
option(IDPREFIX "Prefix CSG nodes with index # (debugging purposes only, will break node cache)" OFF)
option(PROFILE "Enable compiling with profiling / test coverage instrumentation" OFF)
if(PROFILE)
SET(GCC_COVERAGE_COMPILE_FLAGS "-g -O0 --coverage -fprofile-arcs -ftest-coverage -fprofile-dir=.gcov")
SET(GCC_COVERAGE_LINK_FLAGS "--coverage")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${GCC_COVERAGE_LINK_FLAGS}")
# Make sure to override default optimization for Release type
string(REPLACE "-O3" "-O0" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
else()
# Use same optimization as qmake build for Release
string(REPLACE "-O3" "-O2" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
endif()
if (NULLGL)
set(HEADLESS ON)
endif()
if(EXPERIMENTAL)
add_definitions(-DENABLE_EXPERIMENTAL)
endif()
if(IDPREFIX)
add_definitions(-DIDPREFIX)
endif()
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/objects")
set(AUTOGEN_BUILD_DIR "${CMAKE_BINARY_DIR}/objects")
file(MAKE_DIRECTORY ${AUTOGEN_BUILD_DIR})
# Default to Release build
#if(NOT CMAKE_BUILD_TYPE)
# message(STATUS "CMAKE_BUILD_TYPE not specified. Defaulting to 'Release'")
# message(STATUS "Usage: cmake -DCMAKE_BUILD_TYPE=[Debug|Release|RelWithDebInfo|MinSizeRel] .")
# set(CMAKE_BUILD_TYPE Release)
#else()
# message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
#endif()
add_compile_options("$<$<CONFIG:DEBUG>:-DDEBUG>")
set(CMAKE_CXX_STANDARD 14)
add_definitions(-D_REENTRANT -DUNICODE -D_UNICODE)
# Stack size 8MB; github issue 116
add_definitions(-DSTACKSIZE=8388608)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -frounding-math")
if (WIN32) # gcc bug spams warnings, See issue #2771
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-attributes")
endif()
endif()
set(BOOST_DIRECTLY_REQUIRED_LIBRARIES filesystem system regex program_options)
find_package(PkgConfig)
macro(find_graphics)
# 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()
set(OpenGL_GL_PREFERENCE "GLVND")
find_package(OpenGL REQUIRED QUIET)
list(APPEND COMMON_LIBRARIES ${OPENGL_LIBRARIES})
if(MSVC)
find_package(GLEW CONFIG REQUIRED QUIET)
message(STATUS "GLEW: Using target GLEW::GLEW")
list(APPEND COMMON_LIBRARIES GLEW::GLEW)
find_path(OPENCSG_INCLUDE_DIRS opencsg/opencsg.h)
include_directories("${OPENCSG_INCLUDE_DIRS}/opencsg")
else()
find_package(GLEW REQUIRED)
message(STATUS "GLEW_INCLUDE_DIR: ${GLEW_INCLUDE_DIR}")
message(STATUS "GLEW_LIBRARY: ${GLEW_LIBRARY}")
include_directories("${GLEW_INCLUDE_DIR}")
list(APPEND COMMON_LIBRARIES ${GLEW_LIBRARY})
find_path(OPENCSG_INCLUDE_DIRS opencsg.h)
include_directories("${OPENCSG_INCLUDE_DIRS}")
endif()
find_library(OPENCSG_LIBRARY opencsg)
list(APPEND COMMON_LIBRARIES ${OPENCSG_LIBRARY})
message(STATUS "OpenCSG: ${OPENCSG_VERSION_STRING}")
add_definitions(-DENABLE_OPENCSG)
endif()
endmacro(find_graphics)
# NOTE FindCGAL.cmake resets the BOOST_* and Boost_* variables,
# because it looks for Boost itself, so it has to be called
# before we look for our own required boost libraries.
set(CGAL_DO_NOT_WARN_ABOUT_CMAKE_BUILD_TYPE TRUE)
find_package(CGAL REQUIRED)
message(STATUS "CGAL: ${CGAL_MAJOR_VERSION}.${CGAL_MINOR_VERSION}")
add_definitions(-DENABLE_CGAL)
if(TARGET CGAL::CGAL)
list(APPEND COMMON_LIBRARIES CGAL::CGAL)
message(STATUS "CGAL: Using target CGAL::CGAL")
else()
list(APPEND COMMON_LIBRARIES ${CGAL_LIBRARY})
list(APPEND COMMON_LIBRARIES ${GMP_LIBRARIES})
list(APPEND COMMON_LIBRARIES ${MPFR_LIBRARIES})
endif()
# revert any changes to module path from CGAL_Macros.cmake
if (CGAL_MODULE_PATH_IS_SET)
set(CMAKE_MODULE_PATH ORIGINAL_CMAKE_MODULE_PATH)
endif()
if (MSVC)
# Flex lexer options
set(WINCOMPAT "--wincompat --nounistd")
add_definitions(-D_USE_MATH_DEFINES)
message("COMMON_LIBRARIES ${COMMON_LIBRARIES}")
find_package(Eigen3 CONFIG REQUIRED)
list(APPEND COMMON_LIBRARIES Eigen3::Eigen)
set(Boost_USE_STATIC_LIBS TRUE)
find_package(Boost 1.36 REQUIRED COMPONENTS ${BOOST_DIRECTLY_REQUIRED_LIBRARIES})
message(STATUS "Boost: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
message("BOOST DIRS ${Boost_INCLUDE_DIRS}")
include_directories(${Boost_INCLUDE_DIRS})
list(APPEND COMMON_LIBRARIES ${Boost_LIBRARIES})
find_package(harfbuzz CONFIG REQUIRED)
find_path(HARFBUZZ_INCLUDE_DIRS harfbuzz)
include_directories(${HARFBUZZ_INCLUDE_DIRS}/harfbuzz)
list(APPEND COMMON_LIBRARIES harfbuzz::harfbuzz)
find_package(unofficial-fontconfig CONFIG REQUIRED)
list(APPEND COMMON_LIBRARIES unofficial::fontconfig::fontconfig)
find_package(unofficial-glib CONFIG REQUIRED)
include_directories(${GLIB2_INCLUDE_DIRS})
list(APPEND COMMON_LIBRARIES unofficial::glib::gio unofficial::glib::glib unofficial::glib::gmodule unofficial::glib::gobject)
find_package(double-conversion CONFIG REQUIRED)
list(APPEND COMMON_LIBRARIES double-conversion::double-conversion)
find_library(GETTEXT_LIBRARY libintl)
list(APPEND COMMON_LIBRARIES ${GETTEXT_LIBRARY})
# call before setting local CMAKE_MODULE_PATH so we use VCPKG version of FindGLEW
find_graphics()
# needed for Qt5QScintilla, maybe others
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
else()
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
set(CMAKE_PREFIX_PATH "$ENV{OPENSCAD_LIBRARIES}")
find_package(Eigen3 QUIET)
if (NOT Eigen3_FOUND)
# Ubuntu Trusty Eigen package installs FindEigen3.cmake but assumes cmake-2.8, not cmake3
# See https://packages.ubuntu.com/trusty/all/libeigen3-dev/filelist
list(APPEND CMAKE_MODULE_PATH "/usr/share/cmake-2.8/Modules")
find_package(Eigen3 REQUIRED QUIET)
list(REMOVE_ITEM CMAKE_MODULE_PATH "/usr/share/cmake-2.8/Modules")
endif()
if (EIGEN3_VERSION)
message(STATUS "Eigen3: ${EIGEN3_VERSION}")
else()
message(STATUS "Eigen3: ${EIGEN3_VERSION_STRING}")
endif()
include_directories(${EIGEN3_INCLUDE_DIR})
add_definitions(-DEIGEN_DONT_ALIGN)
find_package(Boost 1.36 REQUIRED COMPONENTS ${BOOST_DIRECTLY_REQUIRED_LIBRARIES})
message(STATUS "Boost: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
include_directories(${Boost_INCLUDE_DIRS})
list(APPEND COMMON_LIBRARIES ${Boost_LIBRARIES})
find_package(HarfBuzz 0.9.19 REQUIRED QUIET)
message(STATUS "Harfbuzz: ${HARFBUZZ_VERSION}")
include_directories(${HARFBUZZ_INCLUDE_DIRS})
list(APPEND COMMON_LIBRARIES ${HARFBUZZ_LIBRARIES})
find_package(FontConfig 2.8.0 REQUIRED QUIET)
message(STATUS "Fontconfig: ${FONTCONFIG_VERSION}")
list(APPEND COMMON_LIBRARIES ${FONTCONFIG_LIBRARIES})
find_package(GLIB2 2.26 REQUIRED QUIET)
message(STATUS "Glib: ${GLIB2_VERSION}")
include_directories(${GLIB2_INCLUDE_DIRS})
list(APPEND COMMON_LIBRARIES ${GLIB2_LIBRARIES})
list(APPEND COMMON_LIBRARIES double-conversion)
find_graphics()
endif()
find_package(LibZip REQUIRED QUIET)
include_directories(${LIBZIP_INCLUDE_DIR_ZIP})
include_directories(${LIBZIP_INCLUDE_DIR_ZIPCONF})
list(APPEND COMMON_LIBRARIES ${LIBZIP_LIBRARY})
add_definitions(-DENABLE_LIBZIP)
find_package(Freetype 2.4.9 REQUIRED QUIET)
message(STATUS "Freetype: ${FREETYPE_VERSION_STRING}")
include_directories(${FREETYPE_INCLUDE_DIRS})
list(APPEND COMMON_LIBRARIES ${FREETYPE_LIBRARIES})
find_package(LibXml2 2.9 REQUIRED QUIET)
message(STATUS "LibXml2: ${LIBXML2_VERSION_STRING}")
include_directories(${LIBXML2_INCLUDE_DIR})
list(APPEND COMMON_LIBRARIES ${LIBXML2_LIBRARIES})
find_package(Cairo 1.14 QUIET)
if (CAIRO_VERSION)
message(STATUS "Cairo: ${CAIRO_VERSION}")
include_directories(${CAIRO_INCLUDE_DIRS})
list(APPEND COMMON_LIBRARIES ${CAIRO_LIBRARIES})
add_definitions(-DENABLE_CAIRO)
else()
message(STATUS "Cairo: disabled")
endif()
find_package(FLEX REQUIRED QUIET)
message(STATUS "Flex: ${FLEX_VERSION}")
find_package(BISON REQUIRED QUIET)
message(STATUS "Bison: ${BISON_VERSION}")
if(NOT MSVC)
find_package(Lib3MF REQUIRED QUIET)
add_definitions(${LIB3MF_CFLAGS})
include_directories(${LIB3MF_INCLUDE_DIRS})
list(APPEND COMMON_LIBRARIES ${LIB3MF_LIBRARIES})
endif()
# Output compilation database (compile_commands.json), so we can e.g. run clang-tidy or other tools separately
set(CMAKE_EXPORT_COMPILE_COMMANDS "ON")
# Use clang-tidy if run with -DCLANG_TIDY=1
find_program(CLANG_TIDY_EXE NAMES clang-tidy)
set(CLANG_TIDY ${CLANG_TIDY} CACHE BOOL "Enable clang-tidy")
if(CLANG_TIDY AND CLANG_TIDY_EXE)
include(RegexUtils)
escape_string_as_regex(regex "${CMAKE_SOURCE_DIR}/src")
set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXE};-header-filter=${regex}")
endif()
set(CMAKE_INCLUDE_CURRENT_DIR ON)
include_directories(src)
FLEX_TARGET(openscad_lexer src/engine/lexer.l ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lexer.cxx DEFINES_FILE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/lexer.hxx COMPILE_FLAGS ${WINCOMPAT})
BISON_TARGET(openscad_parser src/engine/parser.y ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/parser.cxx DEFINES_FILE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/parser.hxx COMPILE_FLAGS "-d -p parser")
ADD_FLEX_BISON_DEPENDENCY(openscad_lexer openscad_parser)
FLEX_TARGET(comment_lexer src/engine/comment_lexer.l ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/comment_lexer.cxx DEFINES_FILE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/comment_lexer.hxx COMPILE_FLAGS ${WINCOMPAT})
BISON_TARGET(comment_parser src/engine/comment_parser.y ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/comment_parser.cxx DEFINES_FILE ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/comment_parser.hxx COMPILE_FLAGS "-d -p comment_parser")
ADD_FLEX_BISON_DEPENDENCY(comment_lexer comment_parser)
if(NOT HEADLESS)
if (APPLE AND EXISTS /usr/local/opt/qt)
list(APPEND CMAKE_PREFIX_PATH "/usr/local/opt/qt")
endif()
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
find_package(Qt5 COMPONENTS Core Widgets Multimedia OpenGL Concurrent Network 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)
find_package(Qt5DBus QUIET)
if (Qt5DBus_FOUND)
message(STATUS "DBus input driver enabled")
add_definitions(-DENABLE_DBUS)
set(INPUT_DRIVER_DBUS_SOURCES src/input/DBusInputDriver.cc)
qt5_add_dbus_interface(INPUT_DRIVER_DBUS_SOURCES org.openscad.OpenSCAD.xml openscad_interface)
qt5_add_dbus_adaptor(INPUT_DRIVER_DBUS_SOURCES org.openscad.OpenSCAD.xml input/DBusInputDriver.h DBusInputDriver openscad_adaptor)
else()
message(STATUS "DBus input driver disabled as the QtDBus module could not be found.")
endif()
find_package(Qt5Gamepad QUIET)
if (Qt5Gamepad_FOUND)
message(STATUS "Gamepad input driver enabled")
set(GUI_SOURCES ${GUI_SOURCES} src/input/QGamepadInputDriver.cc)
add_definitions(-DENABLE_QGAMEPAD)
else()
message(STATUS "Gamepad input driver disabled as the Qt5Gamepad module could not be found.")
endif()
endif()
# 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()
if(DEFINED OPENSCAD_COMMIT)
add_definitions(-DOPENSCAD_COMMIT=${OPENSCAD_COMMIT})
endif()
#
# Platform specific settings
#
if(APPLE)
message(STATUS "Offscreen OpenGL Context - using Apple CGL")
set(PLATFORM_SOURCES src/osx/PlatformUtils-mac.mm src/osx/imageutils-macosx.cc src/osx/CocoaUtils.mm)
if(NOT HEADLESS)
set(PLATFORM_SOURCES ${PLATFORM_SOURCES} src/osx/AppleEvents.cc)
endif()
if(NULLGL)
add_definitions(-DOPENSCAD_OS="Mac OS X")
else()
set(PLATFORM_SOURCES ${PLATFORM_SOURCES} src/osx/OffscreenContextCGL.mm)
endif()
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/renderer/imageutils-lodepng.cc src/posix/PlatformUtils-posix.cc)
if(NULLGL)
add_definitions(-DOPENSCAD_OS="Unix")
else()
set(PLATFORM_SOURCES ${PLATFORM_SOURCES} src/posix/OffscreenContextGLX.cc)
find_library(X11_LIBRARY X11)
set(PLATFORM_LIBS ${X11_LIBRARY})
endif()
elseif(WIN32)
add_definitions(-DNOGDI)
message(STATUS "Offscreen OpenGL Context - using Microsoft WGL")
set(PLATFORM_SOURCES src/renderer/imageutils-lodepng.cc src/win/PlatformUtils-win.cc)
if(NULLGL)
add_definitions(-DOPENSCAD_OS="Windows")
else()
set(PLATFORM_SOURCES ${PLATFORM_SOURCES} src/win/OffscreenContextWGL.cc)
endif()
endif()
set(CORE_SOURCES
src/engine/annotation.cc
src/common/boost-utils.cc
src/engine/builtin.cc
src/engine/builtincontext.cc
src/engine/calc.cc
src/engine/cgaladv.cc
src/engine/clipper-utils.cc
src/engine/color.cc
src/colormap.cc
src/engine/context.cc
src/engine/control.cc
src/engine/comment.cpp
src/engine/csgnode.cc
src/engine/csgops.cc
src/engine/math/degree_trig.cc
src/porters/dxfdata.cc
src/porters/dxfdim.cc
src/engine/evalcontext.cc
src/porters/export.cc
src/porters/export_3mf.cc
src/porters/export_amf.cc
src/porters/export_dxf.cc
src/porters/export_off.cc
src/porters/export_pdf.cc
src/porters/export_stl.cc
src/porters/export_svg.cc
src/engine/expr.cc
src/engine/feature.cc
src/common/fileutils.cc
src/engine/func.cc
src/engine/function.cc
src/engine/handle_dep.cc
src/engine/math/hash.cc
src/porters/import.cc
src/porters/import_3mf.cc
src/porters/import_amf.cc
src/porters/import_stl.cc
src/porters/import_off.cc
src/porters/import_svg.cc
src/engine/math/linalg.cc
src/engine/linearextrude.cc
src/engine/localscope.cc
src/engine/modcontext.cc
src/engine/module.cc
src/engine/node.cc
src/engine/nodedumper.cc
src/engine/offset.cc
src/engine/parsersettings.cc
src/engine/math/polyset.cc
src/engine/math/polyset-utils.cc
src/engine/primitives.cc
src/common/printutils.cc
src/engine/progress.cc
src/engine/projection.cc
src/renderer/render.cc
src/renderer/rendersettings.cc
src/engine/rotateextrude.cc
src/engine/stackcheck.h
src/engine/surface.cc
src/engine/svg.cc
src/engine/TextModule.h
src/engine/TextModule.cc
src/engine/text.cc
src/engine/transform.cc
src/engine/value.cc
src/gui/version.cc
src/engine/Assignment.cc
src/engine/AST.cc
src/renderer/Camera.cc
src/engine/CSGTreeNormalizer.cc
src/gui/DrawingCallback.cc
src/engine/FileModule.cc
src/gui/FontCache.cc
src/gui/FreetypeRenderer.cc
src/engine/math/Geometry.cc
src/engine/GeometryCache.cc
src/engine/math/GeometryUtils.cc
src/engine/GroupModule.cc
src/gui/LibraryInfo.cc
src/engine/ModuleInstantiation.cc
src/engine/ModuleCache.cc
src/engine/NodeVisitor.cc
src/common/PlatformUtils.cc
src/engine/math/Polygon2d.cc
src/engine/RenderStatistic.cc
src/engine/StatCache.cc
src/engine/UserModule.cc
src/engine/Tree.cc
src/ext/lodepng/lodepng.cpp
src/ext/polyclipping/clipper.cpp
src/ext/libtess2/Source/bucketalloc.c
src/ext/libtess2/Source/dict.c
src/ext/libtess2/Source/geom.c
src/ext/libtess2/Source/mesh.c
src/ext/libtess2/Source/priorityq.c
src/ext/libtess2/Source/sweep.c
src/ext/libtess2/Source/tess.c
src/libsvg/circle.cc
src/libsvg/data.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/text.cc
src/libsvg/transformation.cc
src/libsvg/tspan.cc
src/libsvg/util.cc
src/parameter/parameterset.cpp
${PLATFORM_SOURCES}
${FLEX_openscad_lexer_OUTPUTS}
${BISON_openscad_parser_OUTPUTS}
${FLEX_comment_lexer_OUTPUTS}
${BISON_comment_parser_OUTPUTS})
set(CGAL_SOURCES
src/engine/cgalutils.cc
src/engine/cgalutils-applyops.cc
src/engine/cgalutils-polyhedron.cc
src/engine/cgalutils-project.cc
src/engine/cgalutils-tess.cc
src/porters/export_nef.cc
src/porters/import_nef.cc
src/engine/CGAL_Nef_polyhedron.cc
src/engine/CGALCache.cc
src/engine/CSGTreeEvaluator.cc
src/engine/Polygon2d-CGAL.cc
src/engine/GeometryEvaluator.cc)
#
# Offscreen OpenGL context source code
#
if(NULLGL)
message(STATUS "NULLGL is set. Overriding OpenGL(TM) settings")
set(OFFSCREEN_SOURCES
src/porters/export_png.cc
src/renderer/imageutils.cc
src/renderer.cc
src/render.cc
src/NULLGL.cc # contains several 'nullified' versions of above .cc files
src/renderer/OffscreenView.cc
src/renderer/OffscreenContextNULL.cc
src/${OFFSCREEN_IMGUTILS_SOURCE})
else()
set(OFFSCREEN_SOURCES
src/porters/export_png.cc
src/renderer/fbo.cc
src/renderer/imageutils.cc
src/renderer/render.cc
src/renderer/renderer.cc
src/renderer/system-gl.cc
src/renderer/CGALRenderer.cc
src/gui/GLView.cc
src/renderer/OffscreenView.cc
src/renderer/OpenCSGRenderer.cc
src/renderer/ThrownTogetherRenderer.cc)
endif()
if(UNIX AND (NOT APPLE) AND (NOT HEADLESS))
set(PLATFORM_INPUT_DRIVER_SOURCES src/input/JoystickInputDriver.cc)
add_definitions(-DENABLE_JOYSTICK)
endif()
set(INPUT_DRIVER_SOURCES
${PLATFORM_INPUT_DRIVER_SOURCES}
${INPUT_DRIVER_DBUS_SOURCES})
set(GUI_SOURCES
${GUI_SOURCES}
src/engine/cgalworker.cc
src/gui/editor.cc
src/gui/initConfig.cc
src/gui/launchingscreen.cc
src/gui/mainwin.cc
src/gui/mouseselector.cc
src/scadapi.cc
src/engine/scadlexer.cpp
src/gui/scintillaeditor.cpp
src/settings.cc
src/gui/tabmanager.cc
src/gui/tabwidget.cc
src/gui/AutoUpdater.cc
src/gui/Console.cc
src/gui/Dock.cc
src/gui/ErrorLog.cc
src/gui/EventFilter.h
src/gui/FontListDialog.cc
src/gui/FontListTableView.cc
src/gui/LibraryInfoDialog.cc
src/octoprint/OctoPrint.cc
src/gui/OpenCSGWarningDialog.cc
src/OpenSCADApp.cc
src/gui/Preferences.cc
src/gui/PrintInitDialog.cc
src/octoprint/PrintService.cc
src/gui/ProgressWidget.cc
src/gui/QGLView.cc
src/gui/QSettingsCached.cc
src/gui/QWordSearchField.cc
src/gui/SettingsWriter.cc
src/gui/UIUtils.cc
src/gui/WindowManager.cc
src/parameter/groupwidget.cpp
src/parameter/ignoreWheelWhenNotFocused.cpp
src/parameter/parametercheckbox.cpp
src/parameter/parametercombobox.cpp
src/parameter/parameterextractor.cpp
src/parameter/parameterobject.cpp
src/parameter/parameterslider.cpp
src/parameter/parameterspinbox.cpp
src/parameter/parametertext.cpp
src/parameter/parametervector.cpp
src/parameter/parametervirtualwidget.cpp
src/parameter/ParameterWidget.cc
src/input/AxisConfigWidget.cc
src/input/ButtonConfigWidget.cc
src/input/InputDriver.cc
src/input/InputDriverManager.cc
src/input/InputEventMapper.cc
src/input/WheelIgnorer.cc
${INPUT_DRIVER_SOURCES}
)
# header-only code
set(GUI_HEADERS
src/gui/AboutDialog.h
src/gui/MainWindow.h
src/octoprint/Network.h
src/octoprint/NetworkSignal.h
)
file(GLOB UIs src/*.ui)
file(GLOB Resources *.qrc)
set(Sources src/openscad.cc ${CORE_SOURCES} ${CGAL_SOURCES} ${OFFSCREEN_SOURCES} ${Resources})
if(HEADLESS)
add_definitions(-DOPENSCAD_NOGUI)
else()
list(APPEND Sources ${GUI_SOURCES} ${GUI_HEADERS})
endif()
if (SNAPSHOT)
add_definitions(-DOPENSCAD_SNAPSHOT)
set(RESOURCE_FILES icons/icon-nightly.icns)
else()
set(RESOURCE_FILES icons/OpenSCAD.icns)
endif()
if(ENABLE_SPNAV)
add_definitions(-DENABLE_SPNAV)
list(APPEND Sources src/input/SpaceNavInputDriver.cc)
endif()
add_executable(OpenSCAD ${Sources} ${RESOURCE_FILES})
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}"
)
elseif(UNIX)
set_target_properties(OpenSCAD PROPERTIES
OUTPUT_NAME openscad
)
elseif(MSVC)
set_target_properties(OpenSCAD PROPERTIES
LINK_FLAGS "-subsystem:windows -ENTRY:mainCRTStartup -stack:8388608"
)
endif()
if(ENABLE_SPNAV)
target_link_libraries(OpenSCAD spnav)
endif()
target_link_libraries(OpenSCAD PRIVATE ${COMMON_LIBRARIES} ${PLATFORM_LIBS})
if(NOT HEADLESS)
target_link_libraries(OpenSCAD PRIVATE Qt5::Core Qt5::Widgets Qt5::Multimedia Qt5::OpenGL Qt5::Concurrent Qt5::Network ${QT5QSCINTILLA_LIBRARY} ${Qt5DBus_LIBRARIES} ${Qt5Gamepad_LIBRARIES})
endif()
if(INFO)
include(info)
endif()
add_subdirectory(tests)