Skip to content
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ if (IGNORE_HOMEBREWED_DEPS)
)
endforeach ()

# Also ignore the whole prefixes, which (unlike CMAKE_IGNORE_PATH) is
# honored by config-package searches, and is forwarded to local
# dependency child builds so they can't quietly resolve a Homebrew
# package (e.g. a mismatched Imath) that we ourselves are ignoring.
list (APPEND CMAKE_IGNORE_PREFIX_PATH ${HOMEBREW_PREFIXES})

message (STATUS "CMAKE_IGNORE_PATH: ${CMAKE_IGNORE_PATH}")
endif ()

Expand Down
10 changes: 10 additions & 0 deletions src/cmake/Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ if (NOT @BUILD_SHARED_LIBS@)
# This is required in static library builds, as e.g. PNG::PNG appears among
# INTERFACE_LINK_LIBRARIES. If the project does not know about PNG target, it will cause
# configuration error about unknown targets being linked in.
# Static libtiff configs may reference this target without importing it.
# https://gitlab.com/libtiff/libtiff/-/work_items/871
if (NOT TARGET Deflate::Deflate)
find_package (libdeflate CONFIG QUIET)
if (TARGET libdeflate::libdeflate_static)
add_library (Deflate::Deflate ALIAS libdeflate::libdeflate_static)
elseif (TARGET libdeflate::libdeflate_shared)
add_library (Deflate::Deflate ALIAS libdeflate::libdeflate_shared)
endif ()
endif ()
find_dependency(TIFF)
find_dependency(OpenColorIO)
if (@JPEG_FOUND@)
Expand Down
62 changes: 62 additions & 0 deletions src/cmake/build_JXL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Copyright Contributors to the OpenImageIO project.
# SPDX-License-Identifier: Apache-2.0
# https://github.com/AcademySoftwareFoundation/OpenImageIO

######################################################################
# JPEG XL (libjxl) by hand!
######################################################################

set_cache (JXL_BUILD_VERSION 0.12.0 "libjxl version for local builds")
set (JXL_GIT_REPOSITORY "https://github.com/libjxl/libjxl")
set_cache (JXL_GIT_TAG "v${JXL_BUILD_VERSION}" "Git branch or tag")
set_cache (JXL_GIT_COMMIT "a7a9c787341cf703dede03c2009fa460cae5e5df"
"commit hash to verify tag against")

# Build libjxl shared: its bundled brotli/highway/skcms are built static
# and folded in, so the installed libraries are self-contained and match
# what OIIO's FindJXL module expects to link (jxl + jxl_threads).
set_cache (JXL_BUILD_SHARED_LIBS ON
"Should a local JXL build, if necessary, build shared libraries" ADVANCED)

build_dependency_with_cmake(JXL
VERSION ${JXL_BUILD_VERSION}
GIT_REPOSITORY ${JXL_GIT_REPOSITORY}
GIT_TAG ${JXL_GIT_TAG}
GIT_COMMIT ${JXL_GIT_COMMIT}
# libjxl vendors its required dependencies as submodules. Only these
# three are needed for the libraries themselves; skcms doubles as the
# color-management backend so no system lcms2 is required.
GIT_SUBMODULES third_party/brotli third_party/highway third_party/skcms
CMAKE_ARGS
-D BUILD_SHARED_LIBS=${JXL_BUILD_SHARED_LIBS}
-D CMAKE_POSITION_INDEPENDENT_CODE=ON
-D CMAKE_INSTALL_LIBDIR=lib
# Libraries only -- no tools, tests, docs, or bindings.
-D BUILD_TESTING=OFF
-D JPEGXL_ENABLE_TOOLS=OFF
-D JPEGXL_ENABLE_EXAMPLES=OFF
-D JPEGXL_ENABLE_BENCHMARK=OFF
-D JPEGXL_ENABLE_MANPAGES=OFF
-D JPEGXL_ENABLE_DOXYGEN=OFF
-D JPEGXL_ENABLE_JNI=OFF
-D JPEGXL_ENABLE_FUZZERS=OFF
# No optional integrations: OIIO's plugin uses the core codestream
# API only. (Transcoding to/from legacy JPEG and the sjpeg/OpenEXR
# helpers are tool/library features OIIO doesn't touch.)
-D JPEGXL_ENABLE_SJPEG=OFF
-D JPEGXL_ENABLE_OPENEXR=OFF
-D JPEGXL_ENABLE_TRANSCODE_JPEG=OFF
# Color management via the bundled skcms submodule.
-D JPEGXL_ENABLE_SKCMS=ON
)

# Set some things up that we'll need for a subsequent find_package to work

set (JXL_ROOT ${JXL_LOCAL_INSTALL_DIR})

# Signal to caller that we need to find again at the installed location
set (JXL_REFIND TRUE)

if (JXL_BUILD_SHARED_LIBS)
install_local_dependency_libs (JXL jxl)
endif ()
23 changes: 22 additions & 1 deletion src/cmake/dependency_utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ macro (build_dependency_with_cmake pkgname)
# singleValueKeywords:
"GIT_REPOSITORY;GIT_TAG;GIT_COMMIT;VERSION;SOURCE_SUBDIR;QUIET"
# multiValueKeywords:
"CMAKE_ARGS"
"CMAKE_ARGS;GIT_SUBMODULES"
# argsToParse:
${ARGN})

Expand Down Expand Up @@ -701,6 +701,23 @@ macro (build_dependency_with_cmake pkgname)
"${pkgname}: Neither GIT_TAG nor GIT_COMMIT was specified.")
endif ()

# Initialize any requested submodules (paths relative to the package
# source dir). This runs after the checkout above, so the submodule
# commits are the ones pinned by the verified superproject commit and
# inherit its supply-chain guarantee.
if (NOT "${_pkg_GIT_SUBMODULES}" STREQUAL "")
execute_process(
COMMAND ${GIT_EXECUTABLE} submodule update --init --depth 1 -- ${_pkg_GIT_SUBMODULES}
WORKING_DIRECTORY ${${pkgname}_LOCAL_SOURCE_DIR}
RESULT_VARIABLE _pkg_submodule_result
ERROR_VARIABLE _pkg_submodule_errors
ERROR_STRIP_TRAILING_WHITESPACE
${_pkg_exec_quiet})
if (NOT _pkg_submodule_result EQUAL 0)
message (FATAL_ERROR "${pkgname}: git submodule update failed: ${_pkg_submodule_errors}")
endif ()
endif ()

# Configure the package
if (${PROJECT_NAME}_DEPENDENCY_BUILD_VERBOSE)
set (_pkg_cmake_verbose -DCMAKE_VERBOSE_MAKEFILE=ON
Expand Down Expand Up @@ -731,6 +748,10 @@ macro (build_dependency_with_cmake pkgname)
string(REPLACE ";" "\\;" CMAKE_IGNORE_PATH_ESCAPED "${CMAKE_IGNORE_PATH}")
list(APPEND _pkg_CMAKE_ARGS "-DCMAKE_IGNORE_PATH=${CMAKE_IGNORE_PATH_ESCAPED}")
endif()
if (CMAKE_IGNORE_PREFIX_PATH)
string(REPLACE ";" "\\;" CMAKE_IGNORE_PREFIX_PATH_ESCAPED "${CMAKE_IGNORE_PREFIX_PATH}")
list(APPEND _pkg_CMAKE_ARGS "-DCMAKE_IGNORE_PREFIX_PATH=${CMAKE_IGNORE_PREFIX_PATH_ESCAPED}")
endif()

# Pass along any CMAKE_MSVC_RUNTIME_LIBRARY
if (WIN32 AND CMAKE_MSVC_RUNTIME_LIBRARY)
Expand Down
12 changes: 12 additions & 0 deletions src/cmake/externalpackages.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,18 @@ endif ()
checked_find_package (libuhdr
VERSION_MIN 1.3)

# Static libtiff configs may reference Deflate::Deflate without importing it
# (https://gitlab.com/libtiff/libtiff/-/work_items/871), so libdeflate must be
# located before TIFF discovery. In particular, a previously auto-built static
# TIFF rediscovered from the local deps cache needs this; the libdeflate found
# during build_TIFF.cmake does not carry over to later reconfigures.
if (NOT TARGET Deflate::Deflate)
checked_find_package (libdeflate
VERSION_MIN 1.18)
alias_library_if_not_exists (Deflate::Deflate libdeflate::libdeflate_static)
alias_library_if_not_exists (Deflate::Deflate libdeflate::libdeflate_shared)
endif ()

checked_find_package (TIFF REQUIRED
VERSION_MIN 4.0
RECOMMEND_MIN 4.5
Expand Down
Loading