FindOgg.cmake 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #[=======================================================================[.rst:
  2. FindOgg
  3. --------
  4. Find the native Ogg includes and library.
  5. IMPORTED Targets
  6. ^^^^^^^^^^^^^^^^
  7. This module defines :prop_tgt:`IMPORTED` target ``Ogg::ogg``, if
  8. Ogg has been found.
  9. Result Variables
  10. ^^^^^^^^^^^^^^^^
  11. This module defines the following variables:
  12. ::
  13. OGG_INCLUDE_DIRS - where to find ogg.h, etc.
  14. OGG_LIBRARIES - List of libraries when using ogg.
  15. OGG_FOUND - True if ogg found.
  16. ::
  17. OGG_VERSION_STRING - The version of ogg found (x.y.z)
  18. Hints
  19. ^^^^^
  20. A user may set ``OGG_ROOT`` to a ogg installation root to tell this
  21. module where to look.
  22. #]=======================================================================]
  23. if(OGG_INCLUDE_DIR)
  24. # Already in cache, be silent
  25. set(OGG_FIND_QUIETLY TRUE)
  26. endif()
  27. find_package(PkgConfig QUIET)
  28. pkg_check_modules(PC_OGG QUIET ogg)
  29. set(OGG_VERSION_STRING ${PC_OGG_VERSION})
  30. find_path(OGG_INCLUDE_DIR ogg/ogg.h
  31. HINTS
  32. ${PC_OGG_INCLUDEDIR}
  33. ${PC_OGG_INCLUDE_DIRS}
  34. ${OGG_ROOT}
  35. PATH_SUFFIXES
  36. include
  37. )
  38. # MSVC built ogg may be named ogg_static.
  39. # The provided project files name the library with the lib prefix.
  40. find_library(OGG_LIBRARY
  41. NAMES
  42. ogg
  43. ogg_static
  44. libogg
  45. libogg_static
  46. HINTS
  47. ${PC_OGG_LIBDIR}
  48. ${PC_OGG_LIBRARY_DIRS}
  49. ${OGG_ROOT}
  50. PATH_SUFFIXES
  51. lib
  52. )
  53. # Handle the QUIETLY and REQUIRED arguments and set OGG_FOUND
  54. # to TRUE if all listed variables are TRUE.
  55. include(FindPackageHandleStandardArgs)
  56. find_package_handle_standard_args(Ogg
  57. REQUIRED_VARS
  58. OGG_LIBRARY
  59. OGG_INCLUDE_DIR
  60. VERSION_VAR
  61. OGG_VERSION_STRING
  62. )
  63. if(OGG_FOUND)
  64. set(OGG_LIBRARIES ${OGG_LIBRARY})
  65. set(OGG_INCLUDE_DIRS ${OGG_INCLUDE_DIR})
  66. if(NOT TARGET Ogg::ogg)
  67. add_library(Ogg::ogg UNKNOWN IMPORTED)
  68. set_target_properties(Ogg::ogg PROPERTIES
  69. INTERFACE_INCLUDE_DIRECTORIES "${OGG_INCLUDE_DIRS}"
  70. IMPORTED_LOCATION "${OGG_LIBRARIES}"
  71. )
  72. endif()
  73. endif()
  74. mark_as_advanced(OGG_INCLUDE_DIR OGG_LIBRARY)