File 0001-Drop-Imath2-support-and-modernize-Imath-includes.patch of Package opentimelineio

From b20b49b78f250414a8a2be9d49f8c444759561fb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Julius=20K=C3=BCnzel?=
 <78424983+jlskuz@users.noreply.github.com>
Date: Thu, 27 Mar 2025 18:10:53 +0100
Subject: [PATCH] Drop Imath2 support and modernize Imath includes (#1852)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* Drop support for Imath 2
* Port Imath includes to Imath/*.h
As suggested by Imath devs, see https://github.com/AcademySoftwareFoundation/Imath/issues/136#issuecomment-812671628
This is possible now that Imath 2 support was dropped

* Add find_dependency call for Imath to *Config.cmake
This will make it easier for downstream users
* Use global include_directories for internal Imath

---------

Signed-off-by: Julius Künzel <julius.kuenzel@kde.org>
---
 CMakeLists.txt                                | 28 ++++---------------
 src/opentimelineio/CMakeLists.txt             |  6 ++--
 .../OpenTimelineIOConfig.cmake.in             |  1 +
 src/opentimelineio/composable.h               |  2 +-
 src/opentimelineio/mediaReference.h           |  2 +-
 src/opentimelineio/serializableObject.h       |  2 +-
 .../opentimelineio-bindings/otio_imath.cpp    |  4 +--
 .../otio_serializableObjects.cpp              |  2 +-
 tests/CMakeLists.txt                          |  3 --
 9 files changed, 15 insertions(+), 35 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 36f6e27..a1a074f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -183,37 +183,22 @@ elseif(OTIO_FIND_IMATH)
         message(STATUS "Found Imath 3 at ${Imath_CONFIG}")
         set(USE_DEPS_IMATH OFF)
     else()
-        find_package(IlmBase QUIET)
-        if (IlmBase_FOUND)
-            message(STATUS "Imath 3 not found, found Imath 2 at ${IlmBase_CONFIG}")
-            message(STATUS "You may need to point to the Imath headers by setting IMATH_INCLUDES")
-            set(USE_DEPS_IMATH_OFF)
-            set(OTIO_RESOLVED_IMATH_LIBRARIES "${IlmBase_LIBRARIES")
-        else()
-            message(STATUS "Imath 3 and 2 were not found, using src/deps/Imath")
-            set(USE_DEPS_IMATH ON)
-        endif()
+        message(STATUS "Imath 3 was not found, using src/deps/Imath")
+        set(USE_DEPS_IMATH ON)
     endif()
 else()
     message(STATUS "Using src/deps/Imath by default")
     set(USE_DEPS_IMATH ON)
 endif()
 
+if(USE_DEPS_IMATH)
+    include_directories("${PROJECT_SOURCE_DIR}/src/deps/Imath/src")
+endif()
+
 # set up the internally hosted dependencies
 # add_subdirectory(src/deps)
 find_package(RapidJSON CONFIG REQUIRED)
 
-set (OTIO_IMATH_TARGETS
-    # For OpenEXR/Imath 3.x:
-    $<TARGET_NAME_IF_EXISTS:Imath::Imath>
-    $<TARGET_NAME_IF_EXISTS:Imath::Half>
-    # For OpenEXR >= 2.4/2.5 with reliable exported targets
-    $<TARGET_NAME_IF_EXISTS:IlmBase::Imath>
-    $<TARGET_NAME_IF_EXISTS:IlmBase::Half>
-    $<TARGET_NAME_IF_EXISTS:IlmBase::Iex>
-    # For OpenEXR <= 2.3:
-    ${ILMBASE_LIBRARIES})
-
 add_subdirectory(src/opentime)
 add_subdirectory(src/opentimelineio)
 
@@ -228,4 +213,3 @@ endif()
 if(OTIO_CXX_EXAMPLES)
     add_subdirectory(examples)
 endif()
-
diff --git a/src/opentimelineio/CMakeLists.txt b/src/opentimelineio/CMakeLists.txt
index 22828a6..ad1890b 100644
--- a/src/opentimelineio/CMakeLists.txt
+++ b/src/opentimelineio/CMakeLists.txt
@@ -78,13 +78,11 @@ add_library(opentimelineio ${OTIO_SHARED_OR_STATIC_LIB}
 add_library(OTIO::opentimelineio ALIAS opentimelineio)
 
 target_include_directories(opentimelineio
-    PRIVATE       "${IMATH_INCLUDES}"
-                  "${PROJECT_SOURCE_DIR}/src"
-                  "${IMATH_INCLUDES}"
+    PRIVATE       "${PROJECT_SOURCE_DIR}/src"
                   ${RapidJSON_INCLUDE_DIRS})
 
 target_link_libraries(opentimelineio 
-    PUBLIC opentime ${OTIO_IMATH_TARGETS})
+    PUBLIC opentime Imath::Imath)
 
 set_target_properties(opentimelineio PROPERTIES
     VERSION ${OTIO_VERSION}
diff --git a/src/opentimelineio/OpenTimelineIOConfig.cmake.in b/src/opentimelineio/OpenTimelineIOConfig.cmake.in
index f735b36..355f8ea 100644
--- a/src/opentimelineio/OpenTimelineIOConfig.cmake.in
+++ b/src/opentimelineio/OpenTimelineIOConfig.cmake.in
@@ -2,5 +2,6 @@
 
 include(CMakeFindDependencyMacro)
 find_dependency(OpenTime)
+find_dependency(Imath)
 
 include("${CMAKE_CURRENT_LIST_DIR}/OpenTimelineIOTargets.cmake")
diff --git a/src/opentimelineio/composable.h b/src/opentimelineio/composable.h
index d2691ff..4f63856 100644
--- a/src/opentimelineio/composable.h
+++ b/src/opentimelineio/composable.h
@@ -6,7 +6,7 @@
 #include "opentimelineio/serializableObjectWithMetadata.h"
 #include "opentimelineio/version.h"
 
-#include <ImathBox.h>
+#include <Imath/ImathBox.h>
 
 namespace opentimelineio { namespace OPENTIMELINEIO_VERSION {
 
diff --git a/src/opentimelineio/mediaReference.h b/src/opentimelineio/mediaReference.h
index f7fde5a..63fa70c 100644
--- a/src/opentimelineio/mediaReference.h
+++ b/src/opentimelineio/mediaReference.h
@@ -6,7 +6,7 @@
 #include "opentimelineio/serializableObjectWithMetadata.h"
 #include "opentimelineio/version.h"
 
-#include <ImathBox.h>
+#include <Imath/ImathBox.h>
 
 namespace opentimelineio { namespace OPENTIMELINEIO_VERSION {
 
diff --git a/src/opentimelineio/serializableObject.h b/src/opentimelineio/serializableObject.h
index 63ccc04..280706e 100644
--- a/src/opentimelineio/serializableObject.h
+++ b/src/opentimelineio/serializableObject.h
@@ -12,7 +12,7 @@
 #include "opentimelineio/typeRegistry.h"
 #include "opentimelineio/version.h"
 
-#include "ImathBox.h"
+#include "Imath/ImathBox.h"
 #include "serialization.h"
 
 #include <list>
diff --git a/src/py-opentimelineio/opentimelineio-bindings/otio_imath.cpp b/src/py-opentimelineio/opentimelineio-bindings/otio_imath.cpp
index 540025a..4cd5df2 100644
--- a/src/py-opentimelineio/opentimelineio-bindings/otio_imath.cpp
+++ b/src/py-opentimelineio/opentimelineio-bindings/otio_imath.cpp
@@ -6,8 +6,8 @@
 
 #include "otio_utils.h"
 
-#include "ImathBox.h"
-#include "ImathVec.h"
+#include "Imath/ImathBox.h"
+#include "Imath/ImathVec.h"
 
 namespace py = pybind11;
 
diff --git a/src/py-opentimelineio/opentimelineio-bindings/otio_serializableObjects.cpp b/src/py-opentimelineio/opentimelineio-bindings/otio_serializableObjects.cpp
index 290a70d..1bdd8c8 100644
--- a/src/py-opentimelineio/opentimelineio-bindings/otio_serializableObjects.cpp
+++ b/src/py-opentimelineio/opentimelineio-bindings/otio_serializableObjects.cpp
@@ -32,7 +32,7 @@
 #include "otio_utils.h"
 #include "otio_anyDictionary.h"
 
-#include "ImathBox.h"
+#include "Imath/ImathBox.h"
 
 namespace py = pybind11;
 using namespace pybind11::literals;
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 85cb216..a17de5c 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -20,9 +20,6 @@ foreach(test ${tests_opentimelineio})
     add_executable(${test} utils.h utils.cpp ${test}.cpp)
 
     target_link_libraries(${test} opentimelineio)
-    if (NOT "${IMATH_INCLUDES}" STREQUAL "")
-        target_include_directories(${test} "${IMATH_INCLUDES}")
-    endif()
     set_target_properties(${test} PROPERTIES FOLDER tests)
     add_test(NAME ${test} 
            COMMAND ${test}
-- 
2.49.0

openSUSE Build Service is sponsored by