FindOgg.cmake 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. # - Find ogg
  2. # Find the native ogg includes and libraries
  3. #
  4. # OGG_INCLUDE_DIRS - where to find ogg.h, etc.
  5. # OGG_LIBRARIES - List of libraries when using ogg.
  6. # OGG_FOUND - True if ogg found.
  7. if (OGG_INCLUDE_DIR)
  8. # Already in cache, be silent
  9. set(OGG_FIND_QUIETLY TRUE)
  10. endif ()
  11. find_package (PkgConfig QUIET)
  12. pkg_check_modules (PC_OGG QUIET ogg>=1.3.0)
  13. set (OGG_VERSION ${PC_OGG_VERSION})
  14. find_path (OGG_INCLUDE_DIR ogg/ogg.h
  15. HINTS
  16. ${PC_OGG_INCLUDEDIR}
  17. ${PC_OGG_INCLUDE_DIRS}
  18. ${OGG_ROOT}
  19. )
  20. # MSVC built ogg may be named ogg_static.
  21. # The provided project files name the library with the lib prefix.
  22. find_library (OGG_LIBRARY
  23. NAMES
  24. ogg
  25. ogg_static
  26. libogg
  27. libogg_static
  28. HINTS
  29. ${PC_OGG_LIBDIR}
  30. ${PC_OGG_LIBRARY_DIRS}
  31. ${OGG_ROOT}
  32. )
  33. # Handle the QUIETLY and REQUIRED arguments and set OGG_FOUND
  34. # to TRUE if all listed variables are TRUE.
  35. include (FindPackageHandleStandardArgs)
  36. find_package_handle_standard_args (Ogg
  37. REQUIRED_VARS
  38. OGG_LIBRARY
  39. OGG_INCLUDE_DIR
  40. VERSION_VAR
  41. OGG_VERSION
  42. )
  43. if (OGG_FOUND)
  44. set (OGG_LIBRARIES ${OGG_LIBRARY})
  45. set (OGG_INCLUDE_DIRS ${OGG_INCLUDE_DIR})
  46. if(NOT TARGET Ogg::ogg)
  47. add_library(Ogg::ogg UNKNOWN IMPORTED)
  48. set_target_properties(Ogg::ogg PROPERTIES
  49. INTERFACE_INCLUDE_DIRECTORIES "${OGG_INCLUDE_DIRS}"
  50. IMPORTED_LOCATION "${OGG_LIBRARIES}"
  51. )
  52. endif ()
  53. endif ()
  54. mark_as_advanced (OGG_INCLUDE_DIR OGG_LIBRARY)