FindOpus.cmake 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. # - Find opus
  2. # Find the native opus includes and libraries
  3. #
  4. # OPUS_INCLUDE_DIRS - where to find opus.h, etc.
  5. # OPUS_LIBRARIES - List of libraries when using opus.
  6. # OPUS_FOUND - True if Opus found.
  7. if (OPUS_INCLUDE_DIR)
  8. # Already in cache, be silent
  9. set(OPUS_FIND_QUIETLY TRUE)
  10. endif ()
  11. find_package (Ogg QUIET)
  12. find_package (PkgConfig QUIET)
  13. pkg_check_modules(PC_OPUS QUIET opus>=1.1)
  14. set (OPUS_VERSION ${PC_OPUS_VERSION})
  15. find_path (OPUS_INCLUDE_DIR opus/opus.h
  16. HINTS
  17. ${PC_OPUS_INCLUDEDIR}
  18. ${PC_OPUS_INCLUDE_DIRS}
  19. ${OPUS_ROOT}
  20. )
  21. # MSVC built opus may be named opus_static.
  22. # The provided project files name the library with the lib prefix.
  23. find_library (OPUS_LIBRARY
  24. NAMES
  25. opus
  26. opus_static
  27. libopus
  28. libopus_static
  29. HINTS
  30. ${PC_OPUS_LIBDIR}
  31. ${PC_OPUS_LIBRARY_DIRS}
  32. ${OPUS_ROOT}
  33. )
  34. # Handle the QUIETLY and REQUIRED arguments and set OPUS_FOUND
  35. # to TRUE if all listed variables are TRUE.
  36. include(FindPackageHandleStandardArgs)
  37. find_package_handle_standard_args (Opus
  38. REQUIRED_VARS
  39. OPUS_LIBRARY
  40. OPUS_INCLUDE_DIR
  41. OGG_FOUND
  42. VERSION_VAR
  43. OPUS_VERSION
  44. )
  45. if (OPUS_FOUND)
  46. set (OPUS_LIBRARIES ${OPUS_LIBRARY})
  47. set (OPUS_INCLUDE_DIRS ${OPUS_INCLUDE_DIR})
  48. if (NOT TARGET Opus::opus)
  49. add_library (Opus::opus UNKNOWN IMPORTED)
  50. set_target_properties (Opus::opus PROPERTIES
  51. INTERFACE_INCLUDE_DIRECTORIES "${OPUS_INCLUDE_DIRS}"
  52. IMPORTED_LOCATION "${OPUS_LIBRARIES}"
  53. )
  54. endif ()
  55. endif ()
  56. mark_as_advanced(OPUS_INCLUDE_DIR OPUS_LIBRARY)