OpenCVFindAVIF.cmake 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. #=============================================================================
  2. # Find AVIF library
  3. #=============================================================================
  4. # Find the native AVIF headers and libraries.
  5. #
  6. # AVIF_INCLUDE_DIRS - where to find avif/avif.h, etc.
  7. # AVIF_LIBRARIES - List of libraries when using AVIF.
  8. # AVIF_FOUND - True if AVIF is found.
  9. #=============================================================================
  10. # Look for the header file.
  11. unset(AVIF_FOUND)
  12. find_package(libavif QUIET)
  13. if(TARGET avif)
  14. MARK_AS_ADVANCED(AVIF_INCLUDE_DIR)
  15. MARK_AS_ADVANCED(AVIF_LIBRARY)
  16. SET(AVIF_FOUND TRUE)
  17. GET_TARGET_PROPERTY(AVIF_LIBRARY avif LOCATION)
  18. GET_TARGET_PROPERTY(AVIF_INCLUDE_DIR1 avif INCLUDE_DIRECTORIES)
  19. GET_TARGET_PROPERTY(AVIF_INCLUDE_DIR2 avif INTERFACE_INCLUDE_DIRECTORIES)
  20. set(AVIF_INCLUDE_DIR)
  21. if(AVIF_INCLUDE_DIR1)
  22. LIST(APPEND AVIF_INCLUDE_DIR ${AVIF_INCLUDE_DIR1})
  23. endif()
  24. if(AVIF_INCLUDE_DIR2)
  25. LIST(APPEND AVIF_INCLUDE_DIR ${AVIF_INCLUDE_DIR2})
  26. endif()
  27. else()
  28. FIND_PATH(AVIF_INCLUDE_DIR NAMES avif/avif.h)
  29. # Look for the library.
  30. FIND_LIBRARY(AVIF_LIBRARY NAMES avif)
  31. MARK_AS_ADVANCED(AVIF_LIBRARY)
  32. # handle the QUIETLY and REQUIRED arguments and set AVIF_FOUND to TRUE if
  33. # all listed variables are TRUE
  34. INCLUDE(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
  35. FIND_PACKAGE_HANDLE_STANDARD_ARGS(AVIF DEFAULT_MSG AVIF_LIBRARY AVIF_INCLUDE_DIR)
  36. SET(AVIF_LIBRARIES ${AVIF_LIBRARY})
  37. SET(AVIF_INCLUDE_DIRS ${AVIF_INCLUDE_DIR})
  38. endif()