summarylogtreecommitdiffstats
path: root/0009-openexr3.patch
blob: 7753e652f8b3490baf2b3516caf1933cb5a91566 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
From 596bb2f33c70b7c6859019971938194cc39e8bdb Mon Sep 17 00:00:00 2001
From: howetuft <howetuft@gmail.com>
Date: Sat, 21 May 2022 18:18:50 +0200
Subject: [PATCH 09/14] openexr3

---
 cmake/Packages/FindOpenEXR.cmake              | 241 ++++++++++--------
 .../src/OpenColorIO/BitDepthUtils.h           |   2 +-
 .../src/OpenColorIO/MathUtils.h               |   2 +-
 .../src/OpenColorIO/ops/range/RangeOp.cpp     |   2 +-
 .../OpenColorIO/transforms/builtins/ACES.cpp  |   2 +-
 .../transforms/builtins/OpHelpers.cpp         |   2 +-
 .../src/libutils/oiiohelpers/oiiohelpers.cpp  |   2 +-
 deps/openvdb-7.0.0/openvdb/Types.h            |   2 +-
 include/slg/imagemap/imagemap.h               |   2 +-
 include/slg/utils/halfserialization.h         |   2 +-
 10 files changed, 137 insertions(+), 122 deletions(-)

diff --git a/cmake/Packages/FindOpenEXR.cmake b/cmake/Packages/FindOpenEXR.cmake
index dfe517b34..a2f7b4c62 100644
--- a/cmake/Packages/FindOpenEXR.cmake
+++ b/cmake/Packages/FindOpenEXR.cmake
@@ -1,123 +1,138 @@
-################################################################################
-# Copyright 1998-2020 by authors (see AUTHORS.txt)
+# - Find OpenEXR library
+# Find the native OpenEXR includes and library
+# This module defines
+#  OPENEXR_INCLUDE_DIRS, where to find ImfXdr.h, etc. Set when
+#                        OPENEXR_INCLUDE_DIR is found.
+#  OPENEXR_LIBRARIES, libraries to link against to use OpenEXR.
+#  OPENEXR_ROOT_DIR, The base directory to search for OpenEXR.
+#                    This can also be an environment variable.
+#  OPENEXR_FOUND, If false, do not try to use OpenEXR.
 #
-#   This file is part of LuxCoreRender.
+# For individual library access these advanced settings are available
+#  OPENEXR_HALF_LIBRARY, Path to Half library
+#  OPENEXR_IEX_LIBRARY, Path to Half library
+#  OPENEXR_ILMIMF_LIBRARY, Path to Ilmimf library
+#  OPENEXR_ILMTHREAD_LIBRARY, Path to IlmThread library
+#  OPENEXR_IMATH_LIBRARY, Path to Imath library
 #
-# 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.
-################################################################################
-
-# - Try to find OpenEXR
-# Library is first searched for in OPENEXR_ROOT
-# Once done, this will define
+# also defined, but not for general use are
+#  OPENEXR_LIBRARY, where to find the OpenEXR library.
+
+#=============================================================================
+# Copyright 2011 Blender Foundation.
 #
-#  OPENEXR_FOUND - system has OpenEXR
-#  OPENEXR_INCLUDE_DIRS - the OpenEXR include directories
-#  OPENEXR_LIBRARIES - link these to use OpenEXR
-
-# Lookup user specified path first
-SET(OpenEXR_TEST_HEADERS ImfXdr.h OpenEXRConfig.h IlmBaseConfig.h)
-SET(OpenEXR_INC_SUFFIXES include/OpenEXR include Include Headers)
-FIND_PATH(OPENEXR_INCLUDE_DIRS
-	NAMES ${OpenEXR_TEST_HEADERS}
-	PATHS "${OPENEXR_ROOT}"
-	PATH_SUFFIXES ${OpenEXR_INC_SUFFIXES}
-	NO_DEFAULT_PATH
-	DOC "The directory where IlmBaseConfig.h resides"
+# Distributed under the OSI-approved BSD 3-Clause License,
+# see accompanying file BSD-3-Clause-license.txt for details.
+#=============================================================================
+
+# If OPENEXR_ROOT_DIR was defined in the environment, use it.
+IF(NOT OPENEXR_ROOT_DIR AND NOT $ENV{OPENEXR_ROOT_DIR} STREQUAL "")
+  SET(OPENEXR_ROOT_DIR $ENV{OPENEXR_ROOT_DIR})
+ENDIF()
+
+# Old versions (before 2.0?) do not have any version string, just assuming this should be fine though.
+SET(_openexr_libs_ver_init "2.0")
+
+SET(_openexr_FIND_COMPONENTS
+  Iex
+  Imath
+  OpenEXR
+  IlmThread
 )
-FIND_PATH(OPENEXR_INCLUDE_DIRS
-	NAMES ${OpenEXR_TEST_HEADERS}
-	PATHS /usr/local /usr /sw /opt/local /opt/csw /opt
-	PATH_SUFFIXES ${OpenEXR_INC_SUFFIXES}
-	DOC "The directory where IlmBaseConfig.h resides"
+
+SET(_openexr_SEARCH_DIRS
+  ${OPENEXR_ROOT_DIR}
+  /opt/lib/openexr
+)
+
+FIND_PATH(OPENEXR_INCLUDE_DIR
+  NAMES
+    OpenEXR/ImfXdr.h
+  HINTS
+    ${_openexr_SEARCH_DIRS}
+  PATH_SUFFIXES
+    include
 )
 
-IF (OPENEXR_INCLUDE_DIRS)
-# Lookup additional headers in case they are in subdirectories
-SET(OpenEXR_MODULES Iex Imf half Imath IlmThread)
-FOREACH(i ${OpenEXR_MODULES})
-	FIND_PATH(OpenEXR_${i}_INCLUDE_DIR
-		NAMES ${i}.h ${i}Header.h ${i}Math.h
-		PATHS "${OPENEXR_INCLUDE_DIRS}" "${OPENEXR_INCLUDE_DIRS}/${i}" "${OPENEXR_INCLUDE_DIRS}/Ilm${i}"
-		NO_DEFAULT_PATH
-		DOC "The directory where ${i}.h resides"
-	)
-ENDFOREACH(i)
-FOREACH(i ${OpenEXR_MODULES})
-	IF (NOT OpenEXR_${i}_INCLUDE_DIR)
-		SET(OpenEXR_${i}_INCLUDE_DIR "")
-	ENDIF (NOT OpenEXR_${i}_INCLUDE_DIR)
-	IF ("${OpenEXR_${i}_INCLUDE_DIR}" STREQUAL "${OPENEXR_INCLUDE_DIRS}")
-		SET(OpenEXR_${i}_INCLUDE_DIR "")
-	ENDIF ("${OpenEXR_${i}_INCLUDE_DIR}" STREQUAL "${OPENEXR_INCLUDE_DIRS}")
-ENDFOREACH(i)
-FOREACH(i ${OpenEXR_MODULES})
-	SET(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIRS} ${OpenEXR_${i}_INCLUDE_DIR})
-ENDFOREACH(i)
-ENDIF(OPENEXR_INCLUDE_DIRS)
-
-SET(OpenEXR_LIBRARY_MODULES Iex IlmImf Half Imath IlmThread)
-SET(OpenEXR_LIB_SUFFIXES lib64 lib Lib lib/OpenEXR Libs x64/Release/lib)
-SET(OpenEXR_LIB_SUFFIXES_REL)
-SET(OpenEXR_LIB_SUFFIXES_DBG)
-FOREACH(i ${OpenEXR_LIB_SUFFIXES})
-	SET(OpenEXR_LIB_SUFFIXES_REL ${OpenEXR_LIB_SUFFIXES_REL}
-		"${i}" "${i}/release" "${i}/relwithdebinfo" "${i}/minsizerel" "${i}/dist")
-	SET(OpenEXR_LIB_SUFFIXES_DBG ${OpenEXR_LIB_SUFFIXES_DBG}
-		"${i}" "${i}/debug" "${i}/dist")
-ENDFOREACH(i)
-SET(OPENEXR_LIBRARIES)
-FOREACH(i ${OpenEXR_LIBRARY_MODULES})
-	FIND_LIBRARY(OpenEXR_${i}_LIBRARY_REL
-		NAMES ${i}
-		PATHS "${OPENEXR_ROOT}"
-		PATH_SUFFIXES ${OpenEXR_LIB_SUFFIXES_REL}
-		NO_DEFAULT_PATH
-		DOC "The ${i} release library"
-	)
-	FIND_LIBRARY(OpenEXR_${i}_LIBRARY_REL
-		NAMES ${i}
-		PATHS /usr/local /usr /sw /opt/local /opt/csw /opt
-		PATH_SUFFIXES ${OpenEXR_LIB_SUFFIXES_REL}
-		DOC "The ${i} release library"
-	)
-	FIND_LIBRARY(OpenEXR_${i}_LIBRARY_DBG
-		NAMES "${i}d" "${i}D" "${i}_d" "${i}_D" "${i}_debug"
-		PATHS "${OPENEXR_ROOT}"
-		PATH_SUFFIXES ${OpenEXR_LIB_SUFFIXES_DBG}
-		NO_DEFAULT_PATH
-		DOC "The ${i} debug library"
-	)
-	FIND_LIBRARY(OpenEXR_${i}_LIBRARY_DBG
-		NAMES "${i}d" "${i}D" "${i}_d" "${i}_D" "${i}_debug"
-		PATHS /usr/local /usr /sw /opt/local /opt/csw /opt
-		PATH_SUFFIXES ${OpenEXR_LIB_SUFFIXES_DBG}
-		DOC "The ${i} debug library"
-	)
-	IF (OpenEXR_${i}_LIBRARY_REL AND OpenEXR_${i}_LIBRARY_DBG)
-		SET(OPENEXR_LIBRARIES ${OPENEXR_LIBRARIES}
-			optimized ${OpenEXR_${i}_LIBRARY_REL}
-			debug ${OpenEXR_${i}_LIBRARY_DBG})
-	ELSEIF (OpenEXR_${i}_LIBRARY_REL)
-		SET(OPENEXR_LIBRARIES ${OPENEXR_LIBRARIES}
-			${OpenEXR_${i}_LIBRARY_REL})
-	ELSEIF (OpenEXR_${i}_LIBRARY_DBG)
-		SET(OPENEXR_LIBRARIES ${OPENEXR_LIBRARIES}
-			${OpenEXR_${i}_LIBRARY_DBG})
-	ENDIF (OpenEXR_${i}_LIBRARY_REL AND OpenEXR_${i}_LIBRARY_DBG)
-ENDFOREACH (i)
+# If the headers were found, get the version from config file, if not already set.
+IF(OPENEXR_INCLUDE_DIR)
+  IF(NOT OPENEXR_VERSION)
+
+    FIND_FILE(_openexr_CONFIG
+      NAMES
+        OpenEXRConfig.h
+      PATHS
+        "${OPENEXR_INCLUDE_DIR}"
+        "${OPENEXR_INCLUDE_DIR}/OpenEXR"
+      NO_DEFAULT_PATH
+    )
+
+    IF(_openexr_CONFIG)
+      FILE(STRINGS "${_openexr_CONFIG}" OPENEXR_BUILD_SPECIFICATION
+           REGEX "^[ \t]*#define[ \t]+OPENEXR_VERSION_STRING[ \t]+\"[.0-9]+\".*$")
+    ELSE()
+      MESSAGE(WARNING "Could not find \"OpenEXRConfig.h\" in \"${OPENEXR_INCLUDE_DIR}\"")
+    ENDIF()
 
+    IF(OPENEXR_BUILD_SPECIFICATION)
+      MESSAGE(STATUS "${OPENEXR_BUILD_SPECIFICATION}")
+      STRING(REGEX REPLACE ".*#define[ \t]+OPENEXR_VERSION_STRING[ \t]+\"([.0-9]+)\".*"
+             "\\1" _openexr_libs_ver_init ${OPENEXR_BUILD_SPECIFICATION})
+    ELSE()
+      MESSAGE(WARNING "Could not determine ILMBase library version, assuming ${_openexr_libs_ver_init}.")
+    ENDIF()
+
+    UNSET(_openexr_CONFIG CACHE)
+
+  ENDIF()
+ENDIF()
+
+SET("OPENEXR_VERSION" ${_openexr_libs_ver_init} CACHE STRING "Version of OpenEXR lib")
+UNSET(_openexr_libs_ver_init)
+
+STRING(REGEX REPLACE "([0-9]+)[.]([0-9]+).*" "\\1_\\2" _openexr_libs_ver ${OPENEXR_VERSION})
+
+SET(_openexr_LIBRARIES)
+FOREACH(COMPONENT ${_openexr_FIND_COMPONENTS})
+  STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
+
+  FIND_LIBRARY(OPENEXR_${UPPERCOMPONENT}_LIBRARY
+    NAMES
+      ${COMPONENT}-${_openexr_libs_ver} ${COMPONENT}
+    NAMES_PER_DIR
+    HINTS
+      ${_openexr_SEARCH_DIRS}
+    PATH_SUFFIXES
+      lib64 lib
+    )
+  LIST(APPEND _openexr_LIBRARIES "${OPENEXR_${UPPERCOMPONENT}_LIBRARY}")
+ENDFOREACH()
+
+UNSET(_openexr_libs_ver)
+
+# handle the QUIETLY and REQUIRED arguments and set OPENEXR_FOUND to TRUE if
+# all listed variables are TRUE
 INCLUDE(FindPackageHandleStandardArgs)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(OPENEXR  DEFAULT_MSG  OPENEXR_LIBRARIES OPENEXR_INCLUDE_DIRS)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenEXR  DEFAULT_MSG
+    _openexr_LIBRARIES OPENEXR_INCLUDE_DIR)
 
-MARK_AS_ADVANCED(OPENEXR_INCLUDE_DIRS OPENEXR_LIBRARIES)
+IF(OPENEXR_FOUND)
+  SET(OPENEXR_LIBRARIES ${_openexr_LIBRARIES})
+  # Both include paths are needed because of dummy OSL headers mixing #include <OpenEXR/foo.h> and #include <foo.h> :(
+  SET(OPENEXR_INCLUDE_DIRS ${OPENEXR_INCLUDE_DIR} ${OPENEXR_INCLUDE_DIR}/OpenEXR ${OPENEXR_INCLUDE_DIR}/Imath)
+ENDIF()
+
+MARK_AS_ADVANCED(
+  OPENEXR_INCLUDE_DIR
+  OPENEXR_VERSION
+)
+FOREACH(COMPONENT ${_openexr_FIND_COMPONENTS})
+  STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
+  MARK_AS_ADVANCED(OPENEXR_${UPPERCOMPONENT}_LIBRARY)
+ENDFOREACH()
 
+UNSET(COMPONENT)
+UNSET(UPPERCOMPONENT)
+UNSET(_openexr_FIND_COMPONENTS)
+UNSET(_openexr_LIBRARIES)
+UNSET(_openexr_SEARCH_DIRS)
diff --git a/deps/opencolorio-2.0.0/src/OpenColorIO/BitDepthUtils.h b/deps/opencolorio-2.0.0/src/OpenColorIO/BitDepthUtils.h
index a8b3cbd94..bb0163bff 100644
--- a/deps/opencolorio-2.0.0/src/OpenColorIO/BitDepthUtils.h
+++ b/deps/opencolorio-2.0.0/src/OpenColorIO/BitDepthUtils.h
@@ -7,7 +7,7 @@
 
 #include <OpenColorIO/OpenColorIO.h>
 
-#include "OpenEXR/half.h"
+#include "Imath/half.h"
 
 
 namespace OCIO_NAMESPACE
diff --git a/deps/opencolorio-2.0.0/src/OpenColorIO/MathUtils.h b/deps/opencolorio-2.0.0/src/OpenColorIO/MathUtils.h
index 309c6244f..0873d4908 100644
--- a/deps/opencolorio-2.0.0/src/OpenColorIO/MathUtils.h
+++ b/deps/opencolorio-2.0.0/src/OpenColorIO/MathUtils.h
@@ -9,7 +9,7 @@
 
 #include <OpenColorIO/OpenColorIO.h>
 
-#include "OpenEXR/half.h"
+#include "Imath/half.h"
 
 namespace OCIO_NAMESPACE
 {
diff --git a/deps/opencolorio-2.0.0/src/OpenColorIO/ops/range/RangeOp.cpp b/deps/opencolorio-2.0.0/src/OpenColorIO/ops/range/RangeOp.cpp
index b6fb6d9e7..e7389203c 100644
--- a/deps/opencolorio-2.0.0/src/OpenColorIO/ops/range/RangeOp.cpp
+++ b/deps/opencolorio-2.0.0/src/OpenColorIO/ops/range/RangeOp.cpp
@@ -7,7 +7,7 @@
 #include <OpenColorIO/OpenColorIO.h>
 
 #include "GpuShaderUtils.h"
-#include "OpenEXR/half.h"
+#include "Imath/half.h"
 #include "HashUtils.h"
 #include "MathUtils.h"
 #include "ops/lut1d/Lut1DOpData.h"
diff --git a/deps/opencolorio-2.0.0/src/OpenColorIO/transforms/builtins/ACES.cpp b/deps/opencolorio-2.0.0/src/OpenColorIO/transforms/builtins/ACES.cpp
index 20968c0da..9ee2ac27a 100644
--- a/deps/opencolorio-2.0.0/src/OpenColorIO/transforms/builtins/ACES.cpp
+++ b/deps/opencolorio-2.0.0/src/OpenColorIO/transforms/builtins/ACES.cpp
@@ -6,7 +6,7 @@
 
 #include <OpenColorIO/OpenColorIO.h>
 
-#include "OpenEXR/half.h"
+#include "Imath/half.h"
 #include "ops/fixedfunction/FixedFunctionOp.h"
 #include "ops/gradingrgbcurve/GradingRGBCurveOp.h"
 #include "ops/log/LogOp.h"
diff --git a/deps/opencolorio-2.0.0/src/OpenColorIO/transforms/builtins/OpHelpers.cpp b/deps/opencolorio-2.0.0/src/OpenColorIO/transforms/builtins/OpHelpers.cpp
index 04b8fbd40..288ca5668 100644
--- a/deps/opencolorio-2.0.0/src/OpenColorIO/transforms/builtins/OpHelpers.cpp
+++ b/deps/opencolorio-2.0.0/src/OpenColorIO/transforms/builtins/OpHelpers.cpp
@@ -4,7 +4,7 @@
 
 #include <OpenColorIO/OpenColorIO.h>
 
-#include "OpenEXR/half.h"
+#include "Imath/half.h"
 #include "ops/lut1d/Lut1DOp.h"
 #include "transforms/builtins/OpHelpers.h"
 
diff --git a/deps/opencolorio-2.0.0/src/libutils/oiiohelpers/oiiohelpers.cpp b/deps/opencolorio-2.0.0/src/libutils/oiiohelpers/oiiohelpers.cpp
index 3228644ad..11478daff 100644
--- a/deps/opencolorio-2.0.0/src/libutils/oiiohelpers/oiiohelpers.cpp
+++ b/deps/opencolorio-2.0.0/src/libutils/oiiohelpers/oiiohelpers.cpp
@@ -5,7 +5,7 @@
 #include <OpenColorIO/OpenColorIO.h>
 
 
-#include "OpenEXR/half.h"
+#include "Imath/half.h"
 #include "oiiohelpers.h"
 #include "utils/StringUtils.h"
 
diff --git a/deps/openvdb-7.0.0/openvdb/Types.h b/deps/openvdb-7.0.0/openvdb/Types.h
index 70269cf07..0d9906828 100644
--- a/deps/openvdb-7.0.0/openvdb/Types.h
+++ b/deps/openvdb-7.0.0/openvdb/Types.h
@@ -6,7 +6,7 @@
 
 #include "version.h"
 #include "Platform.h"
-#include <OpenEXR/half.h>
+#include <Imath/half.h>
 #include <openvdb/math/Math.h>
 #include <openvdb/math/BBox.h>
 #include <openvdb/math/Quat.h>
diff --git a/include/slg/imagemap/imagemap.h b/include/slg/imagemap/imagemap.h
index 0260456ce..46d2c2241 100644
--- a/include/slg/imagemap/imagemap.h
+++ b/include/slg/imagemap/imagemap.h
@@ -19,7 +19,7 @@
 #ifndef _SLG_IMAGEMAP_H
 #define	_SLG_IMAGEMAP_H
 
-#include <OpenEXR/half.h>
+#include <Imath/half.h>
 
 #include <string>
 #include <limits>
diff --git a/include/slg/utils/halfserialization.h b/include/slg/utils/halfserialization.h
index 551789888..2624f118c 100644
--- a/include/slg/utils/halfserialization.h
+++ b/include/slg/utils/halfserialization.h
@@ -19,7 +19,7 @@
 #ifndef _SLG_HALFSERIALIZATION_H
 #define	_SLG_HALFSERIALIZATION_H
 
-#include <OpenEXR/half.h>
+#include <Imath/half.h>
 
 #include "luxrays/utils/utils.h"
 #include "luxrays/utils/serializationutils.h"
-- 
2.43.0