Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
61 changes: 57 additions & 4 deletions src/cmake/Config.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -20,20 +20,73 @@ 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 ()
# Static libtiff configs may likewise reference CMath::CMath (libtiff's
# libm wrapper target) without importing it.
if (NOT WIN32 AND NOT TARGET CMath::CMath)
add_library (CMath::CMath INTERFACE IMPORTED)
set_target_properties (CMath::CMath PROPERTIES
INTERFACE_LINK_LIBRARIES m)
endif ()
find_dependency(TIFF)
find_dependency(OpenEXR)
find_dependency(OpenColorIO)
if (@GIF_FOUND@)
find_dependency(GIF)
endif()
if (@JPEG_FOUND@)
find_dependency(JPEG)
endif()
if (@PNG_FOUND@)
find_dependency(PNG)
# Prefer libpng's own config, whose static/shared targets a static
# OIIO export may reference (e.g. PNG::png_static); fall back to
# the FindPNG module.
find_package (PNG CONFIG QUIET)
if (NOT TARGET PNG::PNG AND NOT TARGET PNG::png_static
AND NOT TARGET PNG::png_shared)
find_dependency(PNG)
endif ()
endif()
if (@WebP_FOUND@)
find_dependency(WebP CONFIG)
endif()
find_dependency(ZLIB)
if (@DCMTK_FOUND@)
find_dependency(DCMTK)
endif()
# The following have the same problem except that INTERFACE_LINK_LIBRARIES use
# TARGET_NAME_IF_EXISTS, so the error only happens on link time.
if (@OIIO_TBB@)
# Resolve targets referenced via $<TARGET_NAME_IF_EXISTS:...> too, so
# static consumer links are not silently missing libraries.
find_dependency(Threads)
if (@BZIP2_FOUND@)
find_dependency(BZip2)
endif()
if (@FREETYPE_FOUND@)
find_dependency(Freetype)
endif()
find_package (libjpeg-turbo CONFIG QUIET)
find_package (OpenJPEG CONFIG QUIET)
find_package (openjph CONFIG QUIET)
find_package (pugixml CONFIG QUIET)
# libuhdr ships no CMake config of its own, so reconstruct the imported
# target the OIIO export refers to.
if (@libuhdr_FOUND@ AND NOT TARGET libuhdr::libuhdr)
find_library (_OIIO_libuhdr_LIBRARY NAMES uhdr libuhdr)
if (_OIIO_libuhdr_LIBRARY)
add_library (libuhdr::libuhdr UNKNOWN IMPORTED)
set_target_properties (libuhdr::libuhdr PROPERTIES
IMPORTED_LOCATION "${_OIIO_libuhdr_LIBRARY}")
endif ()
endif ()
if ("@OIIO_TBB@")
find_dependency(TBB)
endif ()
endif ()
Expand Down
4 changes: 4 additions & 0 deletions src/cmake/dependency_utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,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