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
3 changed files with 9 additions and 7 deletions
Showing only changes of commit 3adbebe0df - Show all commits

View File

@ -886,8 +886,11 @@ set_and_warn_dependency(WITH_TBB WITH_MOD_FLUID OFF)
# NanoVDB requires OpenVDB to convert the data structure
set_and_warn_dependency(WITH_OPENVDB WITH_NANOVDB OFF)
# OpenVDB and OpenColorIO uses 'half' type from OpenEXR
# OpenVDB, Alembic and Vulkan, OSL uses 'half' or 'imath' from OpenEXR
set_and_warn_dependency(WITH_IMAGE_OPENEXR WITH_OPENVDB OFF)
set_and_warn_dependency(WITH_IMAGE_OPENEXR WITH_ALEMBIC OFF)
set_and_warn_dependency(WITH_IMAGE_OPENEXR WITH_VULKAN_BACKEND OFF)
set_and_warn_dependency(WITH_IMAGE_OPENEXR WITH_CYCLES_OSL OFF)
# Haru needs `TIFFFaxBlackCodes` & `TIFFFaxWhiteCodes` symbols from TIFF.
set_and_warn_dependency(WITH_IMAGE_TIFF WITH_HARU OFF)
@ -950,7 +953,6 @@ if(WITH_CYCLES_DEVICE_HIP)
set(WITH_HIP_DYNLOAD ON)
endif()
# -----------------------------------------------------------------------------
# Check if Sub-modules are Cloned
@ -1232,7 +1234,6 @@ if(WITH_METAL_BACKEND)
# build_files/cmake/platform/platform_apple.cmake
endif()
# -----------------------------------------------------------------------------
# Configure OpenMP

View File

@ -120,9 +120,9 @@ 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.
# 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,6 +160,7 @@ 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
@ -196,6 +197,7 @@ MARK_AS_ADVANCED(
OPENEXR_VERSION
IMATH_INCLUDE_DIR
IMATH_LIBRARY
IMATH_LIBRARIES
)
FOREACH(COMPONENT ${_openexr_FIND_COMPONENTS})
STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)

View File

@ -801,7 +801,6 @@ if(WITH_GPU_BUILDTIME_SHADER_BUILDER)
bf_intern_ghost
${PLATFORM_LINKLIBS}
${IMATH_LIBRARIES}
${IMATH_LIBRARY}
)
target_include_directories(shader_builder PRIVATE ${INC} ${CMAKE_CURRENT_BINARY_DIR})