CMake: Disable Options Depending on OpenEXR Dependecies #106209

Merged
Jeroen Bakker merged 3 commits from Jeroen-Bakker/blender:cmake-imath-libraries into main 2023-04-03 09:51:02 +02:00
1 changed files with 7 additions and 2 deletions
Showing only changes of commit db01cb7720 - Show all commits

View File

@ -122,7 +122,6 @@ 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 also add it to the OpenEXR includes and libraries, as it's simpler to
# support both 2.x and 3.x this way.
SET(IMATH_LIBRARIES)
Jeroen-Bakker marked this conversation as resolved Outdated

This code only runs for OpenEXR 3, so this does not work for 2. To handle both cases:

IF(OPENEXR_VERSION VERSION_GREATER_EQUAL "3.0.0")
	set(IMATH_LIBRARIES ${IMATH_LIBRARY})
ELSE()
	set(IMATH_LIBRARIES ${OPENEXR_IMATH_LIBRARY})
ENDIF()
This code only runs for OpenEXR 3, so this does not work for 2. To handle both cases: ``` IF(OPENEXR_VERSION VERSION_GREATER_EQUAL "3.0.0") set(IMATH_LIBRARIES ${IMATH_LIBRARY}) ELSE() set(IMATH_LIBRARIES ${OPENEXR_IMATH_LIBRARY}) ENDIF() ```
# Find include directory
FIND_PATH(IMATH_INCLUDE_DIR
@ -160,7 +159,6 @@ IF(OPENEXR_VERSION VERSION_GREATER_EQUAL "3.0.0")
PATH_SUFFIXES
lib64 lib
)
LIST(APPEND IMATH_LIBRARIES "${IMATH_LIBRARY}")
LIST(APPEND _openexr_LIBRARIES "${IMATH_LIBRARY}")
# In cmake version 3.21 and up, we can instead use the NO_CACHE option for
@ -170,6 +168,13 @@ IF(OPENEXR_VERSION VERSION_GREATER_EQUAL "3.0.0")
UNSET(_imath_build_specification)
ENDIF()
IF(OPENEXR_VERSION VERSION_GREATER_EQUAL "3.0.0")
SET(IMATH_LIBRARIES ${IMATH_LIBRARY})
ELSE()
SET(IMATH_LIBRARIES ${OPENEXR_IMATH_LIBRARY})
ENDIF()
# handle the QUIETLY and REQUIRED arguments and set OPENEXR_FOUND to TRUE if
# all listed variables are TRUE
INCLUDE(FindPackageHandleStandardArgs)