From c9cbf03ec49fb0f4b4a26aa43c5b995bf0bc4288 Mon Sep 17 00:00:00 2001 From: Sebastian Parborg Date: Wed, 20 May 2026 17:10:46 +0200 Subject: [PATCH] fix(cmake): Make the cmake config files always pull in the required libraries Without doing this, we could get link time errors as openimageio doesn't pull in the libraries correctly when using modern cmake targets. It would work when libraries have been installed globally on the system. But we shouldn't rely on the linker automagically finding the libraries in `/usr/lib` for example. Signed-off-by: Sebastian Parborg --- src/cmake/Config.cmake.in | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/cmake/Config.cmake.in b/src/cmake/Config.cmake.in index 2620994b38..ee82718f7d 100644 --- a/src/cmake/Config.cmake.in +++ b/src/cmake/Config.cmake.in @@ -16,26 +16,29 @@ if (NOT @fmt_LOCAL_BUILD@ AND NOT @OIIO_INTERNALIZE_FMT@) find_dependency(fmt) endif () +find_dependency(OpenColorIO) +find_dependency(OpenEXR) +if (@OIIO_TBB@) + find_dependency(TBB) +endif () +if (@JPEG_FOUND@) + find_dependency(JPEG) +endif() +if (@WebP_FOUND@) + find_dependency(WebP) +endif() + 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. find_dependency(TIFF) - find_dependency(OpenColorIO) - if (@JPEG_FOUND@) - find_dependency(JPEG) - endif() if (@PNG_FOUND@) find_dependency(PNG) endif() 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@) - find_dependency(TBB) - endif () endif () # Compute the installation prefix relative to this file. Note that cmake files are installed