|
1 | 1 | # Copyright Contributors to the OpenImageIO project.
|
2 |
| -# SPDX-License-Identifier: BSD-3-Clause and Apache-2.0 |
| 2 | +# SPDX-License-Identifier: Apache-2.0 |
3 | 3 | # https://github.com/OpenImageIO/oiio
|
4 | 4 |
|
5 | 5 | # Module to find OpenEXR and Imath.
|
6 | 6 | #
|
7 | 7 | # I'm afraid this is a mess, due to needing to support a wide range of
|
8 | 8 | # OpenEXR versions.
|
9 | 9 | #
|
10 |
| -# For OpenEXR & Imath 3.0, this will establish the following imported |
| 10 | +# For OpenEXR & Imath 3.x, this will establish the following imported |
11 | 11 | # targets:
|
12 | 12 | #
|
13 | 13 | # Imath::Imath
|
|
24 | 24 | # IlmBase::IlmThread
|
25 | 25 | # OpenEXR::IlmImf
|
26 | 26 | #
|
27 |
| -# For all versions -- but for OpenEXR < 2.4 the only thing this sets -- |
28 |
| -# are the following CMake variables: |
| 27 | +# For all version, the following CMake variables: |
29 | 28 | #
|
30 | 29 | # OPENEXR_FOUND true, if found
|
31 | 30 | # OPENEXR_INCLUDES directory where OpenEXR headers are found
|
32 | 31 | # OPENEXR_LIBRARIES libraries for OpenEXR + IlmBase
|
33 |
| -# OPENEXR_VERSION OpenEXR version (accurate for >= 2.0.0, |
34 |
| -# otherwise will just guess 1.6.1) |
| 32 | +# OPENEXR_VERSION OpenEXR version |
35 | 33 | # IMATH_INCLUDES directory where Imath headers are found
|
36 | 34 | # ILMBASE_INCLUDES directory where IlmBase headers are found
|
37 | 35 | # ILMBASE_LIBRARIES libraries just IlmBase
|
@@ -111,162 +109,4 @@ elseif (TARGET OpenEXR::IlmImf AND TARGET IlmBase::Imath AND
|
111 | 109 | string(REGEX REPLACE "include/OpenEXR$" "include" IMATH_INCLUDES "${IMATH_INCLUDES}")
|
112 | 110 | string(REGEX REPLACE "include/OpenEXR$" "include" OPENEXR_INCLUDES "${OPENEXR_INCLUDES}")
|
113 | 111 |
|
114 |
| -else () |
115 |
| - # OpenEXR 2.x older versions without a config or whose configs we don't |
116 |
| - # trust. |
117 |
| - |
118 |
| - set (FOUND_OPENEXR_WITH_CONFIG 0) |
119 |
| - |
120 |
| -# Other standard issue macros |
121 |
| -include (FindPackageHandleStandardArgs) |
122 |
| -include (SelectLibraryConfigurations) |
123 |
| - |
124 |
| -find_package (ZLIB REQUIRED) |
125 |
| - |
126 |
| -# Link with pthreads if required |
127 |
| -find_package (Threads) |
128 |
| -if (CMAKE_USE_PTHREADS_INIT) |
129 |
| - set (ILMBASE_PTHREADS ${CMAKE_THREAD_LIBS_INIT}) |
130 |
| -endif () |
131 |
| - |
132 |
| -# Attempt to find OpenEXR with pkgconfig |
133 |
| -find_package(PkgConfig) |
134 |
| -if (PKG_CONFIG_FOUND) |
135 |
| - if (NOT Ilmbase_ROOT AND NOT ILMBASE_ROOT |
136 |
| - AND NOT DEFINED ENV{Ilmbase_ROOT} AND NOT DEFINED ENV{ILMBASE_ROOT}) |
137 |
| - pkg_check_modules(_ILMBASE QUIET IlmBase>=2.0.0) |
138 |
| - endif () |
139 |
| - if (NOT OpenEXR_ROOT AND NOT OPENEXR_ROOT |
140 |
| - AND NOT DEFINED ENV{OpenEXR_ROOT} AND NOT DEFINED ENV{OPENEXR_ROOT}) |
141 |
| - pkg_check_modules(_OPENEXR QUIET OpenEXR>=2.0.0) |
142 |
| - endif () |
143 |
| -endif (PKG_CONFIG_FOUND) |
144 |
| - |
145 |
| -# List of likely places to find the headers -- note priority override of |
146 |
| -# ${OPENEXR_ROOT}/include. |
147 |
| -# ILMBASE is needed in case ilmbase an openexr are installed in separate |
148 |
| -# directories, like NixOS does |
149 |
| -set (GENERIC_INCLUDE_PATHS |
150 |
| - ${OPENEXR_ROOT}/include |
151 |
| - $ENV{OPENEXR_ROOT}/include |
152 |
| - ${ILMBASE_ROOT}/include |
153 |
| - $ENV{ILMBASE_ROOT}/include |
154 |
| - ${_ILMBASE_INCLUDEDIR} |
155 |
| - ${_OPENEXR_INCLUDEDIR} |
156 |
| - /usr/local/include |
157 |
| - /usr/include |
158 |
| - /usr/include/${CMAKE_LIBRARY_ARCHITECTURE} |
159 |
| - /sw/include |
160 |
| - /opt/local/include ) |
161 |
| - |
162 |
| -# Find the include file locations. |
163 |
| -find_path (ILMBASE_INCLUDE_PATH OpenEXR/IlmBaseConfig.h |
164 |
| - HINTS ${ILMBASE_INCLUDE_DIR} ${OPENEXR_INCLUDE_DIR} |
165 |
| - ${GENERIC_INCLUDE_PATHS} ) |
166 |
| -find_path (OPENEXR_INCLUDE_PATH OpenEXR/OpenEXRConfig.h |
167 |
| - HINTS ${OPENEXR_INCLUDE_DIR} |
168 |
| - ${GENERIC_INCLUDE_PATHS} ) |
169 |
| - |
170 |
| -# Try to figure out version number |
171 |
| -if (DEFINED _OPENEXR_VERSION AND NOT "${_OPENEXR_VERSION}" STREQUAL "") |
172 |
| - set (OPENEXR_VERSION "${_OPENEXR_VERSION}") |
173 |
| - set (OpenEXR_VERSION "${_OPENEXR_VERSION}") |
174 |
| - string (REGEX REPLACE "([0-9]+)\\.[0-9\\.]+" "\\1" OpenEXR_VERSION_MAJOR "${_OPENEXR_VERSION}") |
175 |
| - string (REGEX REPLACE "[0-9]+\\.([0-9]+)(\\.[0-9]+)?" "\\1" OpenEXR_VERSION_MINOR "${_OPENEXR_VERSION}") |
176 |
| -elseif (EXISTS "${OPENEXR_INCLUDE_PATH}/OpenEXR/ImfMultiPartInputFile.h") |
177 |
| - # Must be at least 2.0 |
178 |
| - file(STRINGS "${OPENEXR_INCLUDE_PATH}/OpenEXR/OpenEXRConfig.h" TMP REGEX "^#define OPENEXR_VERSION_STRING .*$") |
179 |
| - string (REGEX MATCHALL "[0-9]+[.0-9]+" OpenEXR_VERSION ${TMP}) |
180 |
| - file(STRINGS "${OPENEXR_INCLUDE_PATH}/OpenEXR/OpenEXRConfig.h" TMP REGEX "^#define OPENEXR_VERSION_MAJOR .*$") |
181 |
| - string (REGEX MATCHALL "[0-9]+" OpenEXR_VERSION_MAJOR ${TMP}) |
182 |
| - file(STRINGS "${OPENEXR_INCLUDE_PATH}/OpenEXR/OpenEXRConfig.h" TMP REGEX "^#define OPENEXR_VERSION_MINOR .*$") |
183 |
| - string (REGEX MATCHALL "[0-9]+" OpenEXR_VERSION_MINOR ${TMP}) |
184 |
| -else () |
185 |
| - # Assume an old one, predates 2.x that had versions |
186 |
| - set (OPENEXR_VERSION 1.6.1) |
187 |
| - set (OpenEXR_VERSION 1.6.1) |
188 |
| - set (OpenEXR_VERSION_MAJOR 1) |
189 |
| - set (OpenEXR_VERSION_MINOR 6) |
190 |
| -endif () |
191 |
| - |
192 |
| - |
193 |
| -# List of likely places to find the libraries -- note priority override of |
194 |
| -# ${OPENEXR_ROOT}/lib. |
195 |
| -set (GENERIC_LIBRARY_PATHS |
196 |
| - ${OPENEXR_ROOT}/lib |
197 |
| - ${ILMBASE_ROOT}/lib |
198 |
| - ${OPENEXR_INCLUDE_PATH}/../lib |
199 |
| - ${ILMBASE_INCLUDE_PATH}/../lib |
200 |
| - ${_ILMBASE_LIBDIR} |
201 |
| - ${_OPENEXR_LIBDIR} |
202 |
| - /usr/local/lib |
203 |
| - /usr/local/lib/${CMAKE_LIBRARY_ARCHITECTURE} |
204 |
| - /usr/lib |
205 |
| - /usr/lib/${CMAKE_LIBRARY_ARCHITECTURE} |
206 |
| - /sw/lib |
207 |
| - /opt/local/lib |
208 |
| - $ENV{PROGRAM_FILES}/OpenEXR/lib/static ) |
209 |
| - |
210 |
| -# message (STATUS "Generic lib paths: ${GENERIC_LIBRARY_PATHS}") |
211 |
| - |
212 |
| -# Handle request for static libs by altering CMAKE_FIND_LIBRARY_SUFFIXES. |
213 |
| -# We will restore it at the end of this file. |
214 |
| -set (_openexr_orig_suffixes ${CMAKE_FIND_LIBRARY_SUFFIXES}) |
215 |
| -if (OpenEXR_USE_STATIC_LIBS) |
216 |
| - if (WIN32) |
217 |
| - set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES}) |
218 |
| - else () |
219 |
| - set (CMAKE_FIND_LIBRARY_SUFFIXES .a) |
220 |
| - endif () |
221 |
| -endif () |
222 |
| - |
223 |
| -# Look for the libraries themselves, for all the components. |
224 |
| -# This is complicated because the OpenEXR libraries may or may not be |
225 |
| -# built with version numbers embedded. |
226 |
| -set (_openexr_components IlmThread IlmImf Imath Iex Half) |
227 |
| -foreach (COMPONENT ${_openexr_components}) |
228 |
| - string (TOUPPER ${COMPONENT} UPPERCOMPONENT) |
229 |
| - # First try with the version embedded |
230 |
| - find_library (OPENEXR_${UPPERCOMPONENT}_LIBRARY |
231 |
| - NAMES ${COMPONENT}-${OpenEXR_VERSION_MAJOR}_${OpenEXR_VERSION_MINOR} |
232 |
| - ${COMPONENT} |
233 |
| - ${COMPONENT}-${OpenEXR_VERSION_MAJOR}_${OpenEXR_VERSION_MINOR}_d |
234 |
| - ${COMPONENT}_d |
235 |
| - HINTS ${OPENEXR_LIBRARY_DIR} $ENV{OPENEXR_LIBRARY_DIR} |
236 |
| - ${GENERIC_LIBRARY_PATHS} ) |
237 |
| -endforeach () |
238 |
| - |
239 |
| -find_package_handle_standard_args (OpenEXR |
240 |
| - REQUIRED_VARS ILMBASE_INCLUDE_PATH OPENEXR_INCLUDE_PATH |
241 |
| - OPENEXR_IMATH_LIBRARY OPENEXR_ILMIMF_LIBRARY |
242 |
| - OPENEXR_IEX_LIBRARY OPENEXR_HALF_LIBRARY |
243 |
| - ) |
244 |
| - |
245 |
| -if (OPENEXR_FOUND) |
246 |
| - set (OPENEXR_VERSION_MAJOR ${OpenEXR_VERSION_MAJOR}) |
247 |
| - set (OPENEXR_VERSION_MINOR ${OpenEXR_VERSION_MINOR}) |
248 |
| - set (Imath_VERSION_MAJOR ${OpenEXR_VERSION_MAJOR}) |
249 |
| - set (Imath_VERSION_MINOR ${OpenEXR_VERSION_MINOR}) |
250 |
| - set (ILMBASE_FOUND TRUE) |
251 |
| - set (ILMBASE_INCLUDES ${ILMBASE_INCLUDE_PATH}) |
252 |
| - set (IMATH_INCLUDES ${ILMBASE_INCLUDE_PATH}) |
253 |
| - set (OPENEXR_INCLUDES ${OPENEXR_INCLUDE_PATH}) |
254 |
| - set (ILMBASE_INCLUDE_DIR ${ILMBASE_INCLUDE_PATH}) |
255 |
| - set (IMATH_INCLUDE_DIR ${ILMBASE_INCLUDE_PATH}) |
256 |
| - set (OPENEXR_INCLUDE_DIR ${OPENEXR_INCLUDE_PATH}) |
257 |
| - set (ILMBASE_LIBRARIES ${OPENEXR_IMATH_LIBRARY} ${OPENEXR_IEX_LIBRARY} ${OPENEXR_HALF_LIBRARY} ${OPENEXR_ILMTHREAD_LIBRARY} ${ILMBASE_PTHREADS} CACHE STRING "The libraries needed to use IlmBase") |
258 |
| - set (OPENEXR_LIBRARIES ${OPENEXR_ILMIMF_LIBRARY} ${ILMBASE_LIBRARIES} ${ZLIB_LIBRARIES} CACHE STRING "The libraries needed to use OpenEXR") |
259 |
| - set (FINDOPENEXR_FALLBACK TRUE) |
260 |
| -endif () |
261 |
| - |
262 |
| -mark_as_advanced( |
263 |
| - OPENEXR_ILMIMF_LIBRARY |
264 |
| - OPENEXR_IMATH_LIBRARY |
265 |
| - OPENEXR_IEX_LIBRARY |
266 |
| - OPENEXR_HALF_LIBRARY |
267 |
| - OPENEXR_VERSION) |
268 |
| - |
269 |
| -# Restore the original CMAKE_FIND_LIBRARY_SUFFIXES |
270 |
| -set (CMAKE_FIND_LIBRARY_SUFFIXES ${_openexr_orig_suffixes}) |
271 |
| - |
272 | 112 | endif ()
|
0 commit comments