git: a065119e038f - main - cad/cura-engine: upgrade to 5.7.0

From: Diane Bruce <db_at_FreeBSD.org>
Date: Wed, 04 Sep 2024 20:58:45 UTC
The branch main has been updated by db:

URL: https://cgit.FreeBSD.org/ports/commit/?id=a065119e038f865b97b1191dad95aef6c4482b8b

commit a065119e038f865b97b1191dad95aef6c4482b8b
Author:     Matthieu Volat <mazhe@alkumuna.eu>
AuthorDate: 2024-09-04 20:57:15 +0000
Commit:     Diane Bruce <db@FreeBSD.org>
CommitDate: 2024-09-04 20:57:15 +0000

    cad/cura-engine:  upgrade to 5.7.0
    
    - redo build system for our system
    - prepare for cura 5.7.0
---
 cad/cura-engine/Makefile                      |  51 ++-
 cad/cura-engine/distinfo                      |  16 +-
 cad/cura-engine/files/CMakeLists.txt          | 419 +++++++++++++++++++++
 cad/cura-engine/files/CPackConfig.cmake       |  20 +
 cad/cura-engine/files/FindGMock.cmake         | 515 ++++++++++++++++++++++++++
 cad/cura-engine/files/FindPolyclipping.cmake  |  67 ++++
 cad/cura-engine/files/FindStb.cmake           |  69 ++++
 cad/cura-engine/files/patch-CMakeLists.txt    |  19 -
 cad/cura-engine/files/patch-src_layerPart.cpp |   8 -
 cad/cura-engine/files/patch-src_support.cpp   |   8 -
 10 files changed, 1136 insertions(+), 56 deletions(-)

diff --git a/cad/cura-engine/Makefile b/cad/cura-engine/Makefile
index b311474f45db..04dba316b484 100644
--- a/cad/cura-engine/Makefile
+++ b/cad/cura-engine/Makefile
@@ -1,6 +1,5 @@
 PORTNAME=		CuraEngine
-DISTVERSION=		4.13.1
-PORTREVISION=	2
+PORTVERSION=		5.7.0
 PORTEPOCH=		1
 CATEGORIES=		cad
 DIST_SUBDIR=		Ultimaker
@@ -11,28 +10,48 @@ WWW=		http://wiki.ultimaker.com/Cura
 
 LICENSE=	AGPLv3
 
-DEPRECATED=	Depends on expired net/libarcus
-EXPIRATION_DATE=2024-07-31
+BUILD_DEPENDS=	${LOCALBASE}/include/boost/uuid/uuid.hpp:devel/boost-libs \
+		${LOCALBASE}/include/fmt/format.h:devel/libfmt \
+		${LOCALBASE}/include/range/v3/range.hpp:devel/range-v3 \
+		${LOCALBASE}/include/rapidjson/rapidjson.h:devel/rapidjson
+LIB_DEPENDS=	libArcus.so:net/libarcus \
+		libpolyclipping.so:graphics/polyclipping \
+		libprotobuf.so:devel/protobuf \
+		libspdlog.so:devel/spdlog
 
-LIB_DEPENDS=	libArcus.so:net/libarcus	\
-		libprotobuf.so:devel/protobuf
+USES=		compiler:c++20-lang cmake pkgconfig
 
-USES=		compiler:c++11-lang cmake
-
-STB_TAG=	d5d052c
+STB_TAG=	beebb24
+SCRIPTA_TAG=	c378c83
+GEOMETRYHPP_TAG=3b1a10e
+WAGYU_TAG=	0.5.0
 
 USE_GITHUB=	yes
 GH_ACCOUNT=	Ultimaker
 GH_PROJECT=	CuraEngine
-GH_TUPLE=	nothings:stb:${STB_TAG}:stb/include/stb
-
-CMAKE_ARGS+=	-DStb_FOUND:BOOL=ON		\
-		-DStb_INCLUDE_DIRS=${WRKSRC}/include
+GH_TUPLE=	mapbox:geometry.hpp:${GEOMETRYHPP_TAG}:geometryhpp \
+		mapbox:wagyu:${WAGYU_TAG}:wagyu \
+		nothings:stb:${STB_TAG}:stb/include/stb \
+		Ultimaker:Scripta_public:${SCRIPTA_TAG}:Scripta_public
 
-# disable OpenMP as it does not work (at least) on CURRENT.
-# OpenMP support is planned to be replaced with native thread.
-# see files/patch-CMakeLists.txt
+CMAKE_ARGS+=	-DUSE_SYSTEM_LIBS:BOOL=ON \
+		-DStb_FOUND:BOOL=ON \
+		-DStb_INCLUDE_DIRS=${WRKSRC}/include/stb
+LDFLAGS+=	-L${LOCALBASE}/lib
+WITH_DEBUGINFO=	1 # Will segfault if Release
 
 PLIST_FILES=	bin/CuraEngine
 
+post-extract:
+	@${MKDIR} ${WRKSRC}/cmake
+	@for f in FindGMock.cmake FindPolyclipping.cmake FindStb.cmake; do \
+		${CP} ${FILESDIR}/$$f ${WRKSRC}/cmake; \
+		done
+	@for f in CMakeLists.txt CPackConfig.cmake; do \
+		${CP} ${FILESDIR}/$$f ${WRKSRC}; \
+		done
+	@${MV} ${WRKDIR}/Scripta_public-${SCRIPTA_TAG}/include/scripta ${WRKSRC}/include
+	@${MV} ${WRKDIR}/geometry.hpp-${GEOMETRYHPP_TAG}/include/mapbox ${WRKSRC}/include
+	@${MV} ${WRKDIR}/wagyu-${WAGYU_TAG}/include/mapbox/geometry/wagyu ${WRKSRC}/include/mapbox/geometry
+
 .include <bsd.port.mk>
diff --git a/cad/cura-engine/distinfo b/cad/cura-engine/distinfo
index 4c534022b2b3..10a1cc975f51 100644
--- a/cad/cura-engine/distinfo
+++ b/cad/cura-engine/distinfo
@@ -1,5 +1,11 @@
-TIMESTAMP = 1645697559
-SHA256 (Ultimaker/Ultimaker-CuraEngine-4.13.1_GH0.tar.gz) = 283f62326c6072cdcef9d9b84cb8141a6072747f08e1cae6534d08ad85b1c657
-SIZE (Ultimaker/Ultimaker-CuraEngine-4.13.1_GH0.tar.gz) = 1727935
-SHA256 (Ultimaker/nothings-stb-d5d052c_GH0.tar.gz) = ce1a6424b43287166a962827d83d98cedcd9d515e69052b17d8a7896f9fb7517
-SIZE (Ultimaker/nothings-stb-d5d052c_GH0.tar.gz) = 1358441
+TIMESTAMP = 1713896563
+SHA256 (Ultimaker/Ultimaker-CuraEngine-5.7.0_GH0.tar.gz) = b0f3ccd1e1813354fdc1ced7bed322033cc846cd07454547328bdb4cb313b00b
+SIZE (Ultimaker/Ultimaker-CuraEngine-5.7.0_GH0.tar.gz) = 1780860
+SHA256 (Ultimaker/mapbox-geometry.hpp-3b1a10e_GH0.tar.gz) = 5af2b21a10c18a364f5a7e7a077655514f2708ea5537f592e1edfb3f25f508ee
+SIZE (Ultimaker/mapbox-geometry.hpp-3b1a10e_GH0.tar.gz) = 19518
+SHA256 (Ultimaker/mapbox-wagyu-0.5.0_GH0.tar.gz) = 88c41eaba03107ebe79052fdbd66e419e903d331a2616a51849018e13648ab83
+SIZE (Ultimaker/mapbox-wagyu-0.5.0_GH0.tar.gz) = 822342
+SHA256 (Ultimaker/nothings-stb-beebb24_GH0.tar.gz) = f617df64be72137bfc680675a3e0bb9532bc89dbb1facca551885efa6d5f449e
+SIZE (Ultimaker/nothings-stb-beebb24_GH0.tar.gz) = 1506973
+SHA256 (Ultimaker/Ultimaker-Scripta_public-c378c83_GH0.tar.gz) = 1c21e1fefd661dd93445d0cfcfb9eaac89c10bd855b7914830c6c8b1a9b17287
+SIZE (Ultimaker/Ultimaker-Scripta_public-c378c83_GH0.tar.gz) = 16918
diff --git a/cad/cura-engine/files/CMakeLists.txt b/cad/cura-engine/files/CMakeLists.txt
new file mode 100644
index 000000000000..73e0ec08a4e9
--- /dev/null
+++ b/cad/cura-engine/files/CMakeLists.txt
@@ -0,0 +1,419 @@
+#Copyright (c) 2020 Ultimaker B.V.
+#CuraEngine is released under the terms of the AGPLv3 or higher.
+
+cmake_minimum_required(VERSION 3.8.0)
+
+project(CuraEngine)
+
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
+
+option(ENABLE_ARCUS "Enable support for ARCUS" ON)
+
+if (MSVC)
+    option(MSVC_STATIC_RUNTIME "Link the MSVC runtime statically" OFF)
+endif()
+
+if(ENABLE_ARCUS)
+    message(STATUS "Building with Arcus")
+    # We want to have access to protobuf_generate_cpp and other FindProtobuf features.
+    # However, if ProtobufConfig is used instead, there is a CMake option that controls
+    # this, which defaults to OFF. We need to force this option to ON instead.
+    set(protobuf_MODULE_COMPATIBLE ON CACHE INTERNAL "" FORCE)
+    find_package(Protobuf 3.0.0 REQUIRED)
+    find_package(Arcus REQUIRED)
+    add_definitions(-DARCUS)
+    find_program(PROTOC "protoc")
+    if(${PROTOC} STREQUAL "PROTOC-NOTFOUND")
+        message(FATAL_ERROR "Protobuf compiler missing")
+    endif()
+endif()
+
+#For reading image files.
+find_package(Stb REQUIRED)
+include_directories(${Stb_INCLUDE_DIRS})
+
+option(USE_SYSTEM_LIBS "Use the system libraries if available" OFF)
+if(USE_SYSTEM_LIBS)
+    find_package(RapidJSON CONFIG REQUIRED)
+    find_package(Polyclipping REQUIRED)
+endif()
+
+# convert build type to upper case letters
+if(CMAKE_BUILD_TYPE)
+    string(TOUPPER ${CMAKE_BUILD_TYPE} CMAKE_BUILD_TYPE_UPPER)
+endif()
+
+if(CMAKE_BUILD_TYPE_UPPER MATCHES "DEBUG")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_DEBUG_INIT}")
+else()
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE_INIT}")
+endif()
+
+set(CMAKE_CXX_STANDARD 20)
+
+if(APPLE AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
+endif()
+
+OPTION(SET_RPATH ON)
+
+if(SET_RPATH)
+    if(NOT DEFINED LIB_SUFFIX)
+        set(LIB_SUFFIX "")
+    endif()
+    set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib${LIB_SUFFIX}")
+endif()
+
+set(CURA_ENGINE_VERSION "master" CACHE STRING "Version name of Cura")
+
+option(BUILD_TESTS OFF)
+
+# Add a compiler flag to check the output for insane values if we are in debug mode.
+if(CMAKE_BUILD_TYPE_UPPER MATCHES "DEBUG" OR CMAKE_BUILD_TYPE_UPPER MATCHES "RELWITHDEBINFO")
+    message(STATUS "Building debug release of CuraEngine.")
+    if (NOT MSVC)
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wextra -O0 -g -fno-omit-frame-pointer")
+    endif()
+    add_definitions(-DASSERT_INSANE_OUTPUT)
+    add_definitions(-DUSE_CPU_TIME)
+    add_definitions(-DDEBUG)
+endif()
+
+if (MSVC)
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive- /Zc:twoPhase- /EHsc /W3")
+    if (MSVC_STATIC_RUNTIME)
+        foreach(flag_var
+            CMAKE_CXX_FLAGS
+            CMAKE_CXX_FLAGS_DEBUG
+            CMAKE_CXX_FLAGS_RELEASE
+            CMAKE_CXX_FLAGS_MINSIZEREL
+            CMAKE_CXX_FLAGS_RELWITHDEBINFO
+            )
+            if(${flag_var} MATCHES "/MD")
+                string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
+            endif()
+        endforeach()
+    endif()
+else()
+    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall") # Add warnings
+endif()
+
+option (ENABLE_MORE_COMPILER_OPTIMIZATION_FLAGS
+    "Enable more optimization flags" ON)
+if (ENABLE_MORE_COMPILER_OPTIMIZATION_FLAGS AND NOT (CMAKE_BUILD_TYPE_UPPER MATCHES "DEBUG"))
+    message (STATUS "Compile with more optimization flags")
+    if (MSVC)
+        set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} /fp:fast")
+    else()
+        set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS} -Ofast -funroll-loops")
+    endif()
+endif ()
+
+#if(NOT APPLE AND NOT WIN32)
+#    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libstdc++")
+#endif()
+
+if (WIN32)
+    add_definitions(-DNOMINMAX)
+endif()
+
+add_definitions(-DSPDLOG_FMT_EXTERNAL)
+
+option (ENABLE_OPENMP
+    "Use OpenMP for parallel code" ON)
+
+if (ENABLE_OPENMP)
+    FIND_PACKAGE( OpenMP )
+    if( OPENMP_FOUND )
+        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}" )
+    endif()
+endif()
+
+if(USE_SYSTEM_LIBS)
+    include_directories(${Polyclipping_INCLUDE_DIRS} "${CMAKE_BINARY_DIR}" ${RAPIDJSON_INCLUDE_DIRS} include)
+else()
+    include_directories("${CMAKE_CURRENT_BINARY_DIR}" libs libs/clipper include)
+    add_library(clipper STATIC libs/clipper/clipper.cpp)
+endif()
+
+set(engine_SRCS # Except main.cpp.
+    src/Application.cpp
+    src/ConicalOverhang.cpp
+    src/ExtruderPlan.cpp
+    src/ExtruderTrain.cpp
+    src/FffGcodeWriter.cpp
+    src/FffPolygonGenerator.cpp
+    src/FffProcessor.cpp
+    src/GCodePathConfig.cpp
+    src/InsetOrderOptimizer.cpp
+    src/InterlockingGenerator.cpp
+    src/LayerPlan.cpp
+    src/LayerPlanBuffer.cpp
+    src/MeshGroup.cpp
+    src/Mold.cpp
+    src/PathOrderPath.cpp
+    src/Preheat.cpp
+    src/PrimeTower.cpp
+    src/Scene.cpp
+    src/SkeletalTrapezoidation.cpp
+    src/SkeletalTrapezoidationGraph.cpp
+    src/SkirtBrim.cpp
+    src/Slice.cpp
+    src/SupportInfillPart.cpp
+    src/TopSurface.cpp
+    src/TreeModelVolumes.cpp
+    src/TreeSupport.cpp
+    src/TreeSupportTipGenerator.cpp
+    src/WallToolPaths.cpp
+    src/WallsComputation.cpp
+    src/bridge.cpp
+    src/gcodeExport.cpp
+    src/infill.cpp
+    src/layerPart.cpp
+    src/main.cpp
+    src/mesh.cpp
+    src/multiVolumes.cpp
+    src/raft.cpp
+    src/skin.cpp
+    src/sliceDataStorage.cpp
+    src/slicer.cpp
+    src/support.cpp
+    src/timeEstimate.cpp
+
+    src/BeadingStrategy/BeadingStrategy.cpp
+    src/BeadingStrategy/BeadingStrategyFactory.cpp
+    src/BeadingStrategy/DistributedBeadingStrategy.cpp
+    src/BeadingStrategy/LimitedBeadingStrategy.cpp
+    src/BeadingStrategy/OuterWallInsetBeadingStrategy.cpp
+    src/BeadingStrategy/RedistributeBeadingStrategy.cpp
+    src/BeadingStrategy/WideningBeadingStrategy.cpp
+
+    src/communication/ArcusCommunication.cpp
+    src/communication/ArcusCommunicationPrivate.cpp
+    src/communication/CommandLine.cpp
+    src/communication/Listener.cpp
+
+    src/infill/GyroidInfill.cpp
+    src/infill/ImageBasedDensityProvider.cpp
+    src/infill/LightningDistanceField.cpp
+    src/infill/LightningGenerator.cpp
+    src/infill/LightningLayer.cpp
+    src/infill/LightningTreeNode.cpp
+    src/infill/NoZigZagConnectorProcessor.cpp
+    src/infill/SierpinskiFill.cpp
+    src/infill/SierpinskiFillProvider.cpp
+    src/infill/SubDivCube.cpp
+    src/infill/ZigzagConnectorProcessor.cpp
+
+    src/pathPlanning/Comb.cpp
+    src/pathPlanning/GCodePath.cpp
+    src/pathPlanning/LinePolygonsCrossings.cpp
+    src/pathPlanning/NozzleTempInsert.cpp
+    src/pathPlanning/SpeedDerivatives.cpp
+
+    src/progress/Progress.cpp
+    src/progress/ProgressStageEstimator.cpp
+
+    src/settings/AdaptiveLayerHeights.cpp
+    src/settings/FlowTempGraph.cpp
+    src/settings/MeshPathConfigs.cpp
+    src/settings/PathConfigStorage.cpp
+    src/settings/Settings.cpp
+    src/settings/ZSeamConfig.cpp
+
+    src/utils/AABB.cpp
+    src/utils/AABB3D.cpp
+    src/utils/Date.cpp
+    src/utils/ExtrusionJunction.cpp
+    src/utils/ExtrusionLine.cpp
+    src/utils/ExtrusionSegment.cpp
+    src/utils/LinearAlg2D.cpp
+    src/utils/ListPolyIt.cpp
+    src/utils/Matrix4x3D.cpp
+    src/utils/MinimumSpanningTree.cpp
+    src/utils/Point3LL.cpp
+    src/utils/PolygonConnector.cpp
+    src/utils/PolygonsPointIndex.cpp
+    src/utils/PolygonsSegmentIndex.cpp
+    src/utils/PolylineStitcher.cpp
+    src/utils/SVG.cpp
+    src/utils/Simplify.cpp
+    src/utils/SquareGrid.cpp
+    src/utils/ThreadPool.cpp
+    src/utils/ToolpathVisualizer.cpp
+    src/utils/VoronoiUtils.cpp
+    src/utils/VoxelUtils.cpp
+    src/utils/channel.cpp
+    src/utils/gettime.cpp
+    src/utils/polygon.cpp
+    src/utils/polygonUtils.cpp
+)
+
+# List of tests. For each test there must be a file tests/${NAME}.cpp.
+set(engine_TEST
+    GCodeExportTest
+    InfillTest
+    LayerPlanTest
+    MergeInfillLinesTest
+    PathOrderMonotonicTest
+    TimeEstimateCalculatorTest
+)
+set(engine_TEST_INTEGRATION
+    SlicePhaseTest
+)
+set(engine_TEST_SETTINGS
+    SettingsTest
+)
+if (ENABLE_ARCUS)
+    set(engine_TEST_ARCUS
+        ArcusCommunicationTest
+        ArcusCommunicationPrivateTest
+    )
+endif ()
+set(engine_TEST_UTILS
+    AABBTest
+    AABB3DTest
+    IntPointTest
+    LinearAlg2DTest
+    MinimumSpanningTreeTest
+    PolygonConnectorTest
+    PolygonTest
+    PolygonUtilsTest
+    SparseGridTest
+    StringTest
+    UnionFindTest
+)
+
+# Helper classes for some tests.
+set(engine_TEST_ARCUS_HELPERS
+    tests/arcus/MockSocket.cpp
+)
+set(engine_TEST_HELPERS
+    tests/ReadTestPolygons.cpp
+)
+
+# Generating ProtoBuf protocol
+if (ENABLE_ARCUS)
+    protobuf_generate_cpp(engine_PB_SRCS engine_PB_HEADERS Cura.proto)
+endif ()
+
+# Compiling CuraEngine itself.
+add_library(_CuraEngine STATIC ${engine_SRCS} ${engine_PB_SRCS}) #First compile all of CuraEngine as library, allowing this to be re-used for tests.
+
+if (CuraEngine_Download_Stb)
+    add_dependencies(_CuraEngine stb)
+endif()
+if(USE_SYSTEM_LIBS)
+    target_link_libraries(_CuraEngine ${Polyclipping_LIBRARIES})
+else()
+    target_link_libraries(_CuraEngine clipper)
+endif()
+
+if (ENABLE_ARCUS)
+    target_link_libraries(_CuraEngine Arcus)
+endif ()
+
+target_link_libraries(_CuraEngine fmt absl_log_internal_message absl_log_internal_check_op)
+
+set_target_properties(_CuraEngine PROPERTIES COMPILE_DEFINITIONS "VERSION=\"${CURA_ENGINE_VERSION}\"")
+
+if(WIN32)
+  message(STATUS "Using windres")
+  set(RES_FILES "CuraEngine.rc")
+  ENABLE_LANGUAGE(RC)
+  if(NOT MSVC)
+    SET(CMAKE_RC_COMPILER_INIT windres)
+    SET(CMAKE_RC_COMPILE_OBJECT
+        "<CMAKE_RC_COMPILER> <FLAGS> -O coff <DEFINES> -i <SOURCE> -o <OBJECT>"
+        )
+ endif()
+endif(WIN32)
+
+if (UNIX)
+    target_link_libraries(_CuraEngine pthread)
+endif()
+
+if (NOT WIN32)
+  add_executable(CuraEngine src/main.cpp) # Then compile main.cpp as separate executable, and link the library to it.
+else()
+  add_executable(CuraEngine src/main.cpp ${RES_FILES}) # ..., but don't forget the glitter!
+endif(NOT WIN32)
+
+target_link_libraries(CuraEngine _CuraEngine)
+set_target_properties(CuraEngine PROPERTIES COMPILE_DEFINITIONS "VERSION=\"${CURA_ENGINE_VERSION}\"")
+
+# Compiling the test environment.
+if (BUILD_TESTS)
+    include(CTest)
+
+    message(STATUS "Building tests...")
+    set(GTEST_USE_STATIC_LIBS true)
+    set(GMOCK_ROOT "${CMAKE_CURRENT_BINARY_DIR}/gmock")
+    set(GMOCK_VER "1.8.0")
+    find_package(GMock REQUIRED)
+    include_directories(${GTEST_INCLUDE_DIRS})
+    include_directories(${GMOCK_INCLUDE_DIRS})
+    add_dependencies(_CuraEngine GTest::GTest GTest::Main GMock::GMock GMock::Main)
+    add_definitions(-DBUILD_TESTS)
+
+    target_compile_definitions(_CuraEngine PUBLIC BUILD_TESTS=1)
+
+    #To make sure that the tests are built before running them, add the building of these tests as an additional test.
+    add_custom_target(build_all_tests)
+    add_test(BuildTests "${CMAKE_COMMAND}" --build "${CMAKE_CURRENT_BINARY_DIR}" --target build_all_tests)
+
+    foreach (test ${engine_TEST})
+        add_executable(${test} tests/main.cpp ${engine_TEST_HELPERS} tests/${test}.cpp)
+        target_link_libraries(${test} _CuraEngine ${GTEST_BOTH_LIBRARIES} ${GMOCK_BOTH_LIBRARIES})
+        add_test(NAME ${test} COMMAND "${test}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/tests/")
+        add_dependencies(build_all_tests ${test}) #Make sure that this gets built as part of the build_all_tests target.
+    endforeach()
+    foreach (test ${engine_TEST_INFILL})
+        add_executable(${test} tests/main.cpp tests/infill/${test}.cpp)
+        target_link_libraries(${test} _CuraEngine ${GTEST_BOTH_LIBRARIES} ${GMOCK_BOTH_LIBRARIES})
+        add_test(NAME ${test} COMMAND "${test}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/tests/")
+        add_dependencies(build_all_tests ${test}) #Make sure that this gets built as part of the build_all_tests target.
+    endforeach()
+    foreach (test ${engine_TEST_INTEGRATION})
+        add_executable(${test} tests/main.cpp tests/integration/${test}.cpp)
+        target_link_libraries(${test} _CuraEngine ${GTEST_BOTH_LIBRARIES} ${GMOCK_BOTH_LIBRARIES})
+        add_test(NAME ${test} COMMAND "${test}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/tests/")
+        add_dependencies(build_all_tests ${test}) #Make sure that this gets built as part of the build_all_tests target.
+    endforeach()
+    foreach (test ${engine_TEST_SETTINGS})
+        add_executable(${test} tests/main.cpp tests/settings/${test}.cpp)
+        target_link_libraries(${test} _CuraEngine ${GTEST_BOTH_LIBRARIES} ${GMOCK_BOTH_LIBRARIES})
+        add_test(NAME ${test} COMMAND "${test}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/tests/")
+        add_dependencies(build_all_tests ${test}) #Make sure that this gets built as part of the build_all_tests target.
+    endforeach()
+    if (ENABLE_ARCUS)
+        foreach (test ${engine_TEST_ARCUS})
+            add_executable(${test} tests/main.cpp ${engine_TEST_ARCUS_HELPERS} tests/arcus/${test}.cpp)
+            target_link_libraries(${test} _CuraEngine ${GTEST_BOTH_LIBRARIES} ${GMOCK_BOTH_LIBRARIES})
+            add_test(NAME ${test} COMMAND "${test}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/tests/")
+            add_dependencies(build_all_tests ${test}) #Make sure that this gets built as part of the build_all_tests target.
+        endforeach()
+    endif ()
+    foreach (test ${engine_TEST_UTILS})
+        add_executable(${test} tests/main.cpp tests/utils/${test}.cpp)
+        target_link_libraries(${test} _CuraEngine ${GTEST_BOTH_LIBRARIES} ${GMOCK_BOTH_LIBRARIES})
+        add_test(NAME ${test} COMMAND "${test}" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/tests/")
+        add_dependencies(build_all_tests ${test}) #Make sure that this gets built as part of the build_all_tests target.
+    endforeach()
+endif()
+
+# Installing CuraEngine.
+include(GNUInstallDirs)
+install(TARGETS CuraEngine DESTINATION "${CMAKE_INSTALL_BINDIR}")
+# For MinGW64 cross compiling on Debian, we create a ZIP package instead of a DEB
+# Because it's the Windows build system that should install the files.
+if (CMAKE_CROSSCOMPILING AND CMAKE_SYSTEM_NAME MATCHES "Windows")
+    message(STATUS "Include MinGW64 posix DLLs for installation.")
+    install(FILES
+            /usr/lib/gcc/x86_64-w64-mingw32/8.3-posix/libgcc_s_seh-1.dll
+            /usr/lib/gcc/x86_64-w64-mingw32/8.3-posix/libgomp-1.dll
+            /usr/lib/gcc/x86_64-w64-mingw32/8.3-posix/libstdc++-6.dll
+            DESTINATION bin
+            COMPONENT runtime)
+endif ()
+include(CPackConfig.cmake)
diff --git a/cad/cura-engine/files/CPackConfig.cmake b/cad/cura-engine/files/CPackConfig.cmake
new file mode 100644
index 000000000000..91c4b71d0562
--- /dev/null
+++ b/cad/cura-engine/files/CPackConfig.cmake
@@ -0,0 +1,20 @@
+set(CPACK_PACKAGE_VENDOR "Ultimaker")
+set(CPACK_PACKAGE_CONTACT "Arjen Hiemstra <a.hiemstra@ultimaker.com>")
+set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Cura Engine")
+set(CPACK_PACKAGE_VERSION "15.05.90")
+set(CPACK_GENERATOR "DEB")
+if(NOT DEFINED CPACK_DEBIAN_PACKAGE_ARCHITECTURE)
+  execute_process(COMMAND dpkg --print-architecture OUTPUT_VARIABLE CPACK_DEBIAN_PACKAGE_ARCHITECTURE OUTPUT_STRIP_TRAILING_WHITESPACE)
+endif()
+set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${CPACK_PACKAGE_VERSION}_${CPACK_DEBIAN_PACKAGE_ARCHITECTURE}")
+
+set(DEB_DEPENDS
+    "arcus (>= 15.05.90)"
+    "protobuf (>= 3.0.0)"
+    "libstdc++6 (>= 4.9.0)"
+    "libgcc1 (>= 4.9.0)"
+)
+string(REPLACE ";" ", " DEB_DEPENDS "${DEB_DEPENDS}")
+set(CPACK_DEBIAN_PACKAGE_DEPENDS ${DEB_DEPENDS})
+
+include(CPack)
diff --git a/cad/cura-engine/files/FindGMock.cmake b/cad/cura-engine/files/FindGMock.cmake
new file mode 100644
index 000000000000..8d732424234a
--- /dev/null
+++ b/cad/cura-engine/files/FindGMock.cmake
@@ -0,0 +1,515 @@
+# Get the Google C++ Mocking Framework.
+# (This file is almost an copy of the original FindGTest.cmake file,
+#  altered to download and compile GMock and GTest if not found
+#  in GMOCK_ROOT or GTEST_ROOT respectively,
+#  feel free to use it as it is or modify it for your own needs.)
+#
+# Defines the following variables:
+#
+#   GMOCK_FOUND - Found or got the Google Mocking framework
+#   GTEST_FOUND - Found or got the Google Testing framework
+#   GMOCK_INCLUDE_DIRS - GMock include directory
+#   GTEST_INCLUDE_DIRS - GTest include direcotry
+#
+# Also defines the library variables below as normal variables
+#
+#   GMOCK_BOTH_LIBRARIES - Both libgmock & libgmock_main
+#   GMOCK_LIBRARIES - libgmock
+#   GMOCK_MAIN_LIBRARIES - libgmock-main
+#
+#   GTEST_BOTH_LIBRARIES - Both libgtest & libgtest_main
+#   GTEST_LIBRARIES - libgtest
+#   GTEST_MAIN_LIBRARIES - libgtest_main
+#
+# Accepts the following variables as input:
+#
+#   GMOCK_ROOT - The root directory of the gmock install prefix
+#   GTEST_ROOT - The root directory of the gtest install prefix
+#   GMOCK_SRC_DIR -The directory of the gmock sources
+#   GMOCK_VER - The version of the gmock sources to be downloaded
+#
+#-----------------------
+# Example Usage:
+#
+#    set(GMOCK_ROOT "~/gmock")
+#    find_package(GMock REQUIRED)
+#    include_directories(${GMOCK_INCLUDE_DIRS})
+#
+#    add_executable(foo foo.cc)
+#    target_link_libraries(foo ${GMOCK_BOTH_LIBRARIES})
+#
+#=============================================================================
+# Copyright (c) 2016 Michel Estermann
+# Copyright (c) 2016 Kamil Strzempowicz
+# Copyright (c) 2011 Matej Svec
+#
+# CMake - Cross Platform Makefile Generator
+# Copyright 2000-2016 Kitware, Inc.
+# Copyright 2000-2011 Insight Software Consortium
+# All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+#
+# * Redistributions of source code must retain the above copyright
+#   notice, this list of conditions and the following disclaimer.
+#
+# * Redistributions in binary form must reproduce the above copyright
+#   notice, this list of conditions and the following disclaimer in the
+#   documentation and/or other materials provided with the distribution.
+#
+# * Neither the names of Kitware, Inc., the Insight Software Consortium,
+#   nor the names of their contributors may be used to endorse or promote
+#   products derived from this software without specific prior written
+#   permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+# ------------------------------------------------------------------------------
+#
+# The above copyright and license notice applies to distributions of
+# CMake in source and binary form.  Some source files contain additional
+# notices of original copyright by their contributors; see each source
+# for details.  Third-party software packages supplied with CMake under
+# compatible licenses provide their own copyright notices documented in
+# corresponding subdirectories.
+#
+# ------------------------------------------------------------------------------
+#
+# CMake was initially developed by Kitware with the following sponsorship:
+#
+#  * National Library of Medicine at the National Institutes of Health
+#    as part of the Insight Segmentation and Registration Toolkit (ITK).
+#
+#  * US National Labs (Los Alamos, Livermore, Sandia) ASC Parallel
+#    Visualization Initiative.
+#
+#  * National Alliance for Medical Image Computing (NAMIC) is funded by the
+#    National Institutes of Health through the NIH Roadmap for Medical Research,
+#    Grant U54 EB005149.
+#
+#  * Kitware, Inc.
+#=============================================================================
+# Thanks to Daniel Blezek <blezek@gmail.com> for the GTEST_ADD_TESTS code
+
+function(gtest_add_tests executable extra_args)
+    if(NOT ARGN)
+        message(FATAL_ERROR "Missing ARGN: Read the documentation for GTEST_ADD_TESTS")
+    endif()
+    if(ARGN STREQUAL "AUTO")
+        # obtain sources used for building that executable
+        get_property(ARGN TARGET ${executable} PROPERTY SOURCES)
+    endif()
+    set(gtest_case_name_regex ".*\\( *([A-Za-z_0-9]+) *, *([A-Za-z_0-9]+) *\\).*")
+    set(gtest_test_type_regex "(TYPED_TEST|TEST_?[FP]?)")
+    foreach(source ${ARGN})
+        file(READ "${source}" contents)
+        string(REGEX MATCHALL "${gtest_test_type_regex} *\\(([A-Za-z_0-9 ,]+)\\)" found_tests ${contents})
+        foreach(hit ${found_tests})
+            string(REGEX MATCH "${gtest_test_type_regex}" test_type ${hit})
+
+            # Parameterized tests have a different signature for the filter
+            if("x${test_type}" STREQUAL "xTEST_P")
+                string(REGEX REPLACE ${gtest_case_name_regex} "*/\\1.\\2/*" test_name ${hit})
+            elseif("x${test_type}" STREQUAL "xTEST_F" OR "x${test_type}" STREQUAL "xTEST")
+                string(REGEX REPLACE ${gtest_case_name_regex} "\\1.\\2" test_name ${hit})
+            elseif("x${test_type}" STREQUAL "xTYPED_TEST")
+                string(REGEX REPLACE ${gtest_case_name_regex} "\\1/*.\\2" test_name ${hit})
+            else()
+                message(WARNING "Could not parse GTest ${hit} for adding to CTest.")
+                continue()
+            endif()
+            add_test(NAME ${test_name} COMMAND ${executable} --gtest_filter=${test_name} ${extra_args})
+        endforeach()
+    endforeach()
+endfunction()
+
+function(_append_debugs _endvar _library)
+    if(${_library} AND ${_library}_DEBUG)
+        set(_output optimized ${${_library}} debug ${${_library}_DEBUG})
+    else()
+        set(_output ${${_library}})
+    endif()
+    set(${_endvar} ${_output} PARENT_SCOPE)
+endfunction()
+
+function(_gmock_find_library _name)
+    find_library(${_name}
+        NAMES ${ARGN}
+        HINTS
+        ENV GMOCK_ROOT
+        ${GMOCK_ROOT}
+        PATH_SUFFIXES ${_gmock_libpath_suffixes}
+        )
+    mark_as_advanced(${_name})
+endfunction()
+
+function(_gtest_find_library _name)
+    find_library(${_name}
+        NAMES ${ARGN}
+        HINTS
+        ENV GTEST_ROOT
+        ${GTEST_ROOT}
+        PATH_SUFFIXES ${_gtest_libpath_suffixes}
+        )
+    mark_as_advanced(${_name})
+endfunction()
+
+if(NOT DEFINED GMOCK_MSVC_SEARCH)
+    set(GMOCK_MSVC_SEARCH MD)
+endif()
+
+set(_gmock_libpath_suffixes lib)
+set(_gtest_libpath_suffixes lib)
+if(MSVC)
+    if(GMOCK_MSVC_SEARCH STREQUAL "MD")
+        list(APPEND _gmock_libpath_suffixes
+            msvc/gmock-md/Debug
+            msvc/gmock-md/Release)
+        list(APPEND _gtest_libpath_suffixes
+            msvc/gtest-md/Debug
+            msvc/gtest-md/Release)
+    elseif(GMOCK_MSVC_SEARCH STREQUAL "MT")
+        list(APPEND _gmock_libpath_suffixes
+            msvc/gmock/Debug
+            msvc/gmock/Release)
+        list(APPEND _gtest_libpath_suffixes
+            msvc/gtest/Debug
+            msvc/gtest/Release)
+    endif()
+endif()
+
+find_path(GMOCK_INCLUDE_DIR gmock/gmock.h
+    HINTS
+    $ENV{GMOCK_ROOT}/include
+    ${GMOCK_ROOT}/include
+    )
+mark_as_advanced(GMOCK_INCLUDE_DIR)
+
+find_path(GTEST_INCLUDE_DIR gtest/gtest.h
+    HINTS
+    $ENV{GTEST_ROOT}/include
+    ${GTEST_ROOT}/include
+    )
+mark_as_advanced(GTEST_INCLUDE_DIR)
+
+if(MSVC AND GMOCK_MSVC_SEARCH STREQUAL "MD")
+    # The provided /MD project files for Google Mock add -md suffixes to the
+    # library names.
+    _gmock_find_library(GMOCK_LIBRARY gmock-md gmock)
+    _gmock_find_library(GMOCK_LIBRARY_DEBUG gmock-mdd gmockd)
+    _gmock_find_library(GMOCK_MAIN_LIBRARY gmock_main-md gmock_main)
+    _gmock_find_library(GMOCK_MAIN_LIBRARY_DEBUG gmock_main-mdd gmock_maind)
+
+    _gtest_find_library(GTEST_LIBRARY gtest-md gtest)
+    _gtest_find_library(GTEST_LIBRARY_DEBUG gtest-mdd gtestd)
+    _gtest_find_library(GTEST_MAIN_LIBRARY gtest_main-md gtest_main)
+    _gtest_find_library(GTEST_MAIN_LIBRARY_DEBUG gtest_main-mdd gtest_maind)
+else()
+    _gmock_find_library(GMOCK_LIBRARY gmock)
+    _gmock_find_library(GMOCK_LIBRARY_DEBUG gmockd)
+    _gmock_find_library(GMOCK_MAIN_LIBRARY gmock_main)
+    _gmock_find_library(GMOCK_MAIN_LIBRARY_DEBUG gmock_maind)
+
+    _gtest_find_library(GTEST_LIBRARY gtest)
+    _gtest_find_library(GTEST_LIBRARY_DEBUG gtestd)
+    _gtest_find_library(GTEST_MAIN_LIBRARY gtest_main)
+    _gtest_find_library(GTEST_MAIN_LIBRARY_DEBUG gtest_maind)
+endif()
+
+if(NOT TARGET GTest::GTest)
+    add_library(GTest::GTest UNKNOWN IMPORTED)
+endif()
+if(NOT TARGET GTest::Main)
+    add_library(GTest::Main UNKNOWN IMPORTED)
+endif()
+
+if(NOT TARGET GMock::GMock)
+    add_library(GMock::GMock UNKNOWN IMPORTED)
+endif()
+
+if(NOT TARGET GMock::Main)
+    add_library(GMock::Main UNKNOWN IMPORTED)
+endif()
+
+set(GMOCK_LIBRARY_EXISTS OFF)
+set(GTEST_LIBRARY_EXISTS OFF)
+
+if(EXISTS "${GMOCK_LIBRARY}" OR EXISTS "${GMOCK_LIBRARY_DEBUG}" AND GMOCK_INCLUDE_DIR)
+    set(GMOCK_LIBRARY_EXISTS ON)
+endif()
+
+if(EXISTS "${GTEST_LIBRARY}" OR EXISTS "${GTEST_LIBRARY_DEBUG}" AND GTEST_INCLUDE_DIR)
+    set(GTEST_LIBRARY_EXISTS ON)
+endif()
+
+if(NOT (${GMOCK_LIBRARY_EXISTS} AND ${GTEST_LIBRARY_EXISTS}))
+
+    include(ExternalProject)
+
+    if(GTEST_USE_STATIC_LIBS)
+        set(GTEST_CMAKE_ARGS -Dgtest_force_shared_crt:BOOL=ON -DBUILD_SHARED_LIBS=OFF)
+        if(BUILD_SHARED_LIBS)
+            list(APPEND GTEST_CMAKE_ARGS
+                -DCMAKE_POSITION_INDEPENDENT_CODE=ON
+                -Dgtest_hide_internal_symbols=ON
+                -DCMAKE_CXX_VISIBILITY_PRESET=hidden
+                -DCMAKE_VISIBILITY_INLINES_HIDDEN=ON
+                -DCMAKE_POLICY_DEFAULT_CMP0063=NEW
+            )
+        endif()
+        set(GTEST_LIBRARY_PREFIX ${CMAKE_STATIC_LIBRARY_PREFIX})
+    else()
+        set(GTEST_CMAKE_ARGS -DBUILD_SHARED_LIBS=ON)
+        set(GTEST_LIBRARY_PREFIX ${CMAKE_SHARED_LIBRARY_PREFIX})
+    endif()
+    if(WIN32)
+        list(APPEND GTEST_CMAKE_ARGS -Dgtest_disable_pthreads=ON)
+    endif()
+
+    if("${GMOCK_SRC_DIR}" STREQUAL "")
+        message(STATUS "Downloading GMock / GTest version ${GMOCK_VER} from git")
+        if("${GMOCK_VER}" STREQUAL "1.6.0" OR "${GMOCK_VER}" STREQUAL "1.7.0")
+            set(GTEST_BIN_DIR "${GMOCK_ROOT}/src/gtest-build")
+            set(GTEST_LIBRARY "${GTEST_BIN_DIR}/${CMAKE_CFG_INTDIR}/${GTEST_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}")
+            set(GTEST_MAIN_LIBRARY "${GTEST_BIN_DIR}/${CMAKE_CFG_INTDIR}/${GTEST_LIBRARY_PREFIX}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX}")
+            mark_as_advanced(GTEST_LIBRARY)
+            mark_as_advanced(GTEST_MAIN_LIBRARY)
+
+            externalproject_add(
+                gtest
+                GIT_REPOSITORY "https://github.com/google/googletest.git"
+                GIT_TAG "release-${GMOCK_VER}"
+                PREFIX ${GMOCK_ROOT}
+                INSTALL_COMMAND ""
+                LOG_DOWNLOAD ON
+                LOG_CONFIGURE ON
+                LOG_BUILD ON
+                CMAKE_ARGS
+                    ${GTEST_CMAKE_ARGS}
+                BINARY_DIR ${GTEST_BIN_DIR}
+                BUILD_BYPRODUCTS
+                    "${GTEST_LIBRARY}"
+                    "${GTEST_MAIN_LIBRARY}"
+            )
+
+            set(GMOCK_BIN_DIR "${GMOCK_ROOT}/src/gmock-build")
+            set(GMOCK_LIBRARY "${GMOCK_BIN_DIR}/${CMAKE_CFG_INTDIR}/${GTEST_LIBRARY_PREFIX}gmock${CMAKE_STATIC_LIBRARY_SUFFIX}")
+            set(GMOCK_MAIN_LIBRARY "${GMOCK_BIN_DIR}/${CMAKE_CFG_INTDIR}/${GTEST_LIBRARY_PREFIX}gmock_main${CMAKE_STATIC_LIBRARY_SUFFIX}")
+            mark_as_advanced(GMOCK_LIBRARY)
+            mark_as_advanced(GMOCK_MAIN_LIBRARY)
+
+            externalproject_add(
+                gmock
+                GIT_REPOSITORY "https://github.com/google/googlemock.git"
+                GIT_TAG "release-${GMOCK_VER}"
+                PREFIX ${GMOCK_ROOT}
+                INSTALL_COMMAND ""
+                LOG_DOWNLOAD ON
+                LOG_CONFIGURE ON
+                LOG_BUILD ON
+                CMAKE_ARGS
+                    ${GTEST_CMAKE_ARGS}
+                BINARY_DIR ${GMOCK_BIN_DIR}
+                BUILD_BYPRODUCTS
+                    "${GMOCK_LIBRARY}"
+                    "${GMOCK_MAIN_LIBRARY}"
+            )
+
+            add_dependencies(gmock gtest)
+
+            add_dependencies(GTest::GTest gtest)
+            add_dependencies(GTest::Main gtest)
+            add_dependencies(GMock::GMock gmock)
+            add_dependencies(GMock::Main gmock)
+
+            externalproject_get_property(gtest source_dir)
+            set(GTEST_INCLUDE_DIR "${source_dir}/include")
+            mark_as_advanced(GTEST_INCLUDE_DIR)
+            externalproject_get_property(gmock source_dir)
+            set(GMOCK_INCLUDE_DIR "${source_dir}/include")
+            mark_as_advanced(GMOCK_INCLUDE_DIR)
+        else() #1.8.0
+            set(GMOCK_BIN_DIR "${GMOCK_ROOT}/src/gmock-build")
+            set(GTEST_LIBRARY "${GMOCK_BIN_DIR}/googlemock/gtest/${CMAKE_CFG_INTDIR}/${GTEST_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}")
+            set(GTEST_MAIN_LIBRARY "${GMOCK_BIN_DIR}/googlemock/gtest/${CMAKE_CFG_INTDIR}/${GTEST_LIBRARY_PREFIX}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX}")
+            set(GMOCK_LIBRARY "${GMOCK_BIN_DIR}/googlemock/${CMAKE_CFG_INTDIR}/${GTEST_LIBRARY_PREFIX}gmock${CMAKE_STATIC_LIBRARY_SUFFIX}")
+            set(GMOCK_MAIN_LIBRARY "${GMOCK_BIN_DIR}/googlemock/${CMAKE_CFG_INTDIR}/${GTEST_LIBRARY_PREFIX}gmock_main${CMAKE_STATIC_LIBRARY_SUFFIX}")
+            mark_as_advanced(GTEST_LIBRARY)
+            mark_as_advanced(GTEST_MAIN_LIBRARY)
+            mark_as_advanced(GMOCK_LIBRARY)
+            mark_as_advanced(GMOCK_MAIN_LIBRARY)
+
+            externalproject_add(
+                gmock
+                GIT_REPOSITORY "https://github.com/google/googletest.git"
+                GIT_TAG "release-${GMOCK_VER}"
+                PREFIX ${GMOCK_ROOT}
+                INSTALL_COMMAND ""
+                LOG_DOWNLOAD ON
+                LOG_CONFIGURE ON
+                LOG_BUILD ON
+                CMAKE_ARGS
+                    ${GTEST_CMAKE_ARGS}
+                BINARY_DIR "${GMOCK_BIN_DIR}"
+                BUILD_BYPRODUCTS
+                    "${GTEST_LIBRARY}"
+                    "${GTEST_MAIN_LIBRARY}"
+                    "${GMOCK_LIBRARY}"
+                    "${GMOCK_MAIN_LIBRARY}"
+            )
+
+            add_dependencies(GTest::GTest gmock)
+            add_dependencies(GTest::Main gmock)
+            add_dependencies(GMock::GMock gmock)
+            add_dependencies(GMock::Main gmock)
+
+            externalproject_get_property(gmock source_dir)
+            set(GTEST_INCLUDE_DIR "${source_dir}/googletest/include")
+            set(GMOCK_INCLUDE_DIR "${source_dir}/googlemock/include")
+            mark_as_advanced(GMOCK_INCLUDE_DIR)
+            mark_as_advanced(GTEST_INCLUDE_DIR)
+        endif()
+
+        # Prevent CMake from complaining about these directories missing when the libgtest/libgmock targets get used as dependencies
+        file(MAKE_DIRECTORY ${GTEST_INCLUDE_DIR} ${GMOCK_INCLUDE_DIR})
+    else()
+        message(STATUS "Building Gmock / Gtest from dir ${GMOCK_SRC_DIR}")
+
+        set(GMOCK_BIN_DIR "${GMOCK_ROOT}/src/gmock-build")
+        set(GTEST_LIBRARY "${GMOCK_BIN_DIR}/gtest/${CMAKE_CFG_INTDIR}/${GTEST_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX}")
+        set(GTEST_MAIN_LIBRARY "${GMOCK_BIN_DIR}/gtest/${CMAKE_CFG_INTDIR}/${GTEST_LIBRARY_PREFIX}gtest_main${CMAKE_STATIC_LIBRARY_SUFFIX}")
+        set(GMOCK_LIBRARY "${GMOCK_BIN_DIR}/${CMAKE_CFG_INTDIR}/${GTEST_LIBRARY_PREFIX}gmock${CMAKE_STATIC_LIBRARY_SUFFIX}")
+        set(GMOCK_MAIN_LIBRARY "${GMOCK_BIN_DIR}/${CMAKE_CFG_INTDIR}/${GTEST_LIBRARY_PREFIX}gmock_main${CMAKE_STATIC_LIBRARY_SUFFIX}")
+        mark_as_advanced(GTEST_LIBRARY)
+        mark_as_advanced(GTEST_MAIN_LIBRARY)
+        mark_as_advanced(GMOCK_LIBRARY)
+        mark_as_advanced(GMOCK_MAIN_LIBRARY)
+
+        if(EXISTS "${GMOCK_SRC_DIR}/gtest/include/gtest/gtest.h")
+            set(GTEST_INCLUDE_DIR "${GMOCK_SRC_DIR}/gtest/include")
+            mark_as_advanced(GTEST_INCLUDE_DIR)
+        endif()
+        if(EXISTS "${GMOCK_SRC_DIR}/include/gmock/gmock.h")
+            set(GMOCK_INCLUDE_DIR "${GMOCK_SRC_DIR}/include")
+            mark_as_advanced(GMOCK_INCLUDE_DIR)
*** 310 LINES SKIPPED ***