mirror of
https://github.com/opencv/opencv.git
synced 2026-09-11 04:43:22 -05:00
Merge pull request #23596 from vrabaud:libavif
Add AVIF support through libavif. #23596 This is to fix https://github.com/opencv/opencv/issues/19271 Extra: https://github.com/opencv/opencv_extra/pull/1069 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
46
cmake/OpenCVFindAVIF.cmake
Normal file
46
cmake/OpenCVFindAVIF.cmake
Normal file
@@ -0,0 +1,46 @@
|
||||
#=============================================================================
|
||||
# Find AVIF library
|
||||
#=============================================================================
|
||||
# Find the native AVIF headers and libraries.
|
||||
#
|
||||
# AVIF_INCLUDE_DIRS - where to find avif/avif.h, etc.
|
||||
# AVIF_LIBRARIES - List of libraries when using AVIF.
|
||||
# AVIF_FOUND - True if AVIF is found.
|
||||
#=============================================================================
|
||||
|
||||
# Look for the header file.
|
||||
|
||||
unset(AVIF_FOUND)
|
||||
|
||||
find_package(libavif QUIET)
|
||||
|
||||
if(TARGET avif)
|
||||
MARK_AS_ADVANCED(AVIF_INCLUDE_DIR)
|
||||
MARK_AS_ADVANCED(AVIF_LIBRARY)
|
||||
|
||||
SET(AVIF_FOUND TRUE)
|
||||
GET_TARGET_PROPERTY(AVIF_LIBRARY avif LOCATION)
|
||||
GET_TARGET_PROPERTY(AVIF_INCLUDE_DIR1 avif INCLUDE_DIRECTORIES)
|
||||
GET_TARGET_PROPERTY(AVIF_INCLUDE_DIR2 avif INTERFACE_INCLUDE_DIRECTORIES)
|
||||
set(AVIF_INCLUDE_DIR)
|
||||
if(AVIF_INCLUDE_DIR1)
|
||||
LIST(APPEND AVIF_INCLUDE_DIR ${AVIF_INCLUDE_DIR1})
|
||||
endif()
|
||||
if(AVIF_INCLUDE_DIR2)
|
||||
LIST(APPEND AVIF_INCLUDE_DIR ${AVIF_INCLUDE_DIR2})
|
||||
endif()
|
||||
else()
|
||||
FIND_PATH(AVIF_INCLUDE_DIR NAMES avif/avif.h)
|
||||
|
||||
# Look for the library.
|
||||
FIND_LIBRARY(AVIF_LIBRARY NAMES avif)
|
||||
MARK_AS_ADVANCED(AVIF_LIBRARY)
|
||||
|
||||
# handle the QUIETLY and REQUIRED arguments and set AVIF_FOUND to TRUE if
|
||||
# all listed variables are TRUE
|
||||
INCLUDE(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
|
||||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(AVIF DEFAULT_MSG AVIF_LIBRARY AVIF_INCLUDE_DIR)
|
||||
|
||||
SET(AVIF_LIBRARIES ${AVIF_LIBRARY})
|
||||
SET(AVIF_INCLUDE_DIRS ${AVIF_INCLUDE_DIR})
|
||||
endif()
|
||||
Reference in New Issue
Block a user