Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brecht@blender.org>2022-02-17 17:24:29 +0300
committerBrecht Van Lommel <brecht@blender.org>2022-02-17 17:24:29 +0300
commita4c800ed02154b638f44e440ea530f4aacc4aca3 (patch)
treed9e0225b88884f73f9037f580e4b4a25dd4ed0ab /build_files/cmake
parent6a283b7a7f4344fb10fbac54258e9c5b1da0c1ad (diff)
parente5100ca3ad17b1b9a40ffd8a8edccb6cb553e558 (diff)
Merge branch 'blender-v3.1-release'
Diffstat (limited to 'build_files/cmake')
-rw-r--r--build_files/cmake/Modules/FindOpenEXR.cmake93
-rw-r--r--build_files/cmake/Modules/FindOpenImageIO.cmake41
2 files changed, 122 insertions, 12 deletions
diff --git a/build_files/cmake/Modules/FindOpenEXR.cmake b/build_files/cmake/Modules/FindOpenEXR.cmake
index 792bb127f99..f772ef4e1ff 100644
--- a/build_files/cmake/Modules/FindOpenEXR.cmake
+++ b/build_files/cmake/Modules/FindOpenEXR.cmake
@@ -29,14 +29,6 @@ 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
- Half
- Iex
- IlmImf
- IlmThread
- Imath
-)
-
SET(_openexr_SEARCH_DIRS
${OPENEXR_ROOT_DIR}
/opt/lib/openexr
@@ -89,6 +81,24 @@ UNSET(_openexr_libs_ver_init)
STRING(REGEX REPLACE "([0-9]+)[.]([0-9]+).*" "\\1_\\2" _openexr_libs_ver ${OPENEXR_VERSION})
+# Different library names in 3.0, and Imath and Half moved out.
+IF(OPENEXR_VERSION VERSION_GREATER_EQUAL "3.0.0")
+ SET(_openexr_FIND_COMPONENTS
+ Iex
+ IlmThread
+ OpenEXR
+ OpenEXRCore
+ )
+ELSE()
+ SET(_openexr_FIND_COMPONENTS
+ Half
+ Iex
+ IlmImf
+ IlmThread
+ Imath
+ )
+ENDIF()
+
SET(_openexr_LIBRARIES)
FOREACH(COMPONENT ${_openexr_FIND_COMPONENTS})
STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
@@ -107,6 +117,57 @@ ENDFOREACH()
UNSET(_openexr_libs_ver)
+IF(OPENEXR_VERSION VERSION_GREATER_EQUAL "3.0.0")
+ # For OpenEXR 3.x, we also need to find the now separate Imath library.
+ # For simplicity we add it to the OpenEXR includes and libraries, as we
+ # have no direct dependency on Imath and it's simpler to support both
+ # 2.x and 3.x this way.
+
+ # Find include directory
+ FIND_PATH(IMATH_INCLUDE_DIR
+ NAMES
+ Imath/ImathMath.h
+ HINTS
+ ${_openexr_SEARCH_DIRS}
+ PATH_SUFFIXES
+ include
+ )
+
+ # Find version
+ FIND_FILE(_imath_config
+ NAMES
+ ImathConfig.h
+ PATHS
+ ${IMATH_INCLUDE_DIR}/Imath
+ NO_DEFAULT_PATH
+ )
+
+ # Find line with version, extract string, and format for library suffix.
+ FILE(STRINGS "${_imath_config}" _imath_build_specification
+ REGEX "^[ \t]*#define[ \t]+IMATH_VERSION_STRING[ \t]+\"[.0-9]+\".*$")
+ STRING(REGEX REPLACE ".*#define[ \t]+IMATH_VERSION_STRING[ \t]+\"([.0-9]+)\".*"
+ "\\1" _imath_libs_ver ${_imath_build_specification})
+ STRING(REGEX REPLACE "([0-9]+)[.]([0-9]+).*" "\\1_\\2" _imath_libs_ver ${_imath_libs_ver})
+
+ # Find library, with or without version number.
+ FIND_LIBRARY(IMATH_LIBRARY
+ NAMES
+ Imath-${_imath_libs_ver} Imath
+ NAMES_PER_DIR
+ HINTS
+ ${_openexr_SEARCH_DIRS}
+ PATH_SUFFIXES
+ lib64 lib
+ )
+ LIST(APPEND _openexr_LIBRARIES "${IMATH_LIBRARY}")
+
+ # In cmake version 3.21 and up, we can instead use the NO_CACHE option for
+ # FIND_FILE so we don't need to clear it from the cache here.
+ UNSET(_imath_config CACHE)
+ UNSET(_imath_libs_ver)
+ UNSET(_imath_build_specification)
+ENDIF()
+
# handle the QUIETLY and REQUIRED arguments and set OPENEXR_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
@@ -115,13 +176,25 @@ FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenEXR DEFAULT_MSG
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)
+ # Both include paths are needed because of dummy OSL headers mixing
+ # #include <OpenEXR/foo.h> and #include <foo.h>, as well as Alembic
+ # include <half.h> directly.
+ SET(OPENEXR_INCLUDE_DIRS
+ ${OPENEXR_INCLUDE_DIR}
+ ${OPENEXR_INCLUDE_DIR}/OpenEXR)
+
+ IF(OPENEXR_VERSION VERSION_GREATER_EQUAL "3.0.0")
+ LIST(APPEND OPENEXR_INCLUDE_DIRS
+ ${IMATH_INCLUDE_DIR}
+ ${IMATH_INCLUDE_DIR}/Imath)
+ ENDIF()
ENDIF()
MARK_AS_ADVANCED(
OPENEXR_INCLUDE_DIR
OPENEXR_VERSION
+ IMATH_INCLUDE_DIR
+ IMATH_LIBRARY
)
FOREACH(COMPONENT ${_openexr_FIND_COMPONENTS})
STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
diff --git a/build_files/cmake/Modules/FindOpenImageIO.cmake b/build_files/cmake/Modules/FindOpenImageIO.cmake
index 27a56647eac..0e8742ef2ed 100644
--- a/build_files/cmake/Modules/FindOpenImageIO.cmake
+++ b/build_files/cmake/Modules/FindOpenImageIO.cmake
@@ -44,6 +44,8 @@ FIND_LIBRARY(OPENIMAGEIO_LIBRARY
lib64 lib
)
+set(_openimageio_LIBRARIES ${OPENIMAGEIO_LIBRARY})
+
FIND_FILE(OPENIMAGEIO_IDIFF
NAMES
idiff
@@ -53,14 +55,47 @@ FIND_FILE(OPENIMAGEIO_IDIFF
bin
)
+# Additionally find util library if needed. In old versions this library was
+# included in libOpenImageIO and linking to both would duplicate symbols. In
+# new versions we need to link to both.
+FIND_FILE(_openimageio_export
+ NAMES
+ export.h
+ PATHS
+ ${OPENIMAGEIO_INCLUDE_DIR}/OpenImageIO
+ NO_DEFAULT_PATH
+)
+
+# Use existence of OIIO_UTIL_API to check if it's a separate lib.
+FILE(STRINGS "${_openimageio_export}" _openimageio_util_define
+ REGEX "^[ \t]*#[ \t]*define[ \t]+OIIO_UTIL_API.*$")
+
+IF(_openimageio_util_define)
+ FIND_LIBRARY(OPENIMAGEIO_UTIL_LIBRARY
+ NAMES
+ OpenImageIO_Util
+ HINTS
+ ${_openimageio_SEARCH_DIRS}
+ PATH_SUFFIXES
+ lib64 lib
+ )
+
+ LIST(APPEND _openimageio_LIBRARIES ${OPENIMAGEIO_UTIL_LIBRARY})
+ENDIF()
+
+# In cmake version 3.21 and up, we can instead use the NO_CACHE option for
+# FIND_FILE so we don't need to clear it from the cache here.
+UNSET(_openimageio_export CACHE)
+UNSET(_openimageio_util_define)
+
# handle the QUIETLY and REQUIRED arguments and set OPENIMAGEIO_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenImageIO DEFAULT_MSG
- OPENIMAGEIO_LIBRARY OPENIMAGEIO_INCLUDE_DIR)
+ _openimageio_LIBRARIES OPENIMAGEIO_INCLUDE_DIR)
IF(OPENIMAGEIO_FOUND)
- SET(OPENIMAGEIO_LIBRARIES ${OPENIMAGEIO_LIBRARY})
+ SET(OPENIMAGEIO_LIBRARIES ${_openimageio_LIBRARIES})
SET(OPENIMAGEIO_INCLUDE_DIRS ${OPENIMAGEIO_INCLUDE_DIR})
IF(EXISTS ${OPENIMAGEIO_INCLUDE_DIR}/OpenImageIO/pugixml.hpp)
SET(OPENIMAGEIO_PUGIXML_FOUND TRUE)
@@ -74,7 +109,9 @@ ENDIF()
MARK_AS_ADVANCED(
OPENIMAGEIO_INCLUDE_DIR
OPENIMAGEIO_LIBRARY
+ OPENIMAGEIO_UTIL_LIBRARY
OPENIMAGEIO_IDIFF
)
UNSET(_openimageio_SEARCH_DIRS)
+UNSET(_openimageio_LIBRARIES)