From 3adbebe0df1e6f154baf6e14aa37593855efa046 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Tue, 28 Mar 2023 08:34:50 +0200 Subject: [PATCH 1/3] CMake: Disable Options Depeding on OpenEXR dependecies. OpenEXR has some dependecies that other other modules in Blender requires. When disabling OpenEXR these dependecies could not match and building blender would fail. This PR disables the next options when WITH_IMAGE_OPENEXR=Off - `WITH_OPENVDB` - `WITH_ALEMBIC` - `WITH_VULKAN_BACKEND` - `WITH_CYCLES_OSL` Additionally windows stores the IMath libraries in `IMATH_LIBRARIES` Linux and Mac stored the IMath libraries in `IMATH_LIBRARY`. This change will also adds `IMATH_LIBRARIES` variable to all platforms. --- CMakeLists.txt | 7 ++++--- build_files/cmake/Modules/FindOpenEXR.cmake | 8 +++++--- source/blender/gpu/CMakeLists.txt | 1 - 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1feb27f8356..97456d9e6fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/build_files/cmake/Modules/FindOpenEXR.cmake b/build_files/cmake/Modules/FindOpenEXR.cmake index bbc1e11539f..3e301e20f09 100644 --- a/build_files/cmake/Modules/FindOpenEXR.cmake +++ b/build_files/cmake/Modules/FindOpenEXR.cmake @@ -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) # 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) diff --git a/source/blender/gpu/CMakeLists.txt b/source/blender/gpu/CMakeLists.txt index aefa41ccdc5..d03f538e6cf 100644 --- a/source/blender/gpu/CMakeLists.txt +++ b/source/blender/gpu/CMakeLists.txt @@ -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}) -- 2.30.2 From db01cb772030f28724d200f7b07afb588c083301 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Thu, 30 Mar 2023 07:21:25 +0200 Subject: [PATCH 2/3] Add support for OpenEXR 2.0 libraries. --- build_files/cmake/Modules/FindOpenEXR.cmake | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/build_files/cmake/Modules/FindOpenEXR.cmake b/build_files/cmake/Modules/FindOpenEXR.cmake index 3e301e20f09..480b8778414 100644 --- a/build_files/cmake/Modules/FindOpenEXR.cmake +++ b/build_files/cmake/Modules/FindOpenEXR.cmake @@ -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) # 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) -- 2.30.2 From 04956a01bdec153caea84507a58ed7093ad1435e Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Thu, 30 Mar 2023 07:24:31 +0200 Subject: [PATCH 3/3] Cleanup. --- CMakeLists.txt | 2 ++ build_files/cmake/Modules/FindOpenEXR.cmake | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 97456d9e6fa..41bd76e0f5a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -953,6 +953,7 @@ if(WITH_CYCLES_DEVICE_HIP) set(WITH_HIP_DYNLOAD ON) endif() + # ----------------------------------------------------------------------------- # Check if Sub-modules are Cloned @@ -1234,6 +1235,7 @@ if(WITH_METAL_BACKEND) # build_files/cmake/platform/platform_apple.cmake endif() + # ----------------------------------------------------------------------------- # Configure OpenMP diff --git a/build_files/cmake/Modules/FindOpenEXR.cmake b/build_files/cmake/Modules/FindOpenEXR.cmake index 480b8778414..0f840ff2af0 100644 --- a/build_files/cmake/Modules/FindOpenEXR.cmake +++ b/build_files/cmake/Modules/FindOpenEXR.cmake @@ -120,8 +120,8 @@ 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 also add it to the OpenEXR includes and libraries, as 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. # Find include directory FIND_PATH(IMATH_INCLUDE_DIR @@ -174,7 +174,6 @@ 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) -- 2.30.2