File 0004-Fix-OCCT.patch of Package SuperSlicer

From a696b0740c1dab49402771aaee198b4fc5e3fe48 Mon Sep 17 00:00:00 2001
From: Mia Herkt <mia@0x0.st>
Date: Tue, 17 Dec 2024 07:00:16 +0100
Subject: [PATCH 4/7] Fix OCCT

---
 src/libslic3r/Format/STEP.cpp   |  6 ++--
 src/occt_wrapper/CMakeLists.txt | 49 ++++++++++++++-------------------
 2 files changed, 23 insertions(+), 32 deletions(-)

diff --git a/src/libslic3r/Format/STEP.cpp b/src/libslic3r/Format/STEP.cpp
index 2dbb5ee4..327092b9 100644
--- a/src/libslic3r/Format/STEP.cpp
+++ b/src/libslic3r/Format/STEP.cpp
@@ -39,8 +39,8 @@ LoadStepFn get_load_step_fn()
 #endif
 
     if (!load_step_fn) {
-        auto libpath = boost::dll::program_location().parent_path();
 #ifdef _WIN32
+        auto libpath = boost::dll::program_location().parent_path();
         libpath /= "OCCTWrapper.dll";
         HMODULE module = LoadLibraryW(libpath.wstring().c_str());
         if (module == NULL)
@@ -61,8 +61,8 @@ LoadStepFn get_load_step_fn()
 #elif __APPLE__
         load_step_fn = &load_step_internal;
 #else
-        libpath /= "OCCTWrapper.so";
-        void *plugin_ptr = dlopen(libpath.c_str(), RTLD_NOW | RTLD_GLOBAL);
+        // This is installed into /usr/lib(64)/ and dlopen will search there.
+        void *plugin_ptr = dlopen("OCCTWrapper.so", RTLD_NOW | RTLD_GLOBAL);
 
         if (plugin_ptr) {
             load_step_fn = reinterpret_cast<LoadStepFn>(dlsym(plugin_ptr, fn_name));
diff --git a/src/occt_wrapper/CMakeLists.txt b/src/occt_wrapper/CMakeLists.txt
index 8ab9fb4b..9a33378f 100644
--- a/src/occt_wrapper/CMakeLists.txt
+++ b/src/occt_wrapper/CMakeLists.txt
@@ -19,35 +19,23 @@ include(GenerateExportHeader)
 
 generate_export_header(OCCTWrapper)
 
-find_package(OpenCASCADE 7.6.2 REQUIRED)
+find_package(OpenCASCADE REQUIRED)
+# OpenCASCADE has an exact version match even if you don't specify the EXACT
+# keyword in the find_package(). So lets implement it on our own.
+set(OPENCASCADE_MODULE_VERSION
+    "${OpenCASCADE_MAJOR_VERSION}.${OpenCASCADE_MINOR_VERSION}.${OpenCASCADE_MAINTENANCE_VERSION}")
+set(OPENCASCADE_REQUIRED_VERSION "7.8.0")
+if (${OPENCASCADE_MODULE_VERSION} VERSION_LESS ${OPENCASCADE_REQUIRED_VERSION})
+    message(
+        FATAL_ERROR
+        "Coun't find a compatible OpenCASCADE version - "
+        "required: ${OPENCASCADE_REQUIRED_VERSION}, found: "
+        "${OPENCASCADE_MODULE_VERSION}"
+    )
+endif()
 
 set(OCCT_LIBS
-    TKXDESTEP
-    TKSTEP
-    TKSTEP209
-    TKSTEPAttr
-    TKSTEPBase
-    TKXCAF
-    TKXSBase
-    TKVCAF
-    TKCAF
-    TKLCAF
-    TKCDF
-    TKV3d
-    TKService
-    TKMesh
-    TKBO
-    TKPrim
-    TKHLR
-    TKShHealing
-    TKTopAlgo
-    TKGeomAlgo
-    TKBRep
-    TKGeomBase
-    TKG3d
-    TKG2d
-    TKMath
-    TKernel
+    TKDESTEP
 )
 
 slic3r_remap_configs("${OCCT_LIBS}" RelWithDebInfo Release)
@@ -58,5 +46,8 @@ target_link_libraries(OCCTWrapper ${OCCT_LIBS})
 
 include(GNUInstallDirs)
 
-install(TARGETS OCCTWrapper DESTINATION "${CMAKE_INSTALL_BINDIR}")
-
+if (WIN32 OR APPLE)
+    install(TARGETS OCCTWrapper DESTINATION "${CMAKE_INSTALL_BINDIR}")
+else()
+    install(TARGETS OCCTWrapper DESTINATION "${CMAKE_INSTALL_LIBDIR}")
+endif()
-- 
2.47.1

openSUSE Build Service is sponsored by