Skip to content

Commit

Permalink
Use Requires.private for generated pkgconfig file
Browse files Browse the repository at this point in the history
Signed-off-by: Brecht Van Lommel <[email protected]>
  • Loading branch information
brechtvl committed Jan 11, 2024
1 parent 0924c0b commit 80fd751
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 19 deletions.
3 changes: 2 additions & 1 deletion cmake/OpenEXR.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ Name: OpenEXR
Description: OpenEXR image library
Version: @OPENEXR_VERSION@

Libs: @exr_pthread_libs@ -L${libdir} -lOpenEXR${libsuffix} -lOpenEXRUtil${libsuffix} -lOpenEXRCore${libsuffix} -lIex${libsuffix} -lIlmThread${libsuffix} @EXR_DEFLATE_LDFLAGS@
Libs: @exr_pthread_libs@ -L${libdir} -lOpenEXR${libsuffix} -lOpenEXRUtil${libsuffix} -lOpenEXRCore${libsuffix} -lIex${libsuffix} -lIlmThread${libsuffix}
Cflags: -I${includedir} -I${OpenEXR_includedir} @exr_pthread_cflags@
Requires: Imath
Requires.private: @EXR_DEFLATE_PKGCONFIG_REQUIRES@

29 changes: 11 additions & 18 deletions cmake/OpenEXRSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -161,21 +161,14 @@ if(NOT OPENEXR_FORCE_INTERNAL_DEFLATE)
#TODO: ^^ Release should not clone from main, this is a place holder
set(CMAKE_IGNORE_PATH "${CMAKE_CURRENT_BINARY_DIR}/_deps/deflate-src/config;${CMAKE_CURRENT_BINARY_DIR}/_deps/deflate-build/config")
# First try cmake config
find_package(libdeflate CONFIG)
find_package(libdeflate CONFIG QUIET)
if(libdeflate_FOUND)
if(TARGET libdeflate::libdeflate_shared)
set(EXR_DEFLATE_LIB libdeflate::libdeflate_shared)
else()
set(EXR_DEFLATE_LIB libdeflate::libdeflate_static)
endif()
set(EXR_DEFLATE_SOURCES)
set(EXR_DEFLATE_INCLUDE_DIR)
set(EXR_DEFLATE_LDFLAGS)
# Set EXR_DEFATE_LDFLAGS for OpenEXR.pc.in for static build
if(NOT BUILD_SHARED_LIBS)
get_target_property(deflate_LIBRARIES ${EXR_DEFLATE_LIB} LOCATION)
set(EXR_DEFLATE_LDFLAGS "-l${deflate_LIBRARIES}")
endif()
set(EXR_DEFLATE_VERSION ${libdeflate_VERSION})
message(STATUS "Using libdeflate from ${libdeflate_DIR}")
else()
# If not found, try pkgconfig
Expand All @@ -185,22 +178,22 @@ if(NOT OPENEXR_FORCE_INTERNAL_DEFLATE)
pkg_check_modules(deflate IMPORTED_TARGET GLOBAL libdeflate)
if(deflate_FOUND)
set(EXR_DEFLATE_LIB PkgConfig::deflate)
set(EXR_DEFLATE_SOURCES)
set(EXR_DEFLATE_INCLUDE_DIR)
set(EXR_DEFLATE_LDFLAGS)
# Set EXR_DEFATE_LDFLAGS for OpenEXR.pc.in for static build
if(NOT BUILD_SHARED_LIBS)
set(EXR_DEFLATE_LDFLAGS "-l${deflate_LIBRARIES}")
endif()
set(EXR_DEFLATE_VERSION ${deflate_VERSION})
message(STATUS "Using libdeflate from ${deflate_LINK_LIBRARIES}")
endif()
endif()
endif()
set(CMAKE_IGNORE_PATH)
endif()

if(NOT EXR_DEFLATE_LIB)
# Using internal deflate.
if(EXR_DEFLATE_LIB)
# Using external library
set(EXR_DEFLATE_SOURCES)
set(EXR_DEFLATE_INCLUDE_DIR)
# For OpenEXR.pc.in for static build
set(EXR_DEFLATE_PKGCONFIG_REQUIRES "libdeflate >= ${EXR_DEFLATE_VERSION}")
else()
# Using internal deflate
if(OPENEXR_FORCE_INTERNAL_DEFLATE)
message(STATUS "libdeflate forced internal, installing from ${OPENEXR_DEFLATE_REPO} (${OPENEXR_DEFLATE_TAG})")
else()
Expand Down

0 comments on commit 80fd751

Please sign in to comment.