pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

wip/prusaslicer: Update to 2.3.3 and patch for dependant pkg updates.



Module Name:	pkgsrc-wip
Committed By:	Paul Ripke <stix%stix.id.au@localhost>
Pushed By:	stix
Date:		Tue Aug 17 22:35:40 2021 +1000
Changeset:	84e80d8d8e82ff8e54b99e10f740fb3b0dd5ea9e

Modified Files:
	prusaslicer/Makefile
	prusaslicer/distinfo
	prusaslicer/patches/patch-src_PrusaSlicer.cpp
	prusaslicer/patches/patch-src_libslic3r_Thread.cpp
	prusaslicer/patches/patch-src_slic3r_GUI_Mouse3DController.hpp
Added Files:
	prusaslicer/patches/patch-cmake_modules_FindOpenVDB.cmake
	prusaslicer/patches/patch-cmake_modules_FindTBB.cmake
	prusaslicer/patches/patch-src_libslic3r_Print.cpp
	prusaslicer/patches/patch-src_libslic3r_PrintBase.cpp
	prusaslicer/patches/patch-src_libslic3r_PrintBase.hpp
	prusaslicer/patches/patch-src_libslic3r_PrintObject.cpp
	prusaslicer/patches/patch-src_libslic3r_SLAPrint.cpp
	prusaslicer/patches/patch-src_libslic3r_SLA_Concurrency.hpp
	prusaslicer/patches/patch-src_libslic3r_SLA_SupportTree.cpp
	prusaslicer/patches/patch-src_libslic3r_SupportMaterial.cpp
	prusaslicer/patches/patch-src_libslic3r_pchheader.hpp
	prusaslicer/patches/patch-src_libslic3r_utils.cpp
	prusaslicer/patches/patch-src_slic3r_GUI_BackgroundSlicingProcess.cpp
	prusaslicer/patches/patch-src_slic3r_GUI_BackgroundSlicingProcess.hpp
	prusaslicer/patches/patch-src_slic3r_GUI_InstanceCheck.hpp
	prusaslicer/patches/patch-src_slic3r_GUI_Mouse3DController.cpp
	prusaslicer/patches/patch-src_slic3r_GUI_RemovableDriveManager.cpp
	prusaslicer/patches/patch-src_slic3r_GUI_RemovableDriveManager.hpp

Log Message:
wip/prusaslicer: Update to 2.3.3 and patch for dependant pkg updates.

Fixes for upgrade of tbb to 2021.3.
Fixes for upgrade of openvdb, and split to imath.

PrusaSlicer 2.3.3 is a patch release following PrusaSlicer 2.3.2 release,
fixing an unfortunate bug in handling FDM multi-material project and
configuration files: https://github.com/prusa3d/PrusaSlicer/issues/6711

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=84e80d8d8e82ff8e54b99e10f740fb3b0dd5ea9e

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 prusaslicer/Makefile                               |    5 +-
 prusaslicer/distinfo                               |   32 +-
 .../patches/patch-cmake_modules_FindOpenVDB.cmake  | 1024 ++++++++++++++++++++
 .../patches/patch-cmake_modules_FindTBB.cmake      |  420 ++++++++
 prusaslicer/patches/patch-src_PrusaSlicer.cpp      |   31 +-
 prusaslicer/patches/patch-src_libslic3r_Print.cpp  |   33 +
 .../patches/patch-src_libslic3r_PrintBase.cpp      |   15 +
 .../patches/patch-src_libslic3r_PrintBase.hpp      |  158 +++
 .../patches/patch-src_libslic3r_PrintObject.cpp    |   14 +
 .../patches/patch-src_libslic3r_SLAPrint.cpp       |   51 +
 .../patch-src_libslic3r_SLA_Concurrency.hpp        |   23 +
 .../patch-src_libslic3r_SLA_SupportTree.cpp        |   14 +
 .../patch-src_libslic3r_SupportMaterial.cpp        |   14 +
 prusaslicer/patches/patch-src_libslic3r_Thread.cpp |   60 +-
 .../patches/patch-src_libslic3r_pchheader.hpp      |   19 +
 prusaslicer/patches/patch-src_libslic3r_utils.cpp  |   28 +
 ...tch-src_slic3r_GUI_BackgroundSlicingProcess.cpp |   33 +
 ...tch-src_slic3r_GUI_BackgroundSlicingProcess.hpp |   15 +
 .../patches/patch-src_slic3r_GUI_InstanceCheck.hpp |   14 +
 .../patch-src_slic3r_GUI_Mouse3DController.cpp     |  150 +++
 .../patch-src_slic3r_GUI_Mouse3DController.hpp     |   45 +-
 .../patch-src_slic3r_GUI_RemovableDriveManager.cpp |  109 +++
 .../patch-src_slic3r_GUI_RemovableDriveManager.hpp |   26 +
 23 files changed, 2304 insertions(+), 29 deletions(-)

diffs:
diff --git a/prusaslicer/Makefile b/prusaslicer/Makefile
index 9b825a2594..9340a901ff 100644
--- a/prusaslicer/Makefile
+++ b/prusaslicer/Makefile
@@ -1,7 +1,7 @@
 # $NetBSD$
 
 PKGNAME=	${DISTNAME:tl}
-DISTNAME=	PrusaSlicer-2.3.2
+DISTNAME=	PrusaSlicer-2.3.3
 CATEGORIES=	cad
 MASTER_SITES=	${MASTER_SITE_GITHUB:=prusa3d/}
 GITHUB_PROJECT=	PrusaSlicer
@@ -38,11 +38,10 @@ CMAKE_ARGS+=	-DSLIC3R_WX_STABLE=1
 .include "../../graphics/freetype2/buildlink3.mk"
 .include "../../graphics/glew/buildlink3.mk"
 .include "../../graphics/graphite2/buildlink3.mk"
-# ilmbase was removed on 2021-07-08 with no successor
-#.include "../../graphics/ilmbase/buildlink3.mk"
 .include "../../graphics/png/buildlink3.mk"
 .include "../../math/cgal/buildlink3.mk"
 .include "../../math/eigen3/buildlink3.mk"
+.include "../../math/imath/buildlink3.mk"
 .include "../../parallel/threadingbuildingblocks/buildlink3.mk"
 .include "../../sysutils/dbus/buildlink3.mk"
 .include "../../textproc/expat/buildlink3.mk"
diff --git a/prusaslicer/distinfo b/prusaslicer/distinfo
index 45f8a6464c..905f64b946 100644
--- a/prusaslicer/distinfo
+++ b/prusaslicer/distinfo
@@ -1,16 +1,34 @@
 $NetBSD$
 
-SHA1 (PrusaSlicer-2.3.2.tar.gz) = 0770e6f85cc38a72f1b2c53aae806ebd8a031f94
-RMD160 (PrusaSlicer-2.3.2.tar.gz) = 0fdcc2c63f0965ee9fdc8e9f7c74824d2e52fbe9
-SHA512 (PrusaSlicer-2.3.2.tar.gz) = dc9a0b91ed0cd9c6dba07dbf4634be505a801e35134b39303a3ed9c3f16fecf2ebf6a171b746d953cd1183885cf9b65449ef0d57663613ff8d96f3a04c5705e7
-Size (PrusaSlicer-2.3.2.tar.gz) = 40659637 bytes
+SHA1 (PrusaSlicer-2.3.3.tar.gz) = 2cddfa622ec1214a920536ed54c205e43b1fa989
+RMD160 (PrusaSlicer-2.3.3.tar.gz) = a9a26c6042d65b28dde3f4d6384780fe3a18b76f
+SHA512 (PrusaSlicer-2.3.3.tar.gz) = 1f6b97e135202ad9de8f0bb212239ce2497de4205ea32f860b483473fb1f1783451d539a67cd97ef31f512a797b29c1067a1eff4134ea4a29b6218e5757657e2
+Size (PrusaSlicer-2.3.3.tar.gz) = 40659538 bytes
 SHA1 (patch-CMakeLists.txt) = bea477c9b88165a3debc6a77888aae9ee039aeb3
+SHA1 (patch-cmake_modules_FindOpenVDB.cmake) = 1ea4326710edb5a7638beed9693e99bbaafd0276
+SHA1 (patch-cmake_modules_FindTBB.cmake) = bb2e4fcc30d0f98b082ecbe98c0c2032488e53f8
 SHA1 (patch-src_CMakeLists_txt) = 1ec421e911ef96ae412643216080e1f26e5282c4
-SHA1 (patch-src_PrusaSlicer.cpp) = 5bc384fd938b335598b0327f543d15c1a831c5bf
+SHA1 (patch-src_PrusaSlicer.cpp) = 130cfa729f8daf68a76a3face4934dfa55dcdb80
 SHA1 (patch-src_avrdude_arduino.c) = ff02a4cab1c2d8c82ec7b22c7447ed5ec360ac57
 SHA1 (patch-src_avrdude_libavrdude.h) = 414cf7c6c23f7eed61319f8580c1dd7218ac4337
 SHA1 (patch-src_libslic3r_Platform.cpp) = bc417c037cf26f0c72c34bfd2c44ea7ebd177e9e
 SHA1 (patch-src_libslic3r_Platform.hpp) = 5cb5946e30c8cfad305a6d6ee2efd2718eeadeb3
-SHA1 (patch-src_libslic3r_Thread.cpp) = 6cc8b5ab370d82fdc245e3a666dc0b6f1200a4eb
+SHA1 (patch-src_libslic3r_Print.cpp) = 13c0472088277c79bfaedbe9d74deecf9eae8bad
+SHA1 (patch-src_libslic3r_PrintBase.cpp) = d6f6983933215a0b95e390cef32dcb33d5becd59
+SHA1 (patch-src_libslic3r_PrintBase.hpp) = 0cef36de09752e3f956e1ff8a2d4301b31747e0e
+SHA1 (patch-src_libslic3r_PrintObject.cpp) = 491a8966d3b6b92d9ab8fd6186e61f9743a30463
+SHA1 (patch-src_libslic3r_SLAPrint.cpp) = d1cb835e529e76d9ace89673a6bfabe8051ce899
+SHA1 (patch-src_libslic3r_SLA_Concurrency.hpp) = 455b94ed2d5311d292b3667ebb1756715790c6d5
+SHA1 (patch-src_libslic3r_SLA_SupportTree.cpp) = 4d9929c06f3d23e795b71687d0ac1d4e4823934b
+SHA1 (patch-src_libslic3r_SupportMaterial.cpp) = 57783d96e293993ea9cf264c5ba4061f6c1b881a
+SHA1 (patch-src_libslic3r_Thread.cpp) = fc6b7bc4fb0f1ddc1409e824898ba5259f0da72d
+SHA1 (patch-src_libslic3r_pchheader.hpp) = 5e456ec2607ea13ee51250ba5ca735f6bab03e7f
+SHA1 (patch-src_libslic3r_utils.cpp) = 1ae1daa5146d04c907cd88c2b6618345fc79719f
+SHA1 (patch-src_slic3r_GUI_BackgroundSlicingProcess.cpp) = f7ea43adb2da1d5776e58dd18a8ec041a6eabe5a
+SHA1 (patch-src_slic3r_GUI_BackgroundSlicingProcess.hpp) = cad5e01db6cabea14b332e8e1c14ef1e50e530a9
 SHA1 (patch-src_slic3r_GUI_InstanceCheck.cpp) = c9ae1ec2db2b493578cc128383fa4cf0b3e2ae6a
-SHA1 (patch-src_slic3r_GUI_Mouse3DController.hpp) = 98de31b8d470b850aa2b098fd4e914a86631c668
+SHA1 (patch-src_slic3r_GUI_InstanceCheck.hpp) = e87206bc16155d575cf6b258c52429215c1b2c0c
+SHA1 (patch-src_slic3r_GUI_Mouse3DController.cpp) = 41018efeba4c0d5904df5d5df59db1540183a0fe
+SHA1 (patch-src_slic3r_GUI_Mouse3DController.hpp) = 35393bcbde4bccafb26ab0bc636b95053ff02762
+SHA1 (patch-src_slic3r_GUI_RemovableDriveManager.cpp) = d54f0b7f62623cb745786526c6424ac53e6b6630
+SHA1 (patch-src_slic3r_GUI_RemovableDriveManager.hpp) = a7f2c4745e14f375959afcec68c8d6dec1b514cd
diff --git a/prusaslicer/patches/patch-cmake_modules_FindOpenVDB.cmake b/prusaslicer/patches/patch-cmake_modules_FindOpenVDB.cmake
new file mode 100644
index 0000000000..df2ea5a7f9
--- /dev/null
+++ b/prusaslicer/patches/patch-cmake_modules_FindOpenVDB.cmake
@@ -0,0 +1,1024 @@
+$NetBSD$
+
+cmake file copied from OpenVDB 8.1.0 distribution, with unknown cmake
+function OPENVDB_GET_VERSION_DEFINE commented out.
+
+--- cmake/modules/FindOpenVDB.cmake.orig	2021-07-16 10:14:03.000000000 +0000
++++ cmake/modules/FindOpenVDB.cmake
+@@ -1,28 +1,5 @@
+-# Copyright (c) DreamWorks Animation LLC
+-#
+-# All rights reserved. This software is distributed under the
+-# Mozilla Public License 2.0 ( http://www.mozilla.org/MPL/2.0/ )
+-#
+-# Redistributions of source code must retain the above copyright
+-# and license notice and the following restrictions and disclaimer.
+-#
+-# *     Neither the name of DreamWorks Animation nor the names of
+-# its 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
+-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY 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.
+-# IN NO EVENT SHALL THE COPYRIGHT HOLDERS' AND CONTRIBUTORS' AGGREGATE
+-# LIABILITY FOR ALL CLAIMS REGARDLESS OF THEIR BASIS EXCEED US$250.00.
++# Copyright Contributors to the OpenVDB Project
++# SPDX-License-Identifier: MPL-2.0
+ #
+ #[=======================================================================[.rst:
+ 
+@@ -37,7 +14,10 @@ Use this module by invoking find_package
+     [version] [EXACT]      # Minimum or EXACT version
+     [REQUIRED]             # Fail with error if OpenVDB is not found
+     [COMPONENTS <libs>...] # OpenVDB libraries by their canonical name
+-                           # e.g. "openvdb" for "libopenvdb"
++                           # e.g. "openvdb" for "libopenvdb",
++                           # "pyopenvdb" for the python plugin
++                           # "openvdb_ax" for the OpenVDB AX extension
++                           # "openvdb_houdini" for the houdini plugin
+     )
+ 
+ IMPORTED Targets
+@@ -45,6 +25,14 @@ IMPORTED Targets
+ 
+ ``OpenVDB::openvdb``
+   The core openvdb library target.
++``OpenVDB::openvdb_je``
++  The core openvdb library target with jemalloc.
++``OpenVDB::pyopenvdb``
++  The openvdb python library target.
++``OpenVDB::openvdb_houdini``
++  The openvdb houdini library target.
++``OpenVDB::openvdb_ax``
++  The openvdb_ax library target.
+ 
+ Result Variables
+ ^^^^^^^^^^^^^^^^
+@@ -63,14 +51,16 @@ This will define the following variables
+   OpenVDB library directories.
+ ``OpenVDB_DEFINITIONS``
+   Definitions to use when compiling code that uses OpenVDB.
+-``OpenVDB_{COMPONENT}_FOUND``
++``OpenVDB_${COMPONENT}_FOUND``
+   True if the system has the named OpenVDB component.
+ ``OpenVDB_USES_BLOSC``
+   True if the OpenVDB Library has been built with blosc support
++``OpenVDB_USES_ZLIB``
++  True if the OpenVDB Library has been built with zlib support
+ ``OpenVDB_USES_LOG4CPLUS``
+   True if the OpenVDB Library has been built with log4cplus support
+-``OpenVDB_USES_EXR``
+-  True if the OpenVDB Library has been built with openexr support
++``OpenVDB_USES_IMATH_HALF``
++  True if the OpenVDB Library has been built with Imath half support
+ ``OpenVDB_ABI``
+   Set if this module was able to determine the ABI number the located
+   OpenVDB Library was built against. Unset otherwise.
+@@ -82,7 +72,9 @@ The following cache variables may also b
+ 
+ ``OpenVDB_INCLUDE_DIR``
+   The directory containing ``openvdb/version.h``.
+-``OpenVDB_{COMPONENT}_LIBRARY``
++``OpenVDB_${COMPONENT}_INCLUDE_DIR``
++  Individual component include directories for OpenVDB
++``OpenVDB_${COMPONENT}_LIBRARY``
+   Individual component libraries for OpenVDB
+ 
+ Hints
+@@ -91,34 +83,30 @@ Hints
+ Instead of explicitly setting the cache variables, the following variables
+ may be provided to tell this module where to look.
+ 
+-``OPENVDB_ROOT``
++``OpenVDB_ROOT``
+   Preferred installation prefix.
+ ``OPENVDB_INCLUDEDIR``
+   Preferred include directory e.g. <prefix>/include
+ ``OPENVDB_LIBRARYDIR``
+   Preferred library directory e.g. <prefix>/lib
++``OPENVDB_${COMPONENT}_ROOT``
++  Preferred installation prefix of a specific component.
++``OPENVDB_${COMPONENT}_INCLUDEDIR``
++  Preferred include directory of a specific component e.g. <prefix>/include
++``OPENVDB_${COMPONENT}_LIBRARYDIR``
++  Preferred library directory of a specific component e.g. <prefix>/lib
+ ``SYSTEM_LIBRARY_PATHS``
+-  Paths appended to all include and lib searches.
++  Global list of library paths intended to be searched by and find_xxx call
++``OPENVDB_USE_STATIC_LIBS``
++  Only search for static openvdb libraries
++``DISABLE_CMAKE_SEARCH_PATHS``
++  Disable CMakes default search paths for find_xxx calls in this module
+ 
+ #]=======================================================================]
+ 
+-cmake_minimum_required(VERSION 3.3)
+-# Monitoring <PackageName>_ROOT variables
+-if(POLICY CMP0074)
+-  cmake_policy(SET CMP0074 NEW)
+-endif()
++cmake_minimum_required(VERSION 3.12)
++include(GNUInstallDirs)
+ 
+-if(OpenVDB_FIND_QUIETLY)
+-  set (_quiet "QUIET")
+-else()
+-  set (_quiet "")
+-endif()
+-
+-if(OpenVDB_FIND_REQUIRED)
+-  set (_required "REQUIRED")
+-else()
+-  set (_required "")
+-endif()
+ 
+ # Include utility functions for version information
+ include(${CMAKE_CURRENT_LIST_DIR}/OpenVDBUtils.cmake)
+@@ -128,8 +116,17 @@ mark_as_advanced(
+   OpenVDB_LIBRARY
+ )
+ 
++set(_FIND_OPENVDB_ADDITIONAL_OPTIONS "")
++if(DISABLE_CMAKE_SEARCH_PATHS)
++  set(_FIND_OPENVDB_ADDITIONAL_OPTIONS NO_DEFAULT_PATH)
++endif()
++
+ set(_OPENVDB_COMPONENT_LIST
+   openvdb
++  openvdb_je
++  pyopenvdb
++  openvdb_ax
++  openvdb_houdini
+ )
+ 
+ if(OpenVDB_FIND_COMPONENTS)
+@@ -150,16 +147,65 @@ if(OpenVDB_FIND_COMPONENTS)
+   endif()
+ else()
+   set(OPENVDB_COMPONENTS_PROVIDED FALSE)
+-  set(OpenVDB_FIND_COMPONENTS ${_OPENVDB_COMPONENT_LIST})
++  set(OpenVDB_FIND_COMPONENTS openvdb)
+ endif()
+ 
+-# Append OPENVDB_ROOT or $ENV{OPENVDB_ROOT} if set (prioritize the direct cmake var)
+-set(_OPENVDB_ROOT_SEARCH_DIR "")
++# always make sure openvdb is picked up as a component i.e.
++# find_package(OpenVDB COMPONENTS pyopenvdb) results in both
++# openvdb and pyopenvdb targets. Also make sure it appears
++# first in the component lists.
++list(INSERT OpenVDB_FIND_COMPONENTS 0 openvdb)
++list(REMOVE_DUPLICATES OpenVDB_FIND_COMPONENTS)
++
++# Set _OPENVDB_ROOT based on a user provided root var. Xxx_ROOT and ENV{Xxx_ROOT}
++# are prioritised over the legacy capitalized XXX_ROOT variables for matching
++# CMake 3.12 behaviour
++# @todo  deprecate -D and ENV OPENVDB_ROOT from CMake 3.12
++if(OpenVDB_ROOT)
++  set(_OPENVDB_ROOT ${OpenVDB_ROOT})
++elseif(DEFINED ENV{OpenVDB_ROOT})
++  set(_OPENVDB_ROOT $ENV{OpenVDB_ROOT})
++elseif(OPENVDB_ROOT)
++  set(_OPENVDB_ROOT ${OPENVDB_ROOT})
++elseif(DEFINED ENV{OPENVDB_ROOT})
++  set(_OPENVDB_ROOT $ENV{OPENVDB_ROOT})
++endif()
+ 
+ # Additionally try and use pkconfig to find OpenVDB
++if(USE_PKGCONFIG)
++  if(NOT DEFINED PKG_CONFIG_FOUND)
++    find_package(PkgConfig)
++  endif()
++  pkg_check_modules(PC_OpenVDB QUIET OpenVDB)
++endif()
++
++# This CMake module supports being called from external packages AND from
++# within the OpenVDB repository for building openvdb components with the
++# core library build disabled. Determine where we are being called from:
++#
++# (repo structure = <root>/cmake/FindOpenVDB.cmake)
++# (inst structure = <root>/lib/cmake/OpenVDB/FindOpenVDB.cmake)
++
++get_filename_component(_DIR_NAME ${CMAKE_CURRENT_LIST_DIR} NAME)
+ 
+-find_package(PkgConfig ${_quiet} )
+-pkg_check_modules(PC_OpenVDB QUIET OpenVDB)
++if(${_DIR_NAME} STREQUAL "cmake")
++  # Called from root repo for openvdb components
++elseif(${_DIR_NAME} STREQUAL "OpenVDB")
++  # Set the install variable to track directories if this is being called from
++  # an installed location and from another package. The expected installation
++  # directory structure is:
++  #  <root>/lib/cmake/OpenVDB/FindOpenVDB.cmake
++  #  <root>/include
++  #  <root>/bin
++  get_filename_component(_IMPORT_PREFIX ${CMAKE_CURRENT_LIST_DIR} DIRECTORY)
++  get_filename_component(_IMPORT_PREFIX ${_IMPORT_PREFIX} DIRECTORY)
++  get_filename_component(_IMPORT_PREFIX ${_IMPORT_PREFIX} DIRECTORY)
++  set(_OPENVDB_INSTALL ${_IMPORT_PREFIX})
++  list(APPEND _OPENVDB_ROOT ${_OPENVDB_INSTALL})
++endif()
++
++unset(_DIR_NAME)
++unset(_IMPORT_PREFIX)
+ 
+ # ------------------------------------------------------------------------
+ #  Search for OpenVDB include DIR
+@@ -168,24 +214,89 @@ pkg_check_modules(PC_OpenVDB QUIET OpenV
+ set(_OPENVDB_INCLUDE_SEARCH_DIRS "")
+ list(APPEND _OPENVDB_INCLUDE_SEARCH_DIRS
+   ${OPENVDB_INCLUDEDIR}
+-  ${_OPENVDB_ROOT_SEARCH_DIR}
++  ${_OPENVDB_ROOT}
+   ${PC_OpenVDB_INCLUDE_DIRS}
+   ${SYSTEM_LIBRARY_PATHS}
+ )
+ 
+-# Look for a standard OpenVDB header file.
+-find_path(OpenVDB_INCLUDE_DIR openvdb/version.h
+-  PATHS ${_OPENVDB_INCLUDE_SEARCH_DIRS}
+-  PATH_SUFFIXES include
+-)
++foreach(COMPONENT ${OpenVDB_FIND_COMPONENTS})
++  # Add in extra component paths
++  set(_VDB_COMPONENT_SEARCH_DIRS ${_OPENVDB_INCLUDE_SEARCH_DIRS})
++  list(APPEND _VDB_COMPONENT_SEARCH_DIRS
++    ${OPENVDB_${COMPONENT}_ROOT}
++    ${OPENVDB_${COMPONENT}_INCLUDEDIR}
++  )
++  if(_VDB_COMPONENT_SEARCH_DIRS)
++    list(REMOVE_DUPLICATES _VDB_COMPONENT_SEARCH_DIRS)
++  endif()
++
++  # Look for a standard header files.
++  if(${COMPONENT} STREQUAL "openvdb")
++    # Look for a standard OpenVDB header file.
++    find_path(OpenVDB_${COMPONENT}_INCLUDE_DIR openvdb/version.h
++      ${_FIND_OPENVDB_ADDITIONAL_OPTIONS}
++      PATHS ${_VDB_COMPONENT_SEARCH_DIRS}
++      PATH_SUFFIXES
++        ${CMAKE_INSTALL_INCLUDEDIR}
++        include
++    )
++  elseif(${COMPONENT} STREQUAL "pyopenvdb")
++    find_path(OpenVDB_${COMPONENT}_INCLUDE_DIR pyopenvdb.h
++      ${_FIND_OPENVDB_ADDITIONAL_OPTIONS}
++      PATHS ${_VDB_COMPONENT_SEARCH_DIRS}
++      PATH_SUFFIXES
++        ${CMAKE_INSTALL_INCLUDEDIR}/openvdb/python
++        ${CMAKE_INSTALL_INCLUDEDIR}/openvdb
++        ${CMAKE_INSTALL_INCLUDEDIR}
++        include
++    )
++  elseif(${COMPONENT} STREQUAL "openvdb_ax")
++    # Look for a standard OpenVDB header file.
++    find_path(OpenVDB_${COMPONENT}_INCLUDE_DIR compiler/Compiler.h
++      ${_FIND_OPENVDB_ADDITIONAL_OPTIONS}
++      PATHS ${_VDB_COMPONENT_SEARCH_DIRS}
++      PATH_SUFFIXES
++        ${CMAKE_INSTALL_INCLUDEDIR}/openvdb/openvdb_ax
++        ${CMAKE_INSTALL_INCLUDEDIR}/openvdb_ax
++        ${CMAKE_INSTALL_INCLUDEDIR}
++        include
++    )
++  elseif(${COMPONENT} STREQUAL "openvdb_houdini")
++    # @note  Expects both houdini_utils and openvdb_houdini folders
++    #   to be located in the same place
++    find_path(OpenVDB_${COMPONENT}_INCLUDE_DIR openvdb_houdini/SOP_NodeVDB.h
++      ${_FIND_OPENVDB_ADDITIONAL_OPTIONS}
++      PATHS ${_VDB_COMPONENT_SEARCH_DIRS}
++      PATH_SUFFIXES
++        ${CMAKE_INSTALL_INCLUDEDIR}/openvdb
++        ${CMAKE_INSTALL_INCLUDEDIR}
++        include
++    )
++  endif()
++  unset(_VDB_COMPONENT_SEARCH_DIRS)
++endforeach()
+ 
+-OPENVDB_VERSION_FROM_HEADER("${OpenVDB_INCLUDE_DIR}/openvdb/version.h"
++set(OpenVDB_INCLUDE_DIR ${OpenVDB_openvdb_INCLUDE_DIR}
++  CACHE PATH "The OpenVDB core include directory")
++
++set(_OPENVDB_VERSION_HEADER "${OpenVDB_INCLUDE_DIR}/openvdb/version.h")
++OPENVDB_VERSION_FROM_HEADER("${_OPENVDB_VERSION_HEADER}"
+   VERSION OpenVDB_VERSION
+   MAJOR   OpenVDB_MAJOR_VERSION
+   MINOR   OpenVDB_MINOR_VERSION
+   PATCH   OpenVDB_PATCH_VERSION
++  ABI     OpenVDB_ABI_FROM_HEADER # will be OpenVDB_MAJOR_VERSION prior to 8.1.0
+ )
+ 
++if(OpenVDB_VERSION VERSION_LESS 8.1.0)
++  set(_OPENVDB_HAS_NEW_VERSION_HEADER FALSE)
++  # ABI gets computed later
++else()
++  set(_OPENVDB_HAS_NEW_VERSION_HEADER TRUE)
++  set(OpenVDB_ABI ${OpenVDB_ABI_FROM_HEADER})
++endif()
++unset(OpenVDB_ABI_FROM_HEADER)
++
+ # ------------------------------------------------------------------------
+ #  Search for OPENVDB lib DIR
+ # ------------------------------------------------------------------------
+@@ -196,81 +307,95 @@ set(_OPENVDB_LIBRARYDIR_SEARCH_DIRS "")
+ 
+ list(APPEND _OPENVDB_LIBRARYDIR_SEARCH_DIRS
+   ${OPENVDB_LIBRARYDIR}
+-  ${_OPENVDB_ROOT_SEARCH_DIR}
++  ${_OPENVDB_ROOT}
+   ${PC_OpenVDB_LIBRARY_DIRS}
+   ${SYSTEM_LIBRARY_PATHS}
+ )
+ 
+-# Build suffix directories
++# Library suffix handling
++
++set(_OPENVDB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
+ 
+-set(OPENVDB_PATH_SUFFIXES
++set(OPENVDB_PYTHON_PATH_SUFFIXES
++  ${CMAKE_INSTALL_LIBDIR}/python
++  ${CMAKE_INSTALL_LIBDIR}/python2.7
++  ${CMAKE_INSTALL_LIBDIR}/python3
++  lib64/python
++  lib64/python2.7
++  lib64/python3
++  lib/python
++  lib/python2.7
++  lib/python3
++)
++
++set(OPENVDB_LIB_PATH_SUFFIXES
++  ${CMAKE_INSTALL_LIBDIR}
+   lib64
+   lib
+ )
+ 
++list(REMOVE_DUPLICATES OPENVDB_PYTHON_PATH_SUFFIXES)
++list(REMOVE_DUPLICATES OPENVDB_LIB_PATH_SUFFIXES)
++
+ # Static library setup
+-if(UNIX AND OPENVDB_USE_STATIC_LIBS)
+-  set(_OPENVDB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
+-  set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
++if(WIN32)
++  if(OPENVDB_USE_STATIC_LIBS)
++    set(CMAKE_FIND_LIBRARY_SUFFIXES ".lib")
++  endif()
++else()
++  if(OPENVDB_USE_STATIC_LIBS)
++    set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
++  endif()
+ endif()
+ 
+ set(OpenVDB_LIB_COMPONENTS "")
+-set(OpenVDB_DEBUG_SUFFIX "d" CACHE STRING "Suffix for the debug libraries")
+-
+-get_property(_is_multi GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
+ 
+ foreach(COMPONENT ${OpenVDB_FIND_COMPONENTS})
+   set(LIB_NAME ${COMPONENT})
+ 
+-  find_library(OpenVDB_${COMPONENT}_LIBRARY_RELEASE ${LIB_NAME} lib${LIB_NAME}
+-    PATHS ${_OPENVDB_LIBRARYDIR_SEARCH_DIRS}
+-    PATH_SUFFIXES ${OPENVDB_PATH_SUFFIXES}
+-  )
+-
+-  find_library(OpenVDB_${COMPONENT}_LIBRARY_DEBUG ${LIB_NAME}${OpenVDB_DEBUG_SUFFIX} lib${LIB_NAME}${OpenVDB_DEBUG_SUFFIX}
+-    PATHS ${_OPENVDB_LIBRARYDIR_SEARCH_DIRS}
+-    PATH_SUFFIXES ${OPENVDB_PATH_SUFFIXES}
++  # Add in extra component paths
++  set(_VDB_COMPONENT_SEARCH_DIRS ${_OPENVDB_LIBRARYDIR_SEARCH_DIRS})
++  list(APPEND _VDB_COMPONENT_SEARCH_DIRS
++    ${OPENVDB_${COMPONENT}_ROOT}
++    ${OPENVDB_${COMPONENT}_LIBRARYDIR}
+   )
+ 
+-  if (_is_multi)
+-    list(APPEND OpenVDB_LIB_COMPONENTS ${OpenVDB_${COMPONENT}_LIBRARY_RELEASE})
+-    if (OpenVDB_${COMPONENT}_LIBRARY_DEBUG)
+-      list(APPEND OpenVDB_LIB_COMPONENTS ${OpenVDB_${COMPONENT}_LIBRARY_DEBUG})
+-    endif ()
+-
+-    list(FIND CMAKE_CONFIGURATION_TYPES "Debug" _has_debug)
+-    
+-    if(OpenVDB_${COMPONENT}_LIBRARY_RELEASE AND (NOT MSVC OR _has_debug LESS 0 OR OpenVDB_${COMPONENT}_LIBRARY_DEBUG))
+-      set(OpenVDB_${COMPONENT}_FOUND TRUE)
+-    else()
+-      set(OpenVDB_${COMPONENT}_FOUND FALSE)
+-    endif()
+-
+-    set(OpenVDB_${COMPONENT}_LIBRARY ${OpenVDB_${COMPONENT}_LIBRARY_RELEASE})
+-  else ()
+-    string(TOUPPER "${CMAKE_BUILD_TYPE}" _BUILD_TYPE)
+-
+-    set(OpenVDB_${COMPONENT}_LIBRARY ${OpenVDB_${COMPONENT}_LIBRARY_${_BUILD_TYPE}})
+-
+-    if (NOT OpenVDB_${COMPONENT}_LIBRARY)
+-      set(OpenVDB_${COMPONENT}_LIBRARY ${OpenVDB_${COMPONENT}_LIBRARY_RELEASE})
+-    endif ()
++  if(${COMPONENT} STREQUAL "pyopenvdb")
++    set(_OPENVDB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES ${CMAKE_FIND_LIBRARY_PREFIXES})
++    set(CMAKE_FIND_LIBRARY_PREFIXES ";lib") # find non-prefixed
++    find_library(OpenVDB_${COMPONENT}_LIBRARY ${LIB_NAME}
++      ${_FIND_OPENVDB_ADDITIONAL_OPTIONS}
++      PATHS ${_VDB_COMPONENT_SEARCH_DIRS}
++      PATH_SUFFIXES ${OPENVDB_PYTHON_PATH_SUFFIXES}
++    )
++    set(CMAKE_FIND_LIBRARY_PREFIXES ${_OPENVDB_ORIG_CMAKE_FIND_LIBRARY_PREFIXES})
++  elseif(${COMPONENT} STREQUAL "openvdb_je")
++    # alias to the result of openvdb which should be handled first
++    set(OpenVDB_${COMPONENT}_LIBRARY ${OpenVDB_openvdb_LIBRARY})
++  else()
++    find_library(OpenVDB_${COMPONENT}_LIBRARY ${LIB_NAME}
++      ${_FIND_OPENVDB_ADDITIONAL_OPTIONS}
++      PATHS ${_VDB_COMPONENT_SEARCH_DIRS}
++      PATH_SUFFIXES ${OPENVDB_LIB_PATH_SUFFIXES}
++    )
++  endif()
+ 
+-    list(APPEND OpenVDB_LIB_COMPONENTS ${OpenVDB_${COMPONENT}_LIBRARY})
++  list(APPEND OpenVDB_LIB_COMPONENTS ${OpenVDB_${COMPONENT}_LIBRARY})
++  if(OpenVDB_${COMPONENT}_LIBRARY)
++    set(OpenVDB_${COMPONENT}_FOUND TRUE)
++  else()
++    set(OpenVDB_${COMPONENT}_FOUND FALSE)
++  endif()
++  unset(_VDB_COMPONENT_SEARCH_DIRS)
++endforeach()
+ 
+-    if(OpenVDB_${COMPONENT}_LIBRARY)
+-      set(OpenVDB_${COMPONENT}_FOUND TRUE)
+-    else()
+-      set(OpenVDB_${COMPONENT}_FOUND FALSE)
+-    endif()
+-  endif ()
++unset(OPENVDB_PYTHON_PATH_SUFFIXES)
++unset(OPENVDB_LIB_PATH_SUFFIXES)
+ 
+-endforeach()
++# Reset library suffix
+ 
+-if(UNIX AND OPENVDB_USE_STATIC_LIBS)
+-  set(CMAKE_FIND_LIBRARY_SUFFIXES ${_OPENVDB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
+-  unset(_OPENVDB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES)
+-endif()
++set(CMAKE_FIND_LIBRARY_SUFFIXES ${_OPENVDB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
++unset(_OPENVDB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES)
+ 
+ # ------------------------------------------------------------------------
+ #  Cache and set OPENVDB_FOUND
+@@ -290,15 +415,25 @@ find_package_handle_standard_args(OpenVD
+ #  Determine ABI number
+ # ------------------------------------------------------------------------
+ 
+-# Set the ABI number the library was built against. Uses vdb_print
+-find_program(OPENVDB_PRINT vdb_print PATHS ${OpenVDB_INCLUDE_DIR} )
++# Set the ABI number the library was built against. The old system,
++# which didn't define the ABI in the build config, uses vdb_print
+ 
+-OPENVDB_ABI_VERSION_FROM_PRINT(
+-  "${OPENVDB_PRINT}"
+-  ABI OpenVDB_ABI
+-)
++if(NOT _OPENVDB_HAS_NEW_VERSION_HEADER)
++  if(_OPENVDB_INSTALL)
++    OPENVDB_ABI_VERSION_FROM_PRINT(
++      "${_OPENVDB_INSTALL}/bin/vdb_print"
++      ABI OpenVDB_ABI
++    )
++  else()
++    # Try and find vdb_print from the include path
++    OPENVDB_ABI_VERSION_FROM_PRINT(
++      "${OpenVDB_INCLUDE_DIR}/../bin/vdb_print"
++      ABI OpenVDB_ABI
++    )
++  endif()
++endif()
+ 
+-if(NOT OpenVDB_FIND_QUIETLY)
++if(NOT OpenVDB_FIND_QUIET)
+   if(NOT OpenVDB_ABI)
+     message(WARNING "Unable to determine OpenVDB ABI version from OpenVDB "
+       "installation. The library major version \"${OpenVDB_MAJOR_VERSION}\" "
+@@ -311,166 +446,209 @@ if(NOT OpenVDB_FIND_QUIETLY)
+ endif()
+ 
+ # ------------------------------------------------------------------------
+-#  Handle OpenVDB dependencies
++#  Handle OpenVDB dependencies and interface settings
+ # ------------------------------------------------------------------------
+ 
++# Handle openvdb_houdini first to configure search paths
++
++if(openvdb_houdini IN_LIST OpenVDB_FIND_COMPONENTS)
++  include(OpenVDBHoudiniSetup)
++endif()
++
+ # Add standard dependencies
+ 
+-macro(just_fail msg)
+-  set(OpenVDB_FOUND FALSE)
+-  if(OpenVDB_FIND_REQUIRED)
+-    message(FATAL_ERROR ${msg})
+-  elseif(NOT OpenVDB_FIND_QUIETLY)
+-    message(WARNING ${msg})
+-  endif()
+-  return()
+-endmacro()
+-
+-find_package(IlmBase QUIET COMPONENTS Half)
+-if(NOT IlmBase_FOUND)
+-  pkg_check_modules(IlmBase QUIET IlmBase)
+-endif()
+-if (IlmBase_FOUND AND NOT TARGET IlmBase::Half)
+-  message(STATUS "Falling back to IlmBase found by pkg-config...")
+-
+-  find_library(IlmHalf_LIBRARY NAMES Half)
+-  if(IlmHalf_LIBRARY-NOTFOUND OR NOT IlmBase_INCLUDE_DIRS)
+-    just_fail("IlmBase::Half can not be found!")
+-  endif()
+-  
+-  add_library(IlmBase::Half UNKNOWN IMPORTED)
+-  set_target_properties(IlmBase::Half PROPERTIES
+-    IMPORTED_LOCATION "${IlmHalf_LIBRARY}"
+-    INTERFACE_INCLUDE_DIRECTORIES "${IlmBase_INCLUDE_DIRS}")
+-elseif(NOT IlmBase_FOUND)
+-  just_fail("IlmBase::Half can not be found!")
+-endif()
+-find_package(TBB ${_quiet} ${_required} COMPONENTS tbb)
+-find_package(ZLIB ${_quiet} ${_required})
+-find_package(Boost ${_quiet} ${_required} COMPONENTS iostreams system )
+-
+-# Use GetPrerequisites to see which libraries this OpenVDB lib has linked to
+-# which we can query for optional deps. This basically runs ldd/otoll/objdump
+-# etc to track deps. We could use a vdb_config binary tools here to improve
+-# this process
+-
+-include(GetPrerequisites)
+-
+-set(_EXCLUDE_SYSTEM_PREREQUISITES 1)
+-set(_RECURSE_PREREQUISITES 0)
+-set(_OPENVDB_PREREQUISITE_LIST)
++find_package(TBB REQUIRED COMPONENTS tbb)
+ 
+-if(NOT OPENVDB_USE_STATIC_LIBS)
+-get_prerequisites(${OpenVDB_openvdb_LIBRARY}
+-  _OPENVDB_PREREQUISITE_LIST
+-  ${_EXCLUDE_SYSTEM_PREREQUISITES}
+-  ${_RECURSE_PREREQUISITES}
+-  ""
+-  "${SYSTEM_LIBRARY_PATHS}"
+-)
++if(NOT OPENVDB_USE_STATIC_LIBS AND NOT Boost_USE_STATIC_LIBS)
++  # @note  Both of these must be set for Boost 1.70 (VFX2020) to link against
++  #        boost shared libraries (more specifically libraries built with -fPIC).
++  #        http://boost.2283326.n4.nabble.com/CMake-config-scripts-broken-in-1-70-td4708957.html
++  #        https://github.com/boostorg/boost_install/commit/160c7cb2b2c720e74463865ef0454d4c4cd9ae7c
++  set(BUILD_SHARED_LIBS ON)
++  set(Boost_USE_STATIC_LIBS OFF)
++endif()
++
++find_package(Boost REQUIRED COMPONENTS iostreams system)
++
++# Add deps for pyopenvdb
++# @todo track for numpy
++
++if(pyopenvdb IN_LIST OpenVDB_FIND_COMPONENTS)
++  find_package(PythonLibs REQUIRED)
++
++  # Boost python handling - try and find both python and pythonXx (version suffixed).
++  # Prioritize the version suffixed library, failing if neither exist.
++
++  find_package(Boost ${MINIMUM_BOOST_VERSION}
++    QUIET COMPONENTS python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}
++  )
++
++  if(TARGET Boost::python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR})
++    set(BOOST_PYTHON_LIB "python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
++    message(STATUS "Found boost_python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}")
++  else()
++    find_package(Boost ${MINIMUM_BOOST_VERSION} QUIET COMPONENTS python)
++    if(TARGET Boost::python)
++      set(BOOST_PYTHON_LIB "python")
++      message(STATUS "Found non-suffixed boost_python, assuming to be python version "
++        "\"${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}\" compatible"
++      )
++    else()
++      message(FATAL_ERROR "Unable to find boost_python or "
++        "boost_python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}."
++      )
++    endif()
++  endif()
+ endif()
+ 
+-unset(_EXCLUDE_SYSTEM_PREREQUISITES)
+-unset(_RECURSE_PREREQUISITES)
++# Add deps for openvdb_ax
++
++if(openvdb_ax IN_LIST OpenVDB_FIND_COMPONENTS)
++  find_package(LLVM REQUIRED)
++  find_library(found_LLVM LLVM HINTS ${LLVM_LIBRARY_DIRS})
++
++  if(found_LLVM)
++    set(LLVM_LIBS "LLVM")
++  else()
++    llvm_map_components_to_libnames(_llvm_libs
++      native core executionengine support mcjit passes objcarcopts)
++    set(LLVM_LIBS "${_llvm_libs}")
++  endif()
++
++  if(NOT OpenVDB_FIND_QUIET)
++    message(STATUS "Found LLVM: ${LLVM_DIR} (found version \"${LLVM_PACKAGE_VERSION}\")")
++  endif()
++endif()
+ 
+ # As the way we resolve optional libraries relies on library file names, use
+ # the configuration options from the main CMakeLists.txt to allow users
+ # to manually identify the requirements of OpenVDB builds if they know them.
+-
+ set(OpenVDB_USES_BLOSC ${USE_BLOSC})
++set(OpenVDB_USES_ZLIB ${USE_ZLIB})
+ set(OpenVDB_USES_LOG4CPLUS ${USE_LOG4CPLUS})
+-set(OpenVDB_USES_ILM ${USE_EXR})
+-set(OpenVDB_USES_EXR ${USE_EXR})
++set(OpenVDB_USES_IMATH_HALF ${USE_IMATH_HALF})
++set(OpenVDB_DEFINITIONS)
+ 
+-# Search for optional dependencies
++if(WIN32)
++  if(OPENVDB_USE_STATIC_LIBS)
++    list(APPEND OpenVDB_DEFINITIONS OPENVDB_STATICLIB)
++  else()
++    list(APPEND OpenVDB_DEFINITIONS OPENVDB_DLL)
++  endif()
++  # Newer version of OpenVDB define these in Platform.h, but they are also
++  # provided here to maintain backwards compatibility with header include
++  # others
++  list(APPEND OpenVDB_DEFINITIONS _WIN32)
++  list(APPEND OpenVDB_DEFINITIONS NOMINMAX)
++endif()
+ 
+-foreach(PREREQUISITE ${_OPENVDB_PREREQUISITE_LIST})
+-  set(_HAS_DEP)
+-  get_filename_component(PREREQUISITE ${PREREQUISITE} NAME)
++if(OpenVDB_ABI)
++  # Newer version of OpenVDB defines this in version.h, but it is are also
++  # provided here to maintain backwards compatibility with header include
++  # others
++  list(APPEND OpenVDB_DEFINITIONS OPENVDB_ABI_VERSION_NUMBER=${OpenVDB_ABI})
++endif()
++
++# Configure deps
++
++if(_OPENVDB_HAS_NEW_VERSION_HEADER)
++  # OPENVDB_GET_VERSION_DEFINE(${_OPENVDB_VERSION_HEADER} "OPENVDB_USE_IMATH_HALF" OpenVDB_USES_IMATH_HALF)
++  # OPENVDB_GET_VERSION_DEFINE(${_OPENVDB_VERSION_HEADER} "OPENVDB_USE_BLOSC" OpenVDB_USES_BLOSC)
++  # OPENVDB_GET_VERSION_DEFINE(${_OPENVDB_VERSION_HEADER} "OPENVDB_USE_ZLIB" OpenVDB_USES_ZLIB)
++elseif(NOT OPENVDB_USE_STATIC_LIBS)
++  # Use GetPrerequisites to see which libraries this OpenVDB lib has linked to
++  # which we can query for optional deps. This basically runs ldd/otoll/objdump
++  # etc to track deps. We could use a vdb_config binary tools here to improve
++  # this process
++  include(GetPrerequisites)
++
++  set(_EXCLUDE_SYSTEM_PREREQUISITES 1)
++  set(_RECURSE_PREREQUISITES 0)
++  set(_OPENVDB_PREREQUISITE_LIST)
++
++  get_prerequisites(${OpenVDB_openvdb_LIBRARY}
++    _OPENVDB_PREREQUISITE_LIST
++    ${_EXCLUDE_SYSTEM_PREREQUISITES}
++    ${_RECURSE_PREREQUISITES}
++    ""
++    "${SYSTEM_LIBRARY_PATHS}"
++  )
+ 
+-  string(FIND ${PREREQUISITE} "blosc" _HAS_DEP)
+-  if(NOT ${_HAS_DEP} EQUAL -1)
+-    set(OpenVDB_USES_BLOSC ON)
+-  endif()
++  unset(_EXCLUDE_SYSTEM_PREREQUISITES)
++  unset(_RECURSE_PREREQUISITES)
+ 
+-  string(FIND ${PREREQUISITE} "log4cplus" _HAS_DEP)
+-  if(NOT ${_HAS_DEP} EQUAL -1)
+-    set(OpenVDB_USES_LOG4CPLUS ON)
+-  endif()
++  # Search for optional dependencies
++  foreach(PREREQUISITE ${_OPENVDB_PREREQUISITE_LIST})
++    set(_HAS_DEP)
++    get_filename_component(PREREQUISITE ${PREREQUISITE} NAME)
++
++    string(FIND ${PREREQUISITE} "blosc" _HAS_DEP)
++    if(NOT ${_HAS_DEP} EQUAL -1)
++      set(OpenVDB_USES_BLOSC ON)
++    endif()
+ 
+-  string(FIND ${PREREQUISITE} "IlmImf" _HAS_DEP)
+-  if(NOT ${_HAS_DEP} EQUAL -1)
+-    set(OpenVDB_USES_ILM ON)
+-  endif()
+-endforeach()
++    string(FIND ${PREREQUISITE} "zlib" _HAS_DEP)
++    if(NOT ${_HAS_DEP} EQUAL -1)
++      set(OpenVDB_USES_ZLIB ON)
++    endif()
+ 
+-unset(_OPENVDB_PREREQUISITE_LIST)
+-unset(_HAS_DEP)
++    string(FIND ${PREREQUISITE} "log4cplus" _HAS_DEP)
++    if(NOT ${_HAS_DEP} EQUAL -1)
++      set(OpenVDB_USES_LOG4CPLUS ON)
++    endif()
+ 
+-if(OpenVDB_USES_BLOSC)
+-  find_package(Blosc QUIET)
+-  if(NOT Blosc_FOUND OR NOT TARGET Blosc::blosc) 
+-    message(STATUS "find_package could not find Blosc. Using fallback blosc search...")
+-    find_path(Blosc_INCLUDE_DIR blosc.h)
+-    find_library(Blosc_LIBRARY NAMES blosc)
+-    if (Blosc_INCLUDE_DIR AND Blosc_LIBRARY)
+-      set(Blosc_FOUND TRUE)
+-      add_library(Blosc::blosc UNKNOWN IMPORTED)
+-      set_target_properties(Blosc::blosc PROPERTIES 
+-        IMPORTED_LOCATION "${Blosc_LIBRARY}"
+-        INTERFACE_INCLUDE_DIRECTORIES ${Blosc_INCLUDE_DIR})
+-    elseif()
+-      just_fail("Blosc library can not be found!")
++    string(FIND ${PREREQUISITE} "Half" _HAS_DEP)
++    if(NOT ${_HAS_DEP} EQUAL -1)
++      set(OpenVDB_USES_IMATH_HALF ON)
+     endif()
+-  endif()
++  endforeach()
++
++  unset(_OPENVDB_PREREQUISITE_LIST)
+ endif()
+ 
+-if(OpenVDB_USES_LOG4CPLUS)
+-  find_package(Log4cplus ${_quiet} ${_required})
++if(OpenVDB_USES_BLOSC)
++  find_package(Blosc REQUIRED)
+ endif()
+ 
+-if(OpenVDB_USES_ILM)
+-  find_package(IlmBase ${_quiet} ${_required})
++if(OpenVDB_USES_ZLIB)
++  find_package(ZLIB REQUIRED)
++endif()
++
++if(OpenVDB_USES_LOG4CPLUS)
++  find_package(Log4cplus REQUIRED)
+ endif()
+ 
+-if(OpenVDB_USES_EXR)
+-  find_package(OpenEXR ${_quiet} ${_required})
++if(OpenVDB_USES_IMATH_HALF)
++  find_package(IlmBase REQUIRED COMPONENTS Half)
++  if(WIN32)
++    # @note OPENVDB_OPENEXR_STATICLIB is old functionality and should be removed
++    if(OPENEXR_USE_STATIC_LIBS OR (${ILMBASE_LIB_TYPE} STREQUAL STATIC_LIBRARY))
++      list(APPEND OpenVDB_DEFINITIONS OPENVDB_OPENEXR_STATICLIB)
++    endif()
++  endif()
+ endif()
+ 
+ if(UNIX)
+-  find_package(Threads ${_quiet} ${_required})
++  find_package(Threads REQUIRED)
+ endif()
+ 
+ # Set deps. Note that the order here is important. If we're building against
+-# Houdini 17.5 we must include OpenEXR and IlmBase deps first to ensure the
+-# users chosen namespaced headers are correctly prioritized. Otherwise other
+-# include paths from shared installs (including houdini) may pull in the wrong
+-# headers
++# Houdini 17.5 we must include IlmBase deps first to ensure the users chosen
++# namespaced headers are correctly prioritized. Otherwise other include paths
++# from shared installs (including houdini) may pull in the wrong headers
+ 
+ set(_OPENVDB_VISIBLE_DEPENDENCIES
+   Boost::iostreams
+   Boost::system
+-  IlmBase::Half
+ )
+ 
+-set(_OPENVDB_DEFINITIONS)
+-if(OpenVDB_ABI)
+-  list(APPEND _OPENVDB_DEFINITIONS "-DOPENVDB_ABI_VERSION_NUMBER=${OpenVDB_ABI}")
+-endif()
+-
+-if(OpenVDB_USES_EXR)
+-  list(APPEND _OPENVDB_VISIBLE_DEPENDENCIES
+-    IlmBase::IlmThread
+-    IlmBase::Iex
+-    IlmBase::Imath
+-    OpenEXR::IlmImf
+-  )
+-  list(APPEND _OPENVDB_DEFINITIONS "-DOPENVDB_TOOLS_RAYTRACER_USE_EXR")
++if(OpenVDB_USES_IMATH_HALF)
++  list(APPEND _OPENVDB_VISIBLE_DEPENDENCIES IlmBase::Half)
+ endif()
+ 
+ if(OpenVDB_USES_LOG4CPLUS)
+   list(APPEND _OPENVDB_VISIBLE_DEPENDENCIES Log4cplus::log4cplus)
+-  list(APPEND _OPENVDB_DEFINITIONS "-DOPENVDB_USE_LOG4CPLUS")
++  list(APPEND OpenVDB_DEFINITIONS OPENVDB_USE_LOG4CPLUS)
+ endif()
+ 
+ list(APPEND _OPENVDB_VISIBLE_DEPENDENCIES
+@@ -484,34 +662,26 @@ endif()
+ 
+ set(_OPENVDB_HIDDEN_DEPENDENCIES)
+ 
+-if(OpenVDB_USES_BLOSC)
+-  if(OPENVDB_USE_STATIC_LIBS)
+-    list(APPEND _OPENVDB_VISIBLE_DEPENDENCIES $<LINK_ONLY:Blosc::blosc>)
+-  else()
++if(NOT OPENVDB_USE_STATIC_LIBS)
++  if(OpenVDB_USES_BLOSC)
+     list(APPEND _OPENVDB_HIDDEN_DEPENDENCIES Blosc::blosc)
+   endif()
++  if(OpenVDB_USES_ZLIB)
++    list(APPEND _OPENVDB_HIDDEN_DEPENDENCIES ZLIB::ZLIB)
++  endif()
+ endif()
+ 
+-if(OPENVDB_USE_STATIC_LIBS)
+-  list(APPEND _OPENVDB_VISIBLE_DEPENDENCIES $<LINK_ONLY:ZLIB::ZLIB>)
+-else()
+-  list(APPEND _OPENVDB_HIDDEN_DEPENDENCIES ZLIB::ZLIB)
++if(openvdb_je IN_LIST OpenVDB_FIND_COMPONENTS)
++  find_package(Jemalloc REQUIRED)
+ endif()
+ 
+ # ------------------------------------------------------------------------
+-#  Configure imported target
++#  Configure imported targets
+ # ------------------------------------------------------------------------
+ 
+-set(OpenVDB_LIBRARIES
+-  ${OpenVDB_LIB_COMPONENTS}
+-)
++set(OpenVDB_LIBRARIES ${OpenVDB_LIB_COMPONENTS})
+ set(OpenVDB_INCLUDE_DIRS ${OpenVDB_INCLUDE_DIR})
+ 
+-set(OpenVDB_DEFINITIONS)
+-list(APPEND OpenVDB_DEFINITIONS "${PC_OpenVDB_CFLAGS_OTHER}")
+-list(APPEND OpenVDB_DEFINITIONS "${_OPENVDB_DEFINITIONS}")
+-list(REMOVE_DUPLICATES OpenVDB_DEFINITIONS)
+-
+ set(OpenVDB_LIBRARY_DIRS "")
+ foreach(LIB ${OpenVDB_LIB_COMPONENTS})
+   get_filename_component(_OPENVDB_LIBDIR ${LIB} DIRECTORY)
+@@ -519,49 +689,102 @@ foreach(LIB ${OpenVDB_LIB_COMPONENTS})
+ endforeach()
+ list(REMOVE_DUPLICATES OpenVDB_LIBRARY_DIRS)
+ 
+-foreach(COMPONENT ${OpenVDB_FIND_COMPONENTS})
+-  if(NOT TARGET OpenVDB::${COMPONENT})
+-    if (${COMPONENT} STREQUAL openvdb)
+-      include (${CMAKE_CURRENT_LIST_DIR}/CheckAtomic.cmake)
+-      set(_LINK_LIBS ${_OPENVDB_VISIBLE_DEPENDENCIES} ${CMAKE_REQUIRED_LIBRARIES})
+-    else ()
+-      set(_LINK_LIBS _OPENVDB_VISIBLE_DEPENDENCIES)
+-    endif ()
+-
+-    add_library(OpenVDB::${COMPONENT} UNKNOWN IMPORTED)
+-    set_target_properties(OpenVDB::${COMPONENT} PROPERTIES
+-      INTERFACE_COMPILE_OPTIONS "${OpenVDB_DEFINITIONS}"
+-      INTERFACE_INCLUDE_DIRECTORIES "${OpenVDB_INCLUDE_DIR}"
+-      IMPORTED_LINK_DEPENDENT_LIBRARIES "${_OPENVDB_HIDDEN_DEPENDENCIES}" # non visible deps
+-      INTERFACE_LINK_LIBRARIES "${_LINK_LIBS}" # visible deps (headers)
+-      INTERFACE_COMPILE_FEATURES cxx_std_11
+-      IMPORTED_LOCATION "${OpenVDB_${COMPONENT}_LIBRARY}"
++# OpenVDB::openvdb
++
++if(NOT TARGET OpenVDB::openvdb)
++  set(OPENVDB_openvdb_LIB_TYPE UNKNOWN)
++  if(OPENVDB_USE_STATIC_LIBS)
++    set(OPENVDB_openvdb_LIB_TYPE STATIC)
++  elseif(UNIX)
++    get_filename_component(_OPENVDB_openvdb_EXT
++      ${OpenVDB_openvdb_LIBRARY} EXT)
++    if(_OPENVDB_openvdb_EXT STREQUAL ".a")
++      set(OPENVDB_openvdb_LIB_TYPE STATIC)
++    elseif(_OPENVDB_openvdb_EXT STREQUAL ".so" OR
++           _OPENVDB_openvdb_EXT STREQUAL ".dylib")
++      set(OPENVDB_openvdb_LIB_TYPE SHARED)
++    endif()
++  endif()
++
++  add_library(OpenVDB::openvdb ${OPENVDB_openvdb_LIB_TYPE} IMPORTED)
++  set_target_properties(OpenVDB::openvdb PROPERTIES
++    IMPORTED_LOCATION "${OpenVDB_openvdb_LIBRARY}"
++    INTERFACE_COMPILE_OPTIONS "${PC_OpenVDB_CFLAGS_OTHER}"
++    INTERFACE_COMPILE_DEFINITIONS "${OpenVDB_DEFINITIONS}"
++    INTERFACE_INCLUDE_DIRECTORIES "${OpenVDB_INCLUDE_DIR}"
++    IMPORTED_LINK_DEPENDENT_LIBRARIES "${_OPENVDB_HIDDEN_DEPENDENCIES}" # non visible deps
++    INTERFACE_LINK_LIBRARIES "${_OPENVDB_VISIBLE_DEPENDENCIES}" # visible deps (headers)
++    INTERFACE_COMPILE_FEATURES cxx_std_14
++  )
++endif()
++
++# OpenVDB::openvdb_je
++
++if(OpenVDB_openvdb_je_LIBRARY)
++  if(NOT TARGET OpenVDB::openvdb_je)
++    add_library(OpenVDB::openvdb_je INTERFACE IMPORTED)
++    target_link_libraries(OpenVDB::openvdb_je INTERFACE OpenVDB::openvdb)
++    target_link_libraries(OpenVDB::openvdb_je INTERFACE Jemalloc::jemalloc)
++  endif()
++endif()
++
++# OpenVDB::pyopenvdb
++
++if(OpenVDB_pyopenvdb_LIBRARY)
++  if(NOT TARGET OpenVDB::pyopenvdb)
++    add_library(OpenVDB::pyopenvdb MODULE IMPORTED)
++    set_target_properties(OpenVDB::pyopenvdb PROPERTIES
++      IMPORTED_LOCATION "${OpenVDB_pyopenvdb_LIBRARY}"
++      INTERFACE_INCLUDE_DIRECTORIES "${OpenVDB_pyopenvdb_INCLUDE_DIR};${PYTHON_INCLUDE_DIR}"
++      INTERFACE_LINK_LIBRARIES "OpenVDB::openvdb;Boost::${BOOST_PYTHON_LIB};${PYTHON_LIBRARIES}"
++      INTERFACE_COMPILE_FEATURES cxx_std_14
+    )
++  endif()
++endif()
+ 
+-   if (_is_multi)
+-     set_target_properties(OpenVDB::${COMPONENT} PROPERTIES 
+-       IMPORTED_LOCATION_RELEASE "${OpenVDB_${COMPONENT}_LIBRARY_RELEASE}"
+-     )
+-
+-     if (MSVC OR OpenVDB_${COMPONENT}_LIBRARY_DEBUG)
+-      set_target_properties(OpenVDB::${COMPONENT} PROPERTIES 
+-        IMPORTED_LOCATION_DEBUG "${OpenVDB_${COMPONENT}_LIBRARY_DEBUG}"
+-      ) 
+-     endif ()
+-   endif ()
+-
+-   if (OPENVDB_USE_STATIC_LIBS)
+-    set_target_properties(OpenVDB::${COMPONENT} PROPERTIES
+-      INTERFACE_COMPILE_DEFINITIONS "OPENVDB_STATICLIB;OPENVDB_OPENEXR_STATICLIB"
+-    )
+-   endif()
++# OpenVDB::openvdb_houdini
++
++if(OpenVDB_openvdb_houdini_LIBRARY)
++  if(NOT TARGET OpenVDB::openvdb_houdini)
++    add_library(OpenVDB::openvdb_houdini SHARED IMPORTED)
++    set_target_properties(OpenVDB::openvdb_houdini PROPERTIES
++      IMPORTED_LOCATION "${OpenVDB_openvdb_houdini_LIBRARY}"
++      INTERFACE_INCLUDE_DIRECTORIES "${OpenVDB_openvdb_houdini_INCLUDE_DIR}"
++      INTERFACE_LINK_LIBRARIES "OpenVDB::openvdb;Houdini"
++      INTERFACE_COMPILE_FEATURES cxx_std_14
++   )
+   endif()
+-endforeach()
++endif()
++
++# OpenVDB::openvdb_ax
++
++if(OpenVDB_openvdb_ax_LIBRARY)
++  set(OPENVDB_openvdb_ax_LIB_TYPE UNKNOWN)
++  if(OPENVDB_USE_STATIC_LIBS)
++    set(OPENVDB_openvdb_ax_LIB_TYPE STATIC)
++  elseif(UNIX)
++    get_filename_component(_OPENVDB_openvdb_ax_EXT
++      ${OpenVDB_openvdb_ax_LIBRARY} EXT)
++    if(_OPENVDB_openvdb_ax_EXT STREQUAL ".a")
++      set(OPENVDB_openvdb_ax_LIB_TYPE STATIC)
++    elseif(_OPENVDB_openvdb_ax_EXT STREQUAL ".so" OR
++           _OPENVDB_openvdb_ax_EXT STREQUAL ".dylib")
++      set(OPENVDB_openvdb_ax_LIB_TYPE SHARED)
++    endif()
++  endif()
++
+ 
+-if(OpenVDB_FOUND AND NOT OpenVDB_FIND_QUIETLY)
+-  message(STATUS "OpenVDB libraries: ${OpenVDB_LIBRARIES}")
++  if(NOT TARGET OpenVDB::openvdb_ax)
++    add_library(OpenVDB::openvdb_ax UNKNOWN IMPORTED)
++    set_target_properties(OpenVDB::openvdb_ax PROPERTIES
++      IMPORTED_LOCATION "${OpenVDB_openvdb_ax_LIBRARY}"
++      INTERFACE_INCLUDE_DIRECTORIES "${OpenVDB_openvdb_ax_INCLUDE_DIR}"
++      INTERFACE_SYSTEM_INCLUDE_DIRECTORIES "${LLVM_INCLUDE_DIRS}"
++      INTERFACE_LINK_LIBRARIES "OpenVDB::openvdb;${LLVM_LIBS}"
++      INTERFACE_COMPILE_FEATURES cxx_std_14
++    )
++  endif()
+ endif()
+ 
+-unset(_OPENVDB_DEFINITIONS)
+ unset(_OPENVDB_VISIBLE_DEPENDENCIES)
+ unset(_OPENVDB_HIDDEN_DEPENDENCIES)
diff --git a/prusaslicer/patches/patch-cmake_modules_FindTBB.cmake b/prusaslicer/patches/patch-cmake_modules_FindTBB.cmake
new file mode 100644
index 0000000000..48d4e7f21a
--- /dev/null
+++ b/prusaslicer/patches/patch-cmake_modules_FindTBB.cmake
@@ -0,0 +1,420 @@
+$NetBSD$
+
+cmake file copied from TBB distro.
+
+--- cmake/modules/FindTBB.cmake.orig	2021-07-16 10:14:03.000000000 +0000
++++ cmake/modules/FindTBB.cmake
+@@ -1,332 +1,89 @@
+-# The MIT License (MIT)
++# Copyright (c) 2020-2021 Intel Corporation
+ #
+-# Copyright (c) 2015 Justus Calvin
+-# 
+-# Permission is hereby granted, free of charge, to any person obtaining a copy
+-# of this software and associated documentation files (the "Software"), to deal
+-# in the Software without restriction, including without limitation the rights
+-# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+-# copies of the Software, and to permit persons to whom the Software is
+-# furnished to do so, subject to the following conditions:
+-# 
+-# The above copyright notice and this permission notice shall be included in all
+-# copies or substantial portions of the Software.
+-# 
+-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+-# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+-# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+-# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+-# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+-# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+-# SOFTWARE.
+-
+-#
+-# FindTBB
+-# -------
+-#
+-# Find TBB include directories and libraries.
+-#
+-# Usage:
+-#
+-#  find_package(TBB [major[.minor]] [EXACT]
+-#               [QUIET] [REQUIRED]
+-#               [[COMPONENTS] [components...]]
+-#               [OPTIONAL_COMPONENTS components...]) 
+-#
+-# where the allowed components are tbbmalloc and tbb_preview. Users may modify 
+-# the behavior of this module with the following variables:
+-#
+-# * TBB_ROOT_DIR          - The base directory the of TBB installation.
+-# * TBB_INCLUDE_DIR       - The directory that contains the TBB headers files.
+-# * TBB_LIBRARY           - The directory that contains the TBB library files.
+-# * TBB_<library>_LIBRARY - The path of the TBB the corresponding TBB library. 
+-#                           These libraries, if specified, override the 
+-#                           corresponding library search results, where <library>
+-#                           may be tbb, tbb_debug, tbbmalloc, tbbmalloc_debug,
+-#                           tbb_preview, or tbb_preview_debug.
+-# * TBB_USE_DEBUG_BUILD   - The debug version of tbb libraries, if present, will
+-#                           be used instead of the release version.
+-# * TBB_STATIC            - Static linking of libraries with a _static suffix.
+-#                           For example, on Windows a tbb_static.lib will be searched for
+-#                           instead of tbb.lib.
+-#
+-# Users may modify the behavior of this module with the following environment
+-# variables:
+-#
+-# * TBB_INSTALL_DIR 
+-# * TBBROOT
+-# * LIBRARY_PATH
+-#
+-# This module will set the following variables:
+-#
+-# * TBB_FOUND             - Set to false, or undefined, if we haven’t found, or
+-#                           don’t want to use TBB.
+-# * TBB_<component>_FOUND - If False, optional <component> part of TBB sytem is
+-#                           not available.
+-# * TBB_VERSION           - The full version string
+-# * TBB_VERSION_MAJOR     - The major version
+-# * TBB_VERSION_MINOR     - The minor version
+-# * TBB_INTERFACE_VERSION - The interface version number defined in 
+-#                           tbb/tbb_stddef.h.
+-# * TBB_<library>_LIBRARY_RELEASE - The path of the TBB release version of 
+-#                           <library>, where <library> may be tbb, tbb_debug,
+-#                           tbbmalloc, tbbmalloc_debug, tbb_preview, or 
+-#                           tbb_preview_debug.
+-# * TBB_<library>_LIBRARY_DEGUG - The path of the TBB release version of 
+-#                           <library>, where <library> may be tbb, tbb_debug,
+-#                           tbbmalloc, tbbmalloc_debug, tbb_preview, or 
+-#                           tbb_preview_debug.
+-#
+-# The following varibles should be used to build and link with TBB:
+-#
+-# * TBB_INCLUDE_DIRS        - The include directory for TBB.
+-# * TBB_LIBRARIES           - The libraries to link against to use TBB.
+-# * TBB_LIBRARIES_RELEASE   - The release libraries to link against to use TBB.
+-# * TBB_LIBRARIES_DEBUG     - The debug libraries to link against to use TBB.
+-# * TBB_DEFINITIONS         - Definitions to use when compiling code that uses
+-#                             TBB.
+-# * TBB_DEFINITIONS_RELEASE - Definitions to use when compiling release code that
+-#                             uses TBB.
+-# * TBB_DEFINITIONS_DEBUG   - Definitions to use when compiling debug code that
+-#                             uses TBB.
+-#
+-# This module will also create the "tbb" target that may be used when building
+-# executables and libraries.
+-
+-unset(TBB_FOUND CACHE)
+-unset(TBB_INCLUDE_DIRS CACHE)
+-unset(TBB_LIBRARIES)
+-unset(TBB_LIBRARIES_DEBUG)
+-unset(TBB_LIBRARIES_RELEASE)
++# Licensed under the Apache License, Version 2.0 (the "License");
++# you may not use this file except in compliance with the License.
++# You may obtain a copy of the License at
++#
++#     http://www.apache.org/licenses/LICENSE-2.0
++#
++# Unless required by applicable law or agreed to in writing, software
++# distributed under the License is distributed on an "AS IS" BASIS,
++# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
++# See the License for the specific language governing permissions and
++# limitations under the License.
+ 
+ include(FindPackageHandleStandardArgs)
+ 
+-find_package(Threads QUIET REQUIRED)
++# Firstly search for TBB in config mode (i.e. search for TBBConfig.cmake).
++find_package(TBB QUIET CONFIG)
++if (TBB_FOUND)
++    find_package_handle_standard_args(TBB CONFIG_MODE)
++    return()
++endif()
++
++if (NOT TBB_FIND_COMPONENTS)
++    set(TBB_FIND_COMPONENTS tbb tbbmalloc)
++    foreach (_tbb_component ${TBB_FIND_COMPONENTS})
++        set(TBB_FIND_REQUIRED_${_tbb_component} 1)
++    endforeach()
++endif()
+ 
+-if(NOT TBB_FOUND)
++if (WIN32)
++    list(APPEND ADDITIONAL_LIB_DIRS ENV PATH ENV LIB)
++    list(APPEND ADDITIONAL_INCLUDE_DIRS ENV INCLUDE ENV CPATH)
++else()
++    list(APPEND ADDITIONAL_LIB_DIRS ENV LIBRARY_PATH ENV LD_LIBRARY_PATH ENV DYLD_LIBRARY_PATH)
++    list(APPEND ADDITIONAL_INCLUDE_DIRS ENV CPATH ENV C_INCLUDE_PATH ENV CPLUS_INCLUDE_PATH ENV INCLUDE_PATH)
++endif()
+ 
+-  ##################################
+-  # Check the build type
+-  ##################################
+-  
+-  if(NOT DEFINED TBB_USE_DEBUG_BUILD)
+-    if(CMAKE_BUILD_TYPE MATCHES "(Debug|DEBUG|debug)")
+-      set(TBB_BUILD_TYPE DEBUG)
+-    else()
+-      set(TBB_BUILD_TYPE RELEASE)
+-    endif()
+-  elseif(TBB_USE_DEBUG_BUILD)
+-    set(TBB_BUILD_TYPE DEBUG)
+-  else()
+-    set(TBB_BUILD_TYPE RELEASE)
+-  endif()
+-  
+-  ##################################
+-  # Set the TBB search directories
+-  ##################################
+-  
+-  # Define search paths based on user input and environment variables
+-  set(TBB_SEARCH_DIR ${TBB_ROOT_DIR} $ENV{TBB_INSTALL_DIR} $ENV{TBBROOT})
+-  
+-  # Define the search directories based on the current platform
+-  if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+-    set(TBB_DEFAULT_SEARCH_DIR "C:/Program Files/Intel/TBB"
+-                               "C:/Program Files (x86)/Intel/TBB")
+-
+-    # Set the target architecture
+-    if(CMAKE_SIZEOF_VOID_P EQUAL 8)
+-      set(TBB_ARCHITECTURE "intel64")
+-    else()
+-      set(TBB_ARCHITECTURE "ia32")
+-    endif()
+-
+-    # Set the TBB search library path search suffix based on the version of VC
+-    if(WINDOWS_STORE)
+-      set(TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc11_ui")
+-    elseif(MSVC14)
+-      set(TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc14")
+-    elseif(MSVC12)
+-      set(TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc12")
+-    elseif(MSVC11)
+-      set(TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc11")
+-    elseif(MSVC10)
+-      set(TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc10")
+-    endif()
+-
+-    # Add the library path search suffix for the VC independent version of TBB
+-    list(APPEND TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc_mt")
+-
+-  elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
+-    # OS X
+-    set(TBB_DEFAULT_SEARCH_DIR "/opt/intel/tbb")
+-    
+-    # TODO: Check to see which C++ library is being used by the compiler.
+-    if(NOT ${CMAKE_SYSTEM_VERSION} VERSION_LESS 13.0)
+-      # The default C++ library on OS X 10.9 and later is libc++
+-      set(TBB_LIB_PATH_SUFFIX "lib/libc++" "lib")
+-    else()
+-      set(TBB_LIB_PATH_SUFFIX "lib")
+-    endif()
+-  elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+-    # Linux
+-    set(TBB_DEFAULT_SEARCH_DIR "/opt/intel/tbb")
+-    
+-    # TODO: Check compiler version to see the suffix should be <arch>/gcc4.1 or
+-    #       <arch>/gcc4.1. For now, assume that the compiler is more recent than
+-    #       gcc 4.4.x or later.
+-    if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
+-      set(TBB_LIB_PATH_SUFFIX "lib/intel64/gcc4.4")
+-    elseif(CMAKE_SYSTEM_PROCESSOR MATCHES "^i.86$")
+-      set(TBB_LIB_PATH_SUFFIX "lib/ia32/gcc4.4")
+-    endif()
+-  endif()
+-  
+-  ##################################
+-  # Find the TBB include dir
+-  ##################################
+-  
+-  find_path(TBB_INCLUDE_DIRS tbb/tbb.h
+-      HINTS ${TBB_INCLUDE_DIR} ${TBB_SEARCH_DIR}
+-      PATHS ${TBB_DEFAULT_SEARCH_DIR}
+-      PATH_SUFFIXES include)
+-
+-  ##################################
+-  # Set version strings
+-  ##################################
+-
+-  if(TBB_INCLUDE_DIRS)
+-    file(READ "${TBB_INCLUDE_DIRS}/tbb/tbb_stddef.h" _tbb_version_file)
+-    string(REGEX REPLACE ".*#define TBB_VERSION_MAJOR ([0-9]+).*" "\\1"
+-        TBB_VERSION_MAJOR "${_tbb_version_file}")
+-    string(REGEX REPLACE ".*#define TBB_VERSION_MINOR ([0-9]+).*" "\\1"
+-        TBB_VERSION_MINOR "${_tbb_version_file}")
+-    string(REGEX REPLACE ".*#define TBB_INTERFACE_VERSION ([0-9]+).*" "\\1"
+-        TBB_INTERFACE_VERSION "${_tbb_version_file}")
+-    set(TBB_VERSION "${TBB_VERSION_MAJOR}.${TBB_VERSION_MINOR}")
+-  endif()
+-
+-  ##################################
+-  # Find TBB components
+-  ##################################
+-
+-  if(TBB_VERSION VERSION_LESS 4.3)
+-    set(TBB_SEARCH_COMPOMPONENTS tbb_preview tbbmalloc tbb)
+-  else()
+-    set(TBB_SEARCH_COMPOMPONENTS tbb_preview tbbmalloc_proxy tbbmalloc tbb)
+-  endif()
+-
+-  if(TBB_STATIC)
+-    set(TBB_STATIC_SUFFIX "_static")
+-  endif()
+-
+-  # Find each component
+-  foreach(_comp ${TBB_SEARCH_COMPOMPONENTS})
+-    if(";${TBB_FIND_COMPONENTS};tbb;" MATCHES ";${_comp};")
+-
+-      unset(TBB_${_comp}_LIBRARY_DEBUG CACHE)
+-      unset(TBB_${_comp}_LIBRARY_RELEASE CACHE)
+-
+-      # Search for the libraries
+-      find_library(TBB_${_comp}_LIBRARY_RELEASE ${_comp}${TBB_STATIC_SUFFIX}
+-          HINTS ${TBB_LIBRARY} ${TBB_SEARCH_DIR}
+-          PATHS ${TBB_DEFAULT_SEARCH_DIR} ENV LIBRARY_PATH
+-          PATH_SUFFIXES ${TBB_LIB_PATH_SUFFIX})
+-
+-      find_library(TBB_${_comp}_LIBRARY_DEBUG ${_comp}${TBB_STATIC_SUFFIX}_debug
+-          HINTS ${TBB_LIBRARY} ${TBB_SEARCH_DIR}
+-          PATHS ${TBB_DEFAULT_SEARCH_DIR} ENV LIBRARY_PATH
+-          PATH_SUFFIXES ${TBB_LIB_PATH_SUFFIX})
+-
+-      if(TBB_${_comp}_LIBRARY_DEBUG)
+-        list(APPEND TBB_LIBRARIES_DEBUG "${TBB_${_comp}_LIBRARY_DEBUG}")
+-      endif()
+-      if(TBB_${_comp}_LIBRARY_RELEASE)
+-        list(APPEND TBB_LIBRARIES_RELEASE "${TBB_${_comp}_LIBRARY_RELEASE}")
+-      endif()
+-      if(TBB_${_comp}_LIBRARY_${TBB_BUILD_TYPE} AND NOT TBB_${_comp}_LIBRARY)
+-        set(TBB_${_comp}_LIBRARY "${TBB_${_comp}_LIBRARY_${TBB_BUILD_TYPE}}")
+-      endif()
+-
+-      if(TBB_${_comp}_LIBRARY AND EXISTS "${TBB_${_comp}_LIBRARY}")
+-        set(TBB_${_comp}_FOUND TRUE)
+-      else()
+-        set(TBB_${_comp}_FOUND FALSE)
+-      endif()
+-
+-      # Mark internal variables as advanced
+-      mark_as_advanced(TBB_${_comp}_LIBRARY_RELEASE)
+-      mark_as_advanced(TBB_${_comp}_LIBRARY_DEBUG)
+-      mark_as_advanced(TBB_${_comp}_LIBRARY)
+-
+-    endif()
+-  endforeach()
+-
+-  ##################################
+-  # Set compile flags and libraries
+-  ##################################
+-
+-  set(TBB_DEFINITIONS_RELEASE "")
+-  set(TBB_DEFINITIONS_DEBUG "TBB_USE_DEBUG=1")
+-    
+-  if(TBB_LIBRARIES_${TBB_BUILD_TYPE})
+-    set(TBB_LIBRARIES "${TBB_LIBRARIES_${TBB_BUILD_TYPE}}")
+-  endif()
+-  
+-  if(NOT MSVC AND NOT TBB_LIBRARIES)
+-    set(TBB_LIBRARIES ${TBB_LIBRARIES_RELEASE})
+-  endif()
+-
+-  set(TBB_DEFINITIONS "")
+-  if (MSVC AND TBB_STATIC)
+-    set(TBB_DEFINITIONS __TBB_NO_IMPLICIT_LINKAGE)
+-  endif ()
+-
+-  unset (TBB_STATIC_SUFFIX)
+-
+-  find_package_handle_standard_args(TBB 
+-      REQUIRED_VARS TBB_INCLUDE_DIRS TBB_LIBRARIES
+-      FAIL_MESSAGE "TBB library cannot be found. Consider set TBBROOT environment variable."
+-      HANDLE_COMPONENTS
+-      VERSION_VAR TBB_VERSION)
+-
+-  ##################################
+-  # Create targets
+-  ##################################
+-
+-  if(NOT CMAKE_VERSION VERSION_LESS 3.0 AND TBB_FOUND)
+-    add_library(TBB::tbb UNKNOWN IMPORTED)
+-    set_target_properties(TBB::tbb PROPERTIES
+-          INTERFACE_COMPILE_DEFINITIONS "${TBB_DEFINITIONS}"
+-          INTERFACE_LINK_LIBRARIES  "Threads::Threads;${CMAKE_DL_LIBS}"
+-          INTERFACE_INCLUDE_DIRECTORIES  ${TBB_INCLUDE_DIRS}
+-          IMPORTED_LOCATION              ${TBB_LIBRARIES})
+-    if(TBB_LIBRARIES_RELEASE AND TBB_LIBRARIES_DEBUG)
+-      set_target_properties(TBB::tbb PROPERTIES
+-          INTERFACE_COMPILE_DEFINITIONS "${TBB_DEFINITIONS};$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:${TBB_DEFINITIONS_DEBUG}>;$<$<CONFIG:Release>:${TBB_DEFINITIONS_RELEASE}>"
+-          IMPORTED_LOCATION_DEBUG          ${TBB_LIBRARIES_DEBUG}
+-          IMPORTED_LOCATION_RELWITHDEBINFO ${TBB_LIBRARIES_RELEASE}
+-          IMPORTED_LOCATION_RELEASE        ${TBB_LIBRARIES_RELEASE}
+-          IMPORTED_LOCATION_MINSIZEREL     ${TBB_LIBRARIES_RELEASE}
+-          )
+-    endif()
+-  endif()
+-
+-  mark_as_advanced(TBB_INCLUDE_DIRS TBB_LIBRARIES)
+-
+-  unset(TBB_ARCHITECTURE)
+-  unset(TBB_BUILD_TYPE)
+-  unset(TBB_LIB_PATH_SUFFIX)
+-  unset(TBB_DEFAULT_SEARCH_DIR)
+-
+-  if(TBB_DEBUG)
+-    message(STATUS "  TBB_FOUND               = ${TBB_FOUND}")
+-    message(STATUS "  TBB_INCLUDE_DIRS        = ${TBB_INCLUDE_DIRS}")
+-    message(STATUS "  TBB_DEFINITIONS         = ${TBB_DEFINITIONS}")
+-    message(STATUS "  TBB_LIBRARIES           = ${TBB_LIBRARIES}")
+-    message(STATUS "  TBB_DEFINITIONS_DEBUG   = ${TBB_DEFINITIONS_DEBUG}")
+-    message(STATUS "  TBB_LIBRARIES_DEBUG     = ${TBB_LIBRARIES_DEBUG}")
+-    message(STATUS "  TBB_DEFINITIONS_RELEASE = ${TBB_DEFINITIONS_RELEASE}")
+-    message(STATUS "  TBB_LIBRARIES_RELEASE   = ${TBB_LIBRARIES_RELEASE}")
+-  endif()
++find_path(_tbb_include_dir NAMES tbb/tbb.h PATHS ${ADDITIONAL_INCLUDE_DIRS})
+ 
++if (_tbb_include_dir)
++    # TODO: consider TBB_VERSION handling
++    set(_TBB_BUILD_MODES RELEASE DEBUG)
++    set(_TBB_DEBUG_SUFFIX _debug)
++
++    foreach (_tbb_component ${TBB_FIND_COMPONENTS})
++        if (NOT TARGET TBB::${_tbb_component})
++            add_library(TBB::${_tbb_component} SHARED IMPORTED)
++            set_property(TARGET TBB::${_tbb_component} APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${_tbb_include_dir})
++
++            foreach(_TBB_BUILD_MODE ${_TBB_BUILD_MODES})
++                set(_tbb_component_lib_name ${_tbb_component}${_TBB_${_TBB_BUILD_MODE}_SUFFIX})
++                if (WIN32)
++                    find_library(${_tbb_component_lib_name}_lib ${_tbb_component_lib_name} PATHS ${ADDITIONAL_LIB_DIRS})
++                    find_file(${_tbb_component_lib_name}_dll ${_tbb_component_lib_name}.dll PATHS ${ADDITIONAL_LIB_DIRS})
++
++                    set_target_properties(TBB::${_tbb_component} PROPERTIES
++                                          IMPORTED_LOCATION_${_TBB_BUILD_MODE} "${${_tbb_component_lib_name}_dll}"
++                                          IMPORTED_IMPLIB_${_TBB_BUILD_MODE}   "${${_tbb_component_lib_name}_lib}"
++                                          )
++                else()
++                    find_library(${_tbb_component_lib_name}_so ${_tbb_component_lib_name} PATHS ${ADDITIONAL_LIB_DIRS})
++
++                    set_target_properties(TBB::${_tbb_component} PROPERTIES
++                                          IMPORTED_LOCATION_${_TBB_BUILD_MODE} "${${_tbb_component_lib_name}_so}"
++                                          )
++                endif()
++                if (${_tbb_component_lib_name}_lib AND ${_tbb_component_lib_name}_dll OR ${_tbb_component_lib_name}_so)
++                    set_property(TARGET TBB::${_tbb_component} APPEND PROPERTY IMPORTED_CONFIGURATIONS ${_TBB_BUILD_MODE})
++                    list(APPEND TBB_IMPORTED_TARGETS TBB::${_tbb_component})
++                    set(TBB_${_tbb_component}_FOUND 1)
++                endif()
++                unset(${_tbb_component_lib_name}_lib CACHE)
++                unset(${_tbb_component_lib_name}_dll CACHE)
++                unset(${_tbb_component_lib_name}_so CACHE)
++                unset(_tbb_component_lib_name)
++            endforeach()
++        endif()
++    endforeach()
++    unset(_TBB_BUILD_MODESS)
++    unset(_TBB_DEBUG_SUFFIX)
+ endif()
++unset(_tbb_include_dir CACHE)
++
++list(REMOVE_DUPLICATES TBB_IMPORTED_TARGETS)
++
++find_package_handle_standard_args(TBB
++                                  REQUIRED_VARS TBB_IMPORTED_TARGETS
++                                  HANDLE_COMPONENTS)
diff --git a/prusaslicer/patches/patch-src_PrusaSlicer.cpp b/prusaslicer/patches/patch-src_PrusaSlicer.cpp
index 1ec418192e..1a47b5038e 100644
--- a/prusaslicer/patches/patch-src_PrusaSlicer.cpp
+++ b/prusaslicer/patches/patch-src_PrusaSlicer.cpp
@@ -1,23 +1,30 @@
 $NetBSD$
 
-Use more portable boost routine for finding running executable path.
+Use /proc filesystem by default for the path to the running binary.
 
---- src/PrusaSlicer.cpp.orig	2021-07-08 06:46:36.000000000 +0000
+--- src/PrusaSlicer.cpp.orig	2021-07-16 10:14:03.000000000 +0000
 +++ src/PrusaSlicer.cpp
-@@ -23,6 +23,7 @@
- #include <iostream>
- #include <math.h>
- #include <boost/algorithm/string/predicate.hpp>
-+#include <boost/dll/runtime_symbol_info.hpp>
- #include <boost/filesystem.hpp>
- #include <boost/nowide/args.hpp>
- #include <boost/nowide/cenv.hpp>
-@@ -612,7 +613,7 @@ bool CLI::setup(int argc, char **argv)
+@@ -612,7 +612,22 @@ bool CLI::setup(int argc, char **argv)
      // Detect the operating system flavor after SLIC3R_LOGLEVEL is set.
      detect_platform();
  
 -    boost::filesystem::path path_to_binary = boost::filesystem::system_complete(argv[0]);
-+    boost::filesystem::path path_to_binary = boost::dll::program_location();
++    boost::filesystem::path path_to_binary;
++    boost::system::error_code ec;
++    // Linux
++    path_to_binary = boost::filesystem::canonical("/proc/self/exe", ec);
++    // NetBSD
++    if (path_to_binary.empty()) {
++        path_to_binary = boost::filesystem::canonical("/proc/curproc/exe", ec);
++    }
++    // FreeBSD
++    if (path_to_binary.empty()) {
++        path_to_binary = boost::filesystem::canonical("/proc/curproc/file", ec);
++    }
++    // fallback to old, incorrect method, which just appends the binary to the cwd.
++    if (path_to_binary.empty()) {
++        path_to_binary = boost::filesystem::canonical(boost::filesystem::system_complete(argv[0]));
++    }
  
      // Path from the Slic3r binary to its resources.
  #ifdef __APPLE__
diff --git a/prusaslicer/patches/patch-src_libslic3r_Print.cpp b/prusaslicer/patches/patch-src_libslic3r_Print.cpp
new file mode 100644
index 0000000000..d217622b06
--- /dev/null
+++ b/prusaslicer/patches/patch-src_libslic3r_Print.cpp
@@ -0,0 +1,33 @@
+$NetBSD$
+
+Migrate from deprecated tbb::mutex to std::mutex.
+
+--- src/libslic3r/Print.cpp.orig	2021-07-16 10:14:03.000000000 +0000
++++ src/libslic3r/Print.cpp
+@@ -36,7 +36,7 @@ template class PrintState<PrintObjectSte
+ 
+ void Print::clear() 
+ {
+-	tbb::mutex::scoped_lock lock(this->state_mutex());
++	std::lock_guard<std::mutex> lock(this->state_mutex());
+     // The following call should stop background processing if it is running.
+     this->invalidate_all_steps();
+ 	for (PrintObject *object : m_objects)
+@@ -262,7 +262,7 @@ bool Print::is_step_done(PrintObjectStep
+ {
+     if (m_objects.empty())
+         return false;
+-    tbb::mutex::scoped_lock lock(this->state_mutex());
++    std::lock_guard<std::mutex> lock(this->state_mutex());
+     for (const PrintObject *object : m_objects)
+         if (! object->is_step_done_unguarded(step))
+             return false;
+@@ -617,7 +617,7 @@ Print::ApplyStatus Print::apply(const Mo
+         update_apply_status(false);
+ 
+     // Grab the lock for the Print / PrintObject milestones.
+-	tbb::mutex::scoped_lock lock(this->state_mutex());
++	std::lock_guard<std::mutex> lock(this->state_mutex());
+ 
+     // The following call may stop the background processing.
+     if (! print_diff.empty())
diff --git a/prusaslicer/patches/patch-src_libslic3r_PrintBase.cpp b/prusaslicer/patches/patch-src_libslic3r_PrintBase.cpp
new file mode 100644
index 0000000000..6777d5bef8
--- /dev/null
+++ b/prusaslicer/patches/patch-src_libslic3r_PrintBase.cpp
@@ -0,0 +1,15 @@
+$NetBSD$
+
+Migrate from deprecated tbb::mutex to std::mutex.
+
+--- src/libslic3r/PrintBase.cpp.orig	2021-07-16 10:14:03.000000000 +0000
++++ src/libslic3r/PrintBase.cpp
+@@ -97,7 +97,7 @@ void PrintBase::status_update_warnings(O
+     	printf("%s warning: %s\n", (object_id == this->id()) ? "print" : "print object", message.c_str());
+ }
+ 
+-tbb::mutex& PrintObjectBase::state_mutex(PrintBase *print)
++std::mutex& PrintObjectBase::state_mutex(PrintBase *print)
+ { 
+ 	return print->state_mutex();
+ }
diff --git a/prusaslicer/patches/patch-src_libslic3r_PrintBase.hpp b/prusaslicer/patches/patch-src_libslic3r_PrintBase.hpp
new file mode 100644
index 0000000000..f97877c45a
--- /dev/null
+++ b/prusaslicer/patches/patch-src_libslic3r_PrintBase.hpp
@@ -0,0 +1,158 @@
+$NetBSD$
+
+Migrate from deprecated tbb::mutex to std::mutex.
+Migrate from deprecated tbb::atomic to std::atomic.
+
+--- src/libslic3r/PrintBase.hpp.orig	2021-07-16 10:14:03.000000000 +0000
++++ src/libslic3r/PrintBase.hpp
+@@ -2,17 +2,13 @@
+ #define slic3r_PrintBase_hpp_
+ 
+ #include "libslic3r.h"
++#include <atomic>
+ #include <set>
+ #include <vector>
++#include <mutex>
+ #include <string>
+ #include <functional>
+ 
+-// tbb/mutex.h includes Windows, which in turn defines min/max macros. Convince Windows.h to not define these min/max macros.
+-#ifndef NOMINMAX
+-    #define NOMINMAX
+-#endif
+-#include "tbb/mutex.h"
+-
+ #include "ObjectID.hpp"
+ #include "Model.hpp"
+ #include "PlaceholderParser.hpp"
+@@ -84,23 +80,23 @@ class PrintState : public PrintStateBase
+ public:
+     PrintState() {}
+ 
+-    StateWithTimeStamp state_with_timestamp(StepType step, tbb::mutex &mtx) const {
+-        tbb::mutex::scoped_lock lock(mtx);
++    StateWithTimeStamp state_with_timestamp(StepType step, std::mutex &mtx) const {
++        std::lock_guard<std::mutex> lock(mtx);
+         StateWithTimeStamp state = m_state[step];
+         return state;
+     }
+ 
+-    StateWithWarnings state_with_warnings(StepType step, tbb::mutex &mtx) const {
+-        tbb::mutex::scoped_lock lock(mtx);
++    StateWithWarnings state_with_warnings(StepType step, std::mutex &mtx) const {
++        std::lock_guard<std::mutex> lock(mtx);
+         StateWithWarnings state = m_state[step];
+         return state;
+     }
+ 
+-    bool is_started(StepType step, tbb::mutex &mtx) const {
++    bool is_started(StepType step, std::mutex &mtx) const {
+         return this->state_with_timestamp(step, mtx).state == STARTED;
+     }
+ 
+-    bool is_done(StepType step, tbb::mutex &mtx) const {
++    bool is_done(StepType step, std::mutex &mtx) const {
+         return this->state_with_timestamp(step, mtx).state == DONE;
+     }
+ 
+@@ -121,8 +117,8 @@ public:
+     // This is necessary to block until the Print::apply() updates its state, which may
+     // influence the processing step being entered.
+     template<typename ThrowIfCanceled>
+-    bool set_started(StepType step, tbb::mutex &mtx, ThrowIfCanceled throw_if_canceled) {
+-        tbb::mutex::scoped_lock lock(mtx);
++    bool set_started(StepType step, std::mutex &mtx, ThrowIfCanceled throw_if_canceled) {
++        std::lock_guard<std::mutex> lock(mtx);
+         // If canceled, throw before changing the step state.
+         throw_if_canceled();
+ #ifndef NDEBUG
+@@ -154,8 +150,8 @@ public:
+     // 		Timestamp when this stepentered the DONE state.
+     // 		bool indicates whether the UI has to update the slicing warnings of this step or not.
+ 	template<typename ThrowIfCanceled>
+-	std::pair<TimeStamp, bool> set_done(StepType step, tbb::mutex &mtx, ThrowIfCanceled throw_if_canceled) {
+-        tbb::mutex::scoped_lock lock(mtx);
++	std::pair<TimeStamp, bool> set_done(StepType step, std::mutex &mtx, ThrowIfCanceled throw_if_canceled) {
++        std::lock_guard<std::mutex> lock(mtx);
+         // If canceled, throw before changing the step state.
+         throw_if_canceled();
+         assert(m_state[step].state == STARTED);
+@@ -266,9 +262,9 @@ public:
+     // Return value:
+     // 		Current milestone (StepType).
+     // 		bool indicates whether the UI has to be updated or not.
+-    std::pair<StepType, bool> active_step_add_warning(PrintStateBase::WarningLevel warning_level, const std::string &message, int message_id, tbb::mutex &mtx)
++    std::pair<StepType, bool> active_step_add_warning(PrintStateBase::WarningLevel warning_level, const std::string &message, int message_id, std::mutex &mtx)
+     {
+-        tbb::mutex::scoped_lock lock(mtx);
++	std::lock_guard<std::mutex> lock(mtx);
+         assert(m_step_active != -1);
+         StateWithWarnings &state = m_state[m_step_active];
+         assert(state.state == STARTED);
+@@ -314,7 +310,7 @@ protected:
+     PrintObjectBase(ModelObject *model_object) : m_model_object(model_object) {}
+     virtual ~PrintObjectBase() {}
+     // Declared here to allow access from PrintBase through friendship.
+-	static tbb::mutex&                  state_mutex(PrintBase *print);
++	static std::mutex&                  state_mutex(PrintBase *print);
+ 	static std::function<void()>        cancel_callback(PrintBase *print);
+ 	// Notify UI about a new warning of a milestone "step" on this PrintObjectBase.
+ 	// The UI will be notified by calling a status callback registered on print.
+@@ -436,16 +432,16 @@ public:
+ 		// Canceled by user from the user interface (user pressed the "Cancel" button or user closed the application).
+ 		CANCELED_BY_USER = 1,
+ 		// Canceled internally from Print::apply() through the Print/PrintObject::invalidate_step() or ::invalidate_all_steps().
+-		CANCELED_INTERNAL = 2
++		CANCELED_INTERNAL = 2,
+ 	};
+     CancelStatus               cancel_status() const { return m_cancel_status; }
+     // Has the calculation been canceled?
+-	bool                       canceled() const { return m_cancel_status != NOT_CANCELED; }
++	bool                       canceled() const { return m_cancel_status != CancelStatus::NOT_CANCELED; }
+     // Cancel the running computation. Stop execution of all the background threads.
+-	void                       cancel() { m_cancel_status = CANCELED_BY_USER; }
+-	void                       cancel_internal() { m_cancel_status = CANCELED_INTERNAL; }
++	void                       cancel() { m_cancel_status = CancelStatus::CANCELED_BY_USER; }
++	void                       cancel_internal() { m_cancel_status = CancelStatus::CANCELED_INTERNAL; }
+     // Cancel the running computation. Stop execution of all the background threads.
+-	void                       restart() { m_cancel_status = NOT_CANCELED; }
++	void                       restart() { m_cancel_status = CancelStatus::NOT_CANCELED; }
+     // Returns true if the last step was finished with success.
+     virtual bool               finished() const = 0;
+ 
+@@ -461,7 +457,7 @@ protected:
+ 	friend class PrintObjectBase;
+     friend class BackgroundSlicingProcess;
+ 
+-    tbb::mutex&            state_mutex() const { return m_state_mutex; }
++    std::mutex&            state_mutex() const { return m_state_mutex; }
+     std::function<void()>  cancel_callback() { return m_cancel_callback; }
+ 	void				   call_cancel_callback() { m_cancel_callback(); }
+ 	// Notify UI about a new warning of a milestone "step" on this PrintBase.
+@@ -471,7 +467,7 @@ protected:
+ 
+     // If the background processing stop was requested, throw CanceledException.
+     // To be called by the worker thread and its sub-threads (mostly launched on the TBB thread pool) regularly.
+-    void                   throw_if_canceled() const { if (m_cancel_status) throw CanceledException(); }
++    void                   throw_if_canceled() const { if (canceled()) throw CanceledException(); }
+ 
+     // To be called by this->output_filename() with the format string pulled from the configuration layer.
+     std::string            output_filename(const std::string &format, const std::string &default_ext, const std::string &filename_base, const DynamicConfig *config_override = nullptr) const;
+@@ -486,7 +482,7 @@ protected:
+     status_callback_type                    m_status_callback;
+ 
+ private:
+-    tbb::atomic<CancelStatus>               m_cancel_status;
++    std::atomic<Slic3r::PrintBase::CancelStatus>               m_cancel_status {CancelStatus::NOT_CANCELED};
+ 
+     // Callback to be evoked to stop the background processing before a state is updated.
+     cancel_callback_type                    m_cancel_callback = [](){};
+@@ -494,7 +490,7 @@ private:
+     // Mutex used for synchronization of the worker thread with the UI thread:
+     // The mutex will be used to guard the worker thread against entering a stage
+     // while the data influencing the stage is modified.
+-    mutable tbb::mutex                      m_state_mutex;
++    mutable std::mutex                      m_state_mutex;
+ };
+ 
+ template<typename PrintStepEnum, const size_t COUNT>
diff --git a/prusaslicer/patches/patch-src_libslic3r_PrintObject.cpp b/prusaslicer/patches/patch-src_libslic3r_PrintObject.cpp
new file mode 100644
index 0000000000..22ea3af6e7
--- /dev/null
+++ b/prusaslicer/patches/patch-src_libslic3r_PrintObject.cpp
@@ -0,0 +1,14 @@
+$NetBSD$
+
+Migrate from deprecated tbb::atomic to std::atomic.
+
+--- src/libslic3r/PrintObject.cpp.orig	2021-07-16 10:14:03.000000000 +0000
++++ src/libslic3r/PrintObject.cpp
+@@ -19,7 +19,6 @@
+ #include <float.h>
+ 
+ #include <tbb/parallel_for.h>
+-#include <tbb/atomic.h>
+ 
+ #include <Shiny/Shiny.h>
+ 
diff --git a/prusaslicer/patches/patch-src_libslic3r_SLAPrint.cpp b/prusaslicer/patches/patch-src_libslic3r_SLAPrint.cpp
new file mode 100644
index 0000000000..7f6cbd726a
--- /dev/null
+++ b/prusaslicer/patches/patch-src_libslic3r_SLAPrint.cpp
@@ -0,0 +1,51 @@
+$NetBSD$
+
+Migrate from deprecated tbb::mutex to std::mutex.
+
+--- src/libslic3r/SLAPrint.cpp.orig	2021-07-16 10:14:03.000000000 +0000
++++ src/libslic3r/SLAPrint.cpp
+@@ -19,8 +19,6 @@
+ #include <libnest2d/tools/benchmark.h>
+ #endif
+ 
+-//#include <tbb/spin_mutex.h>//#include "tbb/mutex.h"
+-
+ #include "I18N.hpp"
+ 
+ //! macro used to mark string used at localization,
+@@ -118,7 +116,7 @@ bool validate_pad(const TriangleMesh &pa
+ 
+ void SLAPrint::clear()
+ {
+-    tbb::mutex::scoped_lock lock(this->state_mutex());
++    std::lock_guard<std::mutex> lock(this->state_mutex());
+     // The following call should stop background processing if it is running.
+     this->invalidate_all_steps();
+     for (SLAPrintObject *object : m_objects)
+@@ -212,7 +210,7 @@ SLAPrint::ApplyStatus SLAPrint::apply(co
+         update_apply_status(false);
+ 
+     // Grab the lock for the Print / PrintObject milestones.
+-    tbb::mutex::scoped_lock lock(this->state_mutex());
++    std::lock_guard<std::mutex> lock(this->state_mutex());
+ 
+     // The following call may stop the background processing.
+     bool invalidate_all_model_objects = false;
+@@ -514,7 +512,7 @@ SLAPrint::ApplyStatus SLAPrint::apply(co
+ void SLAPrint::set_task(const TaskParams &params)
+ {
+     // Grab the lock for the Print / PrintObject milestones.
+-    tbb::mutex::scoped_lock lock(this->state_mutex());
++    std::lock_guard<std::mutex> lock(this->state_mutex());
+ 
+     int n_object_steps = int(params.to_object_step) + 1;
+     if (n_object_steps == 0)
+@@ -884,7 +882,7 @@ bool SLAPrint::is_step_done(SLAPrintObje
+ {
+     if (m_objects.empty())
+         return false;
+-    tbb::mutex::scoped_lock lock(this->state_mutex());
++    std::lock_guard<std::mutex> lock(this->state_mutex());
+     for (const SLAPrintObject *object : m_objects)
+         if (! object->is_step_done_unguarded(step))
+             return false;
diff --git a/prusaslicer/patches/patch-src_libslic3r_SLA_Concurrency.hpp b/prusaslicer/patches/patch-src_libslic3r_SLA_Concurrency.hpp
new file mode 100644
index 0000000000..de482d3f49
--- /dev/null
+++ b/prusaslicer/patches/patch-src_libslic3r_SLA_Concurrency.hpp
@@ -0,0 +1,23 @@
+$NetBSD$
+
+Migrate from deprecated tbb::mutex to std::mutex.
+
+--- src/libslic3r/SLA/Concurrency.hpp.orig	2021-07-16 10:14:03.000000000 +0000
++++ src/libslic3r/SLA/Concurrency.hpp
+@@ -2,7 +2,6 @@
+ #define SLA_CONCURRENCY_H
+ 
+ #include <tbb/spin_mutex.h>
+-#include <tbb/mutex.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/parallel_reduce.h>
+ 
+@@ -23,7 +22,7 @@ template<bool> struct _ccr {};
+ template<> struct _ccr<true>
+ {
+     using SpinningMutex = tbb::spin_mutex;
+-    using BlockingMutex = tbb::mutex;
++    using BlockingMutex = std::mutex;
+ 
+     template<class Fn, class It>
+     static IteratorOnly<It, void> loop_(const tbb::blocked_range<It> &range, Fn &&fn)
diff --git a/prusaslicer/patches/patch-src_libslic3r_SLA_SupportTree.cpp b/prusaslicer/patches/patch-src_libslic3r_SLA_SupportTree.cpp
new file mode 100644
index 0000000000..7fb3c2f422
--- /dev/null
+++ b/prusaslicer/patches/patch-src_libslic3r_SLA_SupportTree.cpp
@@ -0,0 +1,14 @@
+$NetBSD$
+
+Migrate from deprecated tbb::mutex to std::mutex.
+
+--- src/libslic3r/SLA/SupportTree.cpp.orig	2021-07-16 10:14:03.000000000 +0000
++++ src/libslic3r/SLA/SupportTree.cpp
+@@ -17,7 +17,6 @@
+ #include <libnest2d/optimizers/nlopt/subplex.hpp>
+ #include <boost/log/trivial.hpp>
+ #include <tbb/parallel_for.h>
+-#include <tbb/mutex.h>
+ #include <tbb/spin_mutex.h>
+ #include <libslic3r/I18N.hpp>
+ 
diff --git a/prusaslicer/patches/patch-src_libslic3r_SupportMaterial.cpp b/prusaslicer/patches/patch-src_libslic3r_SupportMaterial.cpp
new file mode 100644
index 0000000000..a1672c8fe8
--- /dev/null
+++ b/prusaslicer/patches/patch-src_libslic3r_SupportMaterial.cpp
@@ -0,0 +1,14 @@
+$NetBSD$
+
+Migrate from deprecated tbb::atomic to std::atomic.
+
+--- src/libslic3r/SupportMaterial.cpp.orig	2021-07-16 10:14:03.000000000 +0000
++++ src/libslic3r/SupportMaterial.cpp
+@@ -12,7 +12,6 @@
+ #include <boost/log/trivial.hpp>
+ 
+ #include <tbb/parallel_for.h>
+-#include <tbb/atomic.h>
+ #include <tbb/spin_mutex.h>
+ #include <tbb/task_group.h>
+ 
diff --git a/prusaslicer/patches/patch-src_libslic3r_Thread.cpp b/prusaslicer/patches/patch-src_libslic3r_Thread.cpp
index b5b0b8dcaa..ae8bd8c75c 100644
--- a/prusaslicer/patches/patch-src_libslic3r_Thread.cpp
+++ b/prusaslicer/patches/patch-src_libslic3r_Thread.cpp
@@ -1,29 +1,77 @@
 $NetBSD$
 
-pthread_setname_np takes 3 arguments.
+pthread_setname_np takes 3 arguments on NetBSD.
+Remove use of deprecated tbb::task_scheduler_init, tbb::thread.
 
---- src/libslic3r/Thread.cpp.orig	2021-01-11 13:01:51.000000000 +0000
+--- src/libslic3r/Thread.cpp.orig	2021-07-16 10:14:03.000000000 +0000
 +++ src/libslic3r/Thread.cpp
-@@ -161,19 +161,19 @@ std::optional<std::string> get_current_t
+@@ -9,10 +9,9 @@
+ #include <atomic>
+ #include <condition_variable>
+ #include <mutex>
++#include <tbb/global_control.h>
+ #include <tbb/parallel_for.h>
+-#include <tbb/tbb_thread.h>
+ #include <tbb/task_arena.h>
+-#include <tbb/task_scheduler_init.h>
+ 
+ #include "Thread.hpp"
+ 
+@@ -161,19 +160,31 @@ std::optional<std::string> get_current_t
  // posix
  bool set_thread_name(std::thread &thread, const char *thread_name)
  {
--   	pthread_setname_np(thread.native_handle(), thread_name);
++#ifdef __NetBSD__
 +   	pthread_setname_np(thread.native_handle(), thread_name, nullptr);
++#else
+    	pthread_setname_np(thread.native_handle(), thread_name);
++#endif
  	return true;
  }
  
  bool set_thread_name(boost::thread &thread, const char *thread_name)
  {
--   	pthread_setname_np(thread.native_handle(), thread_name);
++#ifdef __NetBSD__
 +   	pthread_setname_np(thread.native_handle(), thread_name, nullptr);
++#else
+    	pthread_setname_np(thread.native_handle(), thread_name);
++#endif
  	return true;
  }
  
  bool set_current_thread_name(const char *thread_name)
  {
--	pthread_setname_np(pthread_self(), thread_name);
++#ifdef __NetBSD__
 +	pthread_setname_np(pthread_self(), thread_name, nullptr);
++#else
+ 	pthread_setname_np(pthread_self(), thread_name);
++#endif
  	return true;
  }
  
+@@ -206,13 +217,14 @@ void name_tbb_thread_pool_threads()
+ 	nthreads = 1;
+ #endif
+ 
++	static tbb::global_control *tbb_global = nullptr;
+ 	if (nthreads != nthreads_hw) 
+-		new tbb::task_scheduler_init(int(nthreads));
++		tbb_global = new tbb::global_control(tbb::global_control::max_allowed_parallelism, nthreads);
+ 
+ 	std::atomic<size_t>		nthreads_running(0);
+ 	std::condition_variable cv;
+ 	std::mutex				cv_m;
+-	auto					master_thread_id = tbb::this_tbb_thread::get_id();
++	auto					master_thread_id = std::this_thread::get_id();
+     tbb::parallel_for(
+         tbb::blocked_range<size_t>(0, nthreads, 1),
+         [&nthreads_running, nthreads, &master_thread_id, &cv, &cv_m](const tbb::blocked_range<size_t> &range) {
+@@ -226,7 +238,7 @@ void name_tbb_thread_pool_threads()
+ 				std::unique_lock<std::mutex> lk(cv_m);
+ 			    cv.wait(lk, [&nthreads_running, nthreads]{return nthreads_running == nthreads;});
+         	}
+-        	auto thread_id = tbb::this_tbb_thread::get_id();
++        	auto thread_id = std::this_thread::get_id();
+ 			if (thread_id == master_thread_id) {
+ 				// The calling thread runs the 0'th task.
+ 				assert(range.begin() == 0);
diff --git a/prusaslicer/patches/patch-src_libslic3r_pchheader.hpp b/prusaslicer/patches/patch-src_libslic3r_pchheader.hpp
new file mode 100644
index 0000000000..55c993a360
--- /dev/null
+++ b/prusaslicer/patches/patch-src_libslic3r_pchheader.hpp
@@ -0,0 +1,19 @@
+$NetBSD$
+
+Remove use of deprecated tbb::atomic, tbb::mutex, tbb::task_scheduler_init.
+
+--- src/libslic3r/pchheader.hpp.orig	2021-07-16 10:14:03.000000000 +0000
++++ src/libslic3r/pchheader.hpp
+@@ -93,12 +93,9 @@
+ #include <boost/thread.hpp>
+ #include <boost/version.hpp>
+ 
+-#include <tbb/atomic.h>
+ #include <tbb/parallel_for.h>
+ #include <tbb/spin_mutex.h>
+-#include <tbb/mutex.h>
+ #include <tbb/task_group.h>
+-#include <tbb/task_scheduler_init.h>
+ 
+ #include <Eigen/Dense>
+ #include <Eigen/Geometry>
diff --git a/prusaslicer/patches/patch-src_libslic3r_utils.cpp b/prusaslicer/patches/patch-src_libslic3r_utils.cpp
new file mode 100644
index 0000000000..e733bcefa4
--- /dev/null
+++ b/prusaslicer/patches/patch-src_libslic3r_utils.cpp
@@ -0,0 +1,28 @@
+$NetBSD$
+
+Remove use of deprecated tbb::task_scheduler_init.
+
+--- src/libslic3r/utils.cpp.orig	2021-07-16 10:14:03.000000000 +0000
++++ src/libslic3r/utils.cpp
+@@ -43,7 +43,7 @@
+ #include <boost/nowide/convert.hpp>
+ #include <boost/nowide/cstdio.hpp>
+ 
+-#include <tbb/task_scheduler_init.h>
++#include <tbb/global_control.h>
+ 
+ #if defined(__linux__) || defined(__GNUC__ )
+ #include <strings.h>
+@@ -118,9 +118,9 @@ void trace(unsigned int level, const cha
+ void disable_multi_threading()
+ {
+     // Disable parallelization so the Shiny profiler works
+-    static tbb::task_scheduler_init *tbb_init = nullptr;
+-    if (tbb_init == nullptr)
+-        tbb_init = new tbb::task_scheduler_init(1);
++    static tbb::global_control *tbb_global = nullptr;
++    if (tbb_global == nullptr)
++        tbb_global = new tbb::global_control(tbb::global_control::max_allowed_parallelism, 1);
+ }
+ 
+ static std::string g_var_dir;
diff --git a/prusaslicer/patches/patch-src_slic3r_GUI_BackgroundSlicingProcess.cpp b/prusaslicer/patches/patch-src_slic3r_GUI_BackgroundSlicingProcess.cpp
new file mode 100644
index 0000000000..9c311c487a
--- /dev/null
+++ b/prusaslicer/patches/patch-src_slic3r_GUI_BackgroundSlicingProcess.cpp
@@ -0,0 +1,33 @@
+$NetBSD$
+
+Migrate from deprecated tbb::mutex to std::mutex.
+
+--- src/slic3r/GUI/BackgroundSlicingProcess.cpp.orig	2021-07-16 10:14:03.000000000 +0000
++++ src/slic3r/GUI/BackgroundSlicingProcess.cpp
+@@ -465,7 +465,7 @@ void BackgroundSlicingProcess::schedule_
+ 		return;
+ 
+ 	// Guard against entering the export step before changing the export path.
+-	tbb::mutex::scoped_lock lock(m_print->state_mutex());
++	std::lock_guard<std::mutex> lock(m_print->state_mutex());
+ 	this->invalidate_step(bspsGCodeFinalize);
+ 	m_export_path = path;
+ 	m_export_path_on_removable_media = export_path_on_removable_media;
+@@ -478,7 +478,7 @@ void BackgroundSlicingProcess::schedule_
+ 		return;
+ 
+ 	// Guard against entering the export step before changing the export path.
+-	tbb::mutex::scoped_lock lock(m_print->state_mutex());
++	std::lock_guard<std::mutex> lock(m_print->state_mutex());
+ 	this->invalidate_step(bspsGCodeFinalize);
+ 	m_export_path.clear();
+ 	m_upload_job = std::move(upload_job);
+@@ -491,7 +491,7 @@ void BackgroundSlicingProcess::reset_exp
+ 		m_export_path.clear();
+ 		m_export_path_on_removable_media = false;
+ 		// invalidate_step expects the mutex to be locked.
+-		tbb::mutex::scoped_lock lock(m_print->state_mutex());
++		std::lock_guard<std::mutex> lock(m_print->state_mutex());
+ 		this->invalidate_step(bspsGCodeFinalize);
+ 	}
+ }
diff --git a/prusaslicer/patches/patch-src_slic3r_GUI_BackgroundSlicingProcess.hpp b/prusaslicer/patches/patch-src_slic3r_GUI_BackgroundSlicingProcess.hpp
new file mode 100644
index 0000000000..1562849baa
--- /dev/null
+++ b/prusaslicer/patches/patch-src_slic3r_GUI_BackgroundSlicingProcess.hpp
@@ -0,0 +1,15 @@
+$NetBSD$
+
+Migrate from deprecated tbb::mutex to std::mutex.
+
+--- src/slic3r/GUI/BackgroundSlicingProcess.hpp.orig	2021-07-16 10:14:03.000000000 +0000
++++ src/slic3r/GUI/BackgroundSlicingProcess.hpp
+@@ -213,7 +213,7 @@ private:
+ 	State 						m_state = STATE_INITIAL;
+ 
+     PrintState<BackgroundSlicingProcessStep, bspsCount>   	m_step_state;
+-    mutable tbb::mutex                      				m_step_state_mutex;
++    mutable std::mutex                      				m_step_state_mutex;
+ 	bool                set_step_started(BackgroundSlicingProcessStep step);
+ 	void                set_step_done(BackgroundSlicingProcessStep step);
+ 	bool 				is_step_done(BackgroundSlicingProcessStep step) const;
diff --git a/prusaslicer/patches/patch-src_slic3r_GUI_InstanceCheck.hpp b/prusaslicer/patches/patch-src_slic3r_GUI_InstanceCheck.hpp
new file mode 100644
index 0000000000..39fac50e7a
--- /dev/null
+++ b/prusaslicer/patches/patch-src_slic3r_GUI_InstanceCheck.hpp
@@ -0,0 +1,14 @@
+$NetBSD$
+
+Remove use of deprecated tbb::mutex.
+
+--- src/slic3r/GUI/InstanceCheck.hpp.orig	2021-07-16 10:14:03.000000000 +0000
++++ src/slic3r/GUI/InstanceCheck.hpp
+@@ -13,7 +13,6 @@
+ 
+ #if __linux__
+ #include <boost/thread.hpp>
+-#include <tbb/mutex.h>
+ #include <condition_variable>
+ #endif // __linux__
+ 
diff --git a/prusaslicer/patches/patch-src_slic3r_GUI_Mouse3DController.cpp b/prusaslicer/patches/patch-src_slic3r_GUI_Mouse3DController.cpp
new file mode 100644
index 0000000000..6663041ac7
--- /dev/null
+++ b/prusaslicer/patches/patch-src_slic3r_GUI_Mouse3DController.cpp
@@ -0,0 +1,150 @@
+$NetBSD$
+
+Migrate from deprecated tbb::mutex to std::mutex.
+
+--- src/slic3r/GUI/Mouse3DController.cpp.orig	2021-07-16 10:14:03.000000000 +0000
++++ src/slic3r/GUI/Mouse3DController.cpp
+@@ -66,7 +66,7 @@ void update_maximum(std::atomic<T>& maxi
+ 
+ void Mouse3DController::State::append_translation(const Vec3d& translation, size_t input_queue_max_size)
+ {
+-	tbb::mutex::scoped_lock lock(m_input_queue_mutex);
++	std::lock_guard<std::mutex> lock(m_input_queue_mutex);
+     while (m_input_queue.size() >= input_queue_max_size)
+         m_input_queue.pop_front();
+     m_input_queue.emplace_back(QueueItem::translation(translation));
+@@ -77,7 +77,7 @@ void Mouse3DController::State::append_tr
+ 
+ void Mouse3DController::State::append_rotation(const Vec3f& rotation, size_t input_queue_max_size)
+ {
+-	tbb::mutex::scoped_lock lock(m_input_queue_mutex);
++	std::lock_guard<std::mutex> lock(m_input_queue_mutex);
+     while (m_input_queue.size() >= input_queue_max_size)
+         m_input_queue.pop_front();
+     m_input_queue.emplace_back(QueueItem::rotation(rotation.cast<double>()));
+@@ -92,7 +92,7 @@ void Mouse3DController::State::append_ro
+ 
+ void Mouse3DController::State::append_button(unsigned int id, size_t /* input_queue_max_size */)
+ {
+-	tbb::mutex::scoped_lock lock(m_input_queue_mutex);
++	std::lock_guard<std::mutex> lock(m_input_queue_mutex);
+     m_input_queue.emplace_back(QueueItem::buttons(id));
+ #if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
+     update_maximum(input_queue_max_size_achieved, m_input_queue.size());
+@@ -277,7 +277,7 @@ void Mouse3DController::device_attached(
+ #if ENABLE_CTRL_M_ON_WINDOWS
+             m_device_str = format_device_string(vid, pid);
+             if (auto it_params = m_params_by_device.find(m_device_str); it_params != m_params_by_device.end()) {
+-                tbb::mutex::scoped_lock lock(m_params_ui_mutex);
++                std::lock_guard<std::mutex> lock(m_params_ui_mutex);
+                 m_params = m_params_ui = it_params->second;
+             }
+             else
+@@ -295,7 +295,7 @@ void Mouse3DController::device_detached(
+     int pid = 0;
+     if (sscanf(device.c_str(), "\\\\?\\HID#VID_%x&PID_%x&", &vid, &pid) == 2) {
+         if (std::find(_3DCONNEXION_VENDORS.begin(), _3DCONNEXION_VENDORS.end(), vid) != _3DCONNEXION_VENDORS.end()) {
+-            tbb::mutex::scoped_lock lock(m_params_ui_mutex);
++            std::lock_guard<std::mutex> lock(m_params_ui_mutex);
+             m_params_by_device[format_device_string(vid, pid)] = m_params_ui;
+         }
+     }
+@@ -307,7 +307,7 @@ void Mouse3DController::device_detached(
+ // Filter out mouse scroll events produced by the 3DConnexion driver.
+ bool Mouse3DController::State::process_mouse_wheel()
+ {
+-	tbb::mutex::scoped_lock lock(m_input_queue_mutex);
++	std::lock_guard<std::mutex> lock(m_input_queue_mutex);
+ 	if (m_mouse_wheel_counter == 0)
+     	// No 3DConnexion rotation has been captured since the last mouse scroll event.
+         return false;
+@@ -329,7 +329,7 @@ bool Mouse3DController::State::apply(con
+     std::deque<QueueItem> input_queue;
+     {
+     	// Atomically move m_input_queue to input_queue.
+-    	tbb::mutex::scoped_lock lock(m_input_queue_mutex);
++    	std::lock_guard<std::mutex> lock(m_input_queue_mutex);
+     	input_queue = std::move(m_input_queue);
+         m_input_queue.clear();
+     }
+@@ -418,7 +418,7 @@ bool Mouse3DController::apply(Camera& ca
+ #if ENABLE_CTRL_M_ON_WINDOWS
+ #ifdef _WIN32
+     {
+-        tbb::mutex::scoped_lock lock(m_params_ui_mutex);
++        std::lock_guard<std::mutex> lock(m_params_ui_mutex);
+         if (m_params_ui_changed) {
+             m_params = m_params_ui;
+             m_params_ui_changed = false;
+@@ -447,7 +447,7 @@ void Mouse3DController::render_settings_
+     Params params_copy;
+     bool   params_changed = false;
+     {
+-    	tbb::mutex::scoped_lock lock(m_params_ui_mutex);
++    	std::lock_guard<std::mutex> lock(m_params_ui_mutex);
+     	params_copy = m_params_ui;
+     }
+ 
+@@ -565,7 +565,7 @@ void Mouse3DController::render_settings_
+ 
+     if (params_changed) {
+         // Synchronize front end parameters to back end.
+-    	tbb::mutex::scoped_lock lock(m_params_ui_mutex);
++    	std::lock_guard<std::mutex> lock(m_params_ui_mutex);
+         auto pthis = const_cast<Mouse3DController*>(this);
+ #if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
+         if (params_copy.input_queue_max_size != params_copy.input_queue_max_size)
+@@ -586,7 +586,7 @@ void Mouse3DController::connected(std::s
+ 	m_device_str = device_name;
+     // Copy the parameters for m_device_str into the current parameters.
+     if (auto it_params = m_params_by_device.find(m_device_str); it_params != m_params_by_device.end()) {
+-    	tbb::mutex::scoped_lock lock(m_params_ui_mutex);
++    	std::lock_guard<std::mutex> lock(m_params_ui_mutex);
+     	m_params = m_params_ui = it_params->second;
+     }
+     m_connected = true;
+@@ -597,7 +597,7 @@ void Mouse3DController::disconnected()
+     // Copy the current parameters for m_device_str into the parameter database.
+     assert(m_connected == ! m_device_str.empty());
+     if (m_connected) {
+-        tbb::mutex::scoped_lock lock(m_params_ui_mutex);
++        std::lock_guard<std::mutex> lock(m_params_ui_mutex);
+         m_params_by_device[m_device_str] = m_params_ui;
+ 	    m_device_str.clear();
+ 	    m_connected = false;
+@@ -621,7 +621,7 @@ bool Mouse3DController::handle_input(con
+     {
+     	// Synchronize parameters between the UI thread and the background thread.
+     	//FIXME is this necessary on OSX? Are these notifications triggered from the main thread or from a worker thread?
+-    	tbb::mutex::scoped_lock lock(m_params_ui_mutex);
++    	std::lock_guard<std::mutex> lock(m_params_ui_mutex);
+     	if (m_params_ui_changed) {
+     		m_params = m_params_ui;
+     		m_params_ui_changed = false;
+@@ -733,7 +733,7 @@ void Mouse3DController::run()
+ 
+     for (;;) {
+         {
+-        	tbb::mutex::scoped_lock lock(m_params_ui_mutex);
++        	std::lock_guard<std::mutex> lock(m_params_ui_mutex);
+         	if (m_stop)
+         		break;
+         	if (m_params_ui_changed) {
+@@ -998,7 +998,7 @@ bool Mouse3DController::connect_device()
+ #endif // ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
+         // Copy the parameters for m_device_str into the current parameters.
+         if (auto it_params = m_params_by_device.find(m_device_str); it_params != m_params_by_device.end()) {
+-	    	tbb::mutex::scoped_lock lock(m_params_ui_mutex);
++	    	std::lock_guard<std::mutex> lock(m_params_ui_mutex);
+ 	    	m_params = m_params_ui = it_params->second;
+ 	    }
+     }
+@@ -1023,7 +1023,7 @@ void Mouse3DController::disconnect_devic
+ 	    BOOST_LOG_TRIVIAL(info) << "Disconnected device: " << m_device_str;
+         // Copy the current parameters for m_device_str into the parameter database.
+         {
+-	        tbb::mutex::scoped_lock lock(m_params_ui_mutex);
++	        std::lock_guard<std::mutex> lock(m_params_ui_mutex);
+ 	        m_params_by_device[m_device_str] = m_params_ui;
+ 	    }
+ 	    m_device_str.clear();
diff --git a/prusaslicer/patches/patch-src_slic3r_GUI_Mouse3DController.hpp b/prusaslicer/patches/patch-src_slic3r_GUI_Mouse3DController.hpp
index 1f3236abbc..b8f95c7b67 100644
--- a/prusaslicer/patches/patch-src_slic3r_GUI_Mouse3DController.hpp
+++ b/prusaslicer/patches/patch-src_slic3r_GUI_Mouse3DController.hpp
@@ -1,8 +1,9 @@
 $NetBSD$
 
 pkgsrc hidapi.h is one level deeper than builtin.
+Migrate from deprecated tbb::mutex to std::mutex.
 
---- src/slic3r/GUI/Mouse3DController.hpp.orig	2021-01-11 13:01:51.000000000 +0000
+--- src/slic3r/GUI/Mouse3DController.hpp.orig	2021-07-16 10:14:03.000000000 +0000
 +++ src/slic3r/GUI/Mouse3DController.hpp
 @@ -6,7 +6,7 @@
  
@@ -13,3 +14,45 @@ pkgsrc hidapi.h is one level deeper than builtin.
  
  #include <queue>
  #include <atomic>
+@@ -15,8 +15,6 @@
+ #include <chrono>
+ #include <condition_variable>
+ 
+-#include <tbb/mutex.h>
+-
+ namespace Slic3r {
+ 
+ class AppConfig;
+@@ -85,7 +83,7 @@ class Mouse3DController
+     	// m_input_queue is accessed by the background thread and by the UI thread. Access to m_input_queue
+     	// is guarded with m_input_queue_mutex.
+         std::deque<QueueItem> m_input_queue;
+-        mutable tbb::mutex	  m_input_queue_mutex;
++        mutable std::mutex	  m_input_queue_mutex;
+ 
+ #ifdef WIN32
+         // When the 3Dconnexion driver is running the system gets, by default, mouse wheel events when rotations around the X axis are detected.
+@@ -112,12 +110,12 @@ class Mouse3DController
+ 
+ #if ENABLE_3DCONNEXION_DEVICES_DEBUG_OUTPUT
+         Vec3d               get_first_vector_of_type(unsigned int type) const {
+-            tbb::mutex::scoped_lock lock(m_input_queue_mutex);
++            std::lock_guard<std::mutex> lock(m_input_queue_mutex);
+             auto it = std::find_if(m_input_queue.begin(), m_input_queue.end(), [type](const QueueItem& item) { return item.type_or_buttons == type; });
+             return (it == m_input_queue.end()) ? Vec3d::Zero() : it->vector;
+         }
+         size_t              input_queue_size_current() const { 
+-        	tbb::mutex::scoped_lock lock(m_input_queue_mutex); 
++        	std::lock_guard<std::mutex> lock(m_input_queue_mutex); 
+         	return m_input_queue.size(); 
+         }
+         std::atomic<size_t> input_queue_max_size_achieved;
+@@ -133,7 +131,7 @@ class Mouse3DController
+     // UI thread will read / write this copy.
+     Params 				m_params_ui;
+     bool 	            m_params_ui_changed { false };
+-    mutable tbb::mutex	m_params_ui_mutex;
++    mutable std::mutex	m_params_ui_mutex;
+ 
+     // This is a database of parametes of all 3DConnexion devices ever connected.
+     // This database is loaded from AppConfig on application start and it is stored to AppConfig on application exit.
diff --git a/prusaslicer/patches/patch-src_slic3r_GUI_RemovableDriveManager.cpp b/prusaslicer/patches/patch-src_slic3r_GUI_RemovableDriveManager.cpp
new file mode 100644
index 0000000000..c8433142b8
--- /dev/null
+++ b/prusaslicer/patches/patch-src_slic3r_GUI_RemovableDriveManager.cpp
@@ -0,0 +1,109 @@
+$NetBSD$
+
+Migrate from deprecated tbb::mutex to std::mutex.
+
+--- src/slic3r/GUI/RemovableDriveManager.cpp.orig	2021-07-16 10:14:03.000000000 +0000
++++ src/slic3r/GUI/RemovableDriveManager.cpp
+@@ -84,7 +84,7 @@ void RemovableDriveManager::eject_drive(
+ 	this->update();
+ #endif // REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
+ 	BOOST_LOG_TRIVIAL(info) << "Ejecting started"; 
+-	tbb::mutex::scoped_lock lock(m_drives_mutex);
++	std::lock_guard<std::mutex> lock(m_drives_mutex);
+ 	auto it_drive_data = this->find_last_save_path_drive_data();
+ 	if (it_drive_data != m_current_drives.end()) {
+ 		// get handle to device
+@@ -130,7 +130,7 @@ std::string RemovableDriveManager::get_r
+ 	this->update();
+ #endif // REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
+ 
+-	tbb::mutex::scoped_lock lock(m_drives_mutex);
++	std::lock_guard<std::mutex> lock(m_drives_mutex);
+ 	if (m_current_drives.empty())
+ 		return std::string();
+ 	std::size_t found = path.find_last_of("\\");
+@@ -146,7 +146,7 @@ std::string RemovableDriveManager::get_r
+ 
+ std::string RemovableDriveManager::get_removable_drive_from_path(const std::string& path)
+ {
+-	tbb::mutex::scoped_lock lock(m_drives_mutex);
++	std::lock_guard<std::mutex> lock(m_drives_mutex);
+ 	std::size_t found = path.find_last_of("\\");
+ 	std::string new_path = path.substr(0, found);
+ 	int letter = PathGetDriveNumberW(boost::nowide::widen(new_path).c_str());	
+@@ -285,7 +285,7 @@ void RemovableDriveManager::eject_drive(
+ 
+ 	DriveData drive_data;
+ 	{
+-		tbb::mutex::scoped_lock lock(m_drives_mutex);
++		std::lock_guard<std::mutex> lock(m_drives_mutex);
+ 		auto it_drive_data = this->find_last_save_path_drive_data();
+ 		if (it_drive_data == m_current_drives.end())
+ 			return;
+@@ -341,7 +341,7 @@ void RemovableDriveManager::eject_drive(
+ 		if (success) {
+ 			// Remove the drive_data from m_current drives, searching by value, not by pointer, as m_current_drives may get modified during
+ 			// asynchronous execution on m_eject_thread.
+-			tbb::mutex::scoped_lock lock(m_drives_mutex);
++			std::lock_guard<std::mutex> lock(m_drives_mutex);
+ 			auto it = std::find(m_current_drives.begin(), m_current_drives.end(), drive_data);
+ 			if (it != m_current_drives.end())
+ 				m_current_drives.erase(it);
+@@ -361,7 +361,7 @@ std::string RemovableDriveManager::get_r
+ 	std::size_t found = path.find_last_of("/");
+ 	std::string new_path = found == path.size() - 1 ? path.substr(0, found) : path;
+ 
+-	tbb::mutex::scoped_lock lock(m_drives_mutex);
++	std::lock_guard<std::mutex> lock(m_drives_mutex);
+ 	for (const DriveData &data : m_current_drives)
+ 		if (search_for_drives_internal::compare_filesystem_id(new_path, data.path))
+ 			return path;
+@@ -377,7 +377,7 @@ std::string RemovableDriveManager::get_r
+     new_path = new_path.substr(0, found);
+     
+ 	// check if same filesystem
+-	tbb::mutex::scoped_lock lock(m_drives_mutex);
++	std::lock_guard<std::mutex> lock(m_drives_mutex);
+ 	for (const DriveData &drive_data : m_current_drives)
+ 		if (search_for_drives_internal::compare_filesystem_id(new_path, drive_data.path))
+ 			return drive_data.path;
+@@ -452,7 +452,7 @@ RemovableDriveManager::RemovableDrivesSt
+ 
+ 	RemovableDriveManager::RemovableDrivesStatus out;
+ 	{
+-		tbb::mutex::scoped_lock lock(m_drives_mutex);
++		std::lock_guard<std::mutex> lock(m_drives_mutex);
+ 		out.has_eject = 
+ 			// Cannot control eject on Chromium.
+ 			platform_flavor() != PlatformFlavor::LinuxOnChromium &&
+@@ -468,17 +468,16 @@ RemovableDriveManager::RemovableDrivesSt
+ // Update is called from thread_proc() and from most of the public methods on demand.
+ void RemovableDriveManager::update()
+ {
+-	tbb::mutex::scoped_lock inside_update_lock;
+ #ifdef _WIN32
+ 	// All wake up calls up to now are now consumed when the drive enumeration starts.
+ 	m_wakeup = false;
+ #endif // _WIN32
+-	if (inside_update_lock.try_acquire(m_inside_update_mutex)) {
++	if (m_inside_update_mutex.try_lock()) {
+ 		// Got the lock without waiting. That means, the update was not running.
+ 		// Run the update.
+ 		std::vector<DriveData> current_drives = this->search_for_removable_drives();
+ 		// Post update events.
+-		tbb::mutex::scoped_lock lock(m_drives_mutex);
++		std::lock_guard<std::mutex> lock(m_drives_mutex);
+ 		std::sort(current_drives.begin(), current_drives.end());
+ 		if (current_drives != m_current_drives) {
+ 			assert(m_callback_evt_handler);
+@@ -489,8 +488,9 @@ void RemovableDriveManager::update()
+ 	} else {
+ 		// Acquiring the m_iniside_update lock failed, therefore another update is running.
+ 		// Just block until the other instance of update() finishes.
+-		inside_update_lock.acquire(m_inside_update_mutex);
++	        m_inside_update_mutex.lock();
+ 	}
++	m_inside_update_mutex.unlock();
+ }
+ 
+ #ifndef REMOVABLE_DRIVE_MANAGER_OS_CALLBACKS
diff --git a/prusaslicer/patches/patch-src_slic3r_GUI_RemovableDriveManager.hpp b/prusaslicer/patches/patch-src_slic3r_GUI_RemovableDriveManager.hpp
new file mode 100644
index 0000000000..01ab6e6947
--- /dev/null
+++ b/prusaslicer/patches/patch-src_slic3r_GUI_RemovableDriveManager.hpp
@@ -0,0 +1,26 @@
+$NetBSD$
+
+Migrate from deprecated tbb::mutex to std::mutex.
+
+--- src/slic3r/GUI/RemovableDriveManager.hpp.orig	2021-07-16 10:14:03.000000000 +0000
++++ src/slic3r/GUI/RemovableDriveManager.hpp
+@@ -5,7 +5,6 @@
+ #include <string>
+ 
+ #include <boost/thread.hpp>
+-#include <tbb/mutex.h>
+ #include <condition_variable>
+ 
+ // Custom wxWidget events
+@@ -111,9 +110,9 @@ private:
+ 	// m_current_drives is guarded by m_drives_mutex
+ 	// sorted ascending by path
+ 	std::vector<DriveData> 	m_current_drives;
+-	mutable tbb::mutex 		m_drives_mutex;
++	mutable std::mutex 		m_drives_mutex;
+ 	// Locking the update() function to avoid that the function is executed multiple times.
+-	mutable tbb::mutex 		m_inside_update_mutex;
++	mutable std::mutex 		m_inside_update_mutex;
+ 
+ 	// Returns drive path (same as path in DriveData) if exists otherwise empty string.
+ 	std::string 			get_removable_drive_from_path(const std::string& path);


Home | Main Index | Thread Index | Old Index