From: stuff overlay maintainer
Subject: Use split OpenCV components instead of opencv_world

OrcaSlicer expects OpenCV built with -DBUILD_opencv_world=ON, but Gentoo
(and most distros) build per-module libraries. The libslic3r target uses
cv::cvtColor / cv::threshold / cv::imread (imgproc, imgcodecs) plus
cv::kmeans (core), so request and link those modules explicitly. Also
add OpenCV_INCLUDE_DIRS to libslic3r explicitly: on Gentoo OpenCV headers
live under /usr/include/opencv4 and bare-name target_link_libraries
entries do not propagate the imported targets INTERFACE include dirs to
every translation unit (ObjColorUtils.cpp).

--- a/src/libslic3r/CMakeLists.txt
+++ b/src/libslic3r/CMakeLists.txt
@@ -496,7 +496,7 @@
 cmake_policy(PUSH)
 cmake_policy(SET CMP0011 NEW)
 find_package(CGAL REQUIRED)
-find_package(OpenCV REQUIRED core)
+find_package(OpenCV REQUIRED core imgproc imgcodecs)
 cmake_policy(POP)
 
 add_library(libslic3r_cgal STATIC 
@@ -579,7 +579,9 @@
         libigl
         libnest2d
         miniz
-        opencv_world
+        opencv_core
+        opencv_imgproc
+        opencv_imgcodecs
     PRIVATE
         ${CMAKE_DL_LIBS}
         ${EXPAT_LIBRARIES}
@@ -604,6 +606,7 @@
         ZLIB::ZLIB
         OpenSSL::Crypto
     )
+target_include_directories(libslic3r SYSTEM PRIVATE ${OpenCV_INCLUDE_DIRS})
 
 if(NOT WIN32)
     # Link freetype for OCCT dependency (CAD operations need font rendering)
