blender/build_files/build_environment/cmake/openjph.cmake
Sebastian Parborg 0243d0c2fa Deps: Fix fragile openexr dependency linking
When working on the 5.1 library updates, I noticed that quite a few places in Blender where OpenEXR (and libraries depending on OpenEXR) didn't really seem to pull in all of the required libraries properly.
While we are working around this currently, I felt like actually doing the proper thing and using the new cmake libraries interfaces would be the best way forward as we then can rely on them pulling in all needed dependencies by themselves.

To be able to use the .cmake files, two patches are needed:

1. `openexr_deflate_cmake.diff`:
This fixes the cmake install targets to not require libdeflate if it has been complied into openexr as a static library.
2. `osl_relative_inc_cmake.diff`:
This makes it so the library targets no longer uses absolute paths for the include directories. They now use relative paths so that they can be relocated properly.

Co-authored-by: Ray Molenkamp <github@lazydodo.com>
Co-authored-by: Jonas Holzman <jonas@blender.org>
Pull Request: https://projects.blender.org/blender/blender/pulls/153424
2026-02-05 23:10:02 +01:00

46 lines
1.2 KiB
CMake

# SPDX-FileCopyrightText: 2025 Blender Authors
#
# SPDX-License-Identifier: GPL-2.0-or-later
set(OPENJPH_EXTRA_ARGS
-DOJPH_BUILD_TESTS=OFF
-DOJPH_ENABLE_TIFF_SUPPORT=OFF
-DOJPH_BUILD_EXECUTABLES=OFF
-DBUILD_SHARED_LIBS=ON
)
ExternalProject_Add(external_openjph
URL file://${PACKAGE_DIR}/${OPENJPH_FILE}
DOWNLOAD_DIR ${DOWNLOAD_DIR}
URL_HASH ${OPENJPH_HASH_TYPE}=${OPENJPH_HASH}
CMAKE_GENERATOR ${PLATFORM_ALT_GENERATOR}
PREFIX ${BUILD_DIR}/openjph
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${LIBDIR}/openjph
${DEFAULT_CMAKE_FLAGS}
${OPENJPH_EXTRA_ARGS}
PATCH_COMMAND
${PATCH_CMD} -p 1 -N -d
${BUILD_DIR}/openjph/src/external_openjph/ <
${PATCH_DIR}/openjph_table_init_243.diff
INSTALL_DIR ${LIBDIR}/openjph
)
if(WIN32)
ExternalProject_Add_Step(external_openjph after_install
COMMAND ${CMAKE_COMMAND} -E copy_directory
${LIBDIR}/openjph
${HARVEST_TARGET}/openjph
DEPENDEES install
)
else()
harvest(external_openjph openjph/include openjph/include "*.h")
# Cmake files first because harvest_rpath_lib edits them.
harvest(external_openjph openjph/lib/cmake/openjph openjph/lib/cmake/openjph "*.cmake")
harvest_rpath_lib(external_openjph openjph/lib openjph/lib "*${SHAREDLIBEXT}*")
endif()