FindOggVorbis.cmake 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. # - Try to find the OggVorbis libraries
  2. # Once done this will define
  3. #
  4. # OGGVORBIS_FOUND - system has OggVorbis
  5. # OGGVORBIS_VERSION - set either to 1 or 2
  6. # OGGVORBIS_INCLUDE_DIR - the OggVorbis include directory
  7. # OGGVORBIS_LIBRARIES - The libraries needed to use OggVorbis
  8. # OGG_LIBRARY - The Ogg library
  9. # VORBIS_LIBRARY - The Vorbis library
  10. # VORBISFILE_LIBRARY - The VorbisFile library
  11. # VORBISENC_LIBRARY - The VorbisEnc library
  12. # Copyright (c) 2006, Richard Laerkaeng, <richard@goteborg.utfors.se>
  13. #
  14. # Redistribution and use is allowed according to the terms of the BSD license.
  15. # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
  16. include (CheckLibraryExists)
  17. find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h)
  18. find_path(OGG_INCLUDE_DIR ogg/ogg.h)
  19. find_library(OGG_LIBRARY NAMES ogg)
  20. find_library(VORBIS_LIBRARY NAMES vorbis)
  21. find_library(VORBISFILE_LIBRARY NAMES vorbisfile)
  22. find_library(VORBISENC_LIBRARY NAMES vorbisenc)
  23. message(VORBIS_INCLUDE_DIR: ${VORBIS_INCLUDE_DIR})
  24. message(VORBIS_LIBRARY: ${VORBIS_LIBRARY})
  25. mark_as_advanced(VORBIS_INCLUDE_DIR OGG_INCLUDE_DIR
  26. OGG_LIBRARY VORBIS_LIBRARY VORBISFILE_LIBRARY VORBISENC_LIBRARY)
  27. if (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY)
  28. set(OGGVORBIS_FOUND TRUE)
  29. set(OGGVORBIS_LIBRARIES ${OGG_LIBRARY} ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBISENC_LIBRARY})
  30. set(_CMAKE_REQUIRED_LIBRARIES_TMP ${CMAKE_REQUIRED_LIBRARIES})
  31. set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${OGGVORBIS_LIBRARIES})
  32. check_library_exists(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2)
  33. set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_TMP})
  34. if (HAVE_LIBVORBISENC2)
  35. set (OGGVORBIS_VERSION 2)
  36. else (HAVE_LIBVORBISENC2)
  37. set (OGGVORBIS_VERSION 1)
  38. endif (HAVE_LIBVORBISENC2)
  39. else (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY)
  40. set (OGGVORBIS_VERSION)
  41. set(OGGVORBIS_FOUND FALSE)
  42. endif (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY)
  43. if (OGGVORBIS_FOUND)
  44. if (NOT OggVorbis_FIND_QUIETLY)
  45. message(STATUS "Found OggVorbis: ${OGGVORBIS_LIBRARIES}")
  46. endif (NOT OggVorbis_FIND_QUIETLY)
  47. else (OGGVORBIS_FOUND)
  48. if (OggVorbis_FIND_REQUIRED)
  49. message(FATAL_ERROR "Could NOT find OggVorbis libraries")
  50. endif (OggVorbis_FIND_REQUIRED)
  51. if (NOT OggVorbis_FIND_QUITELY)
  52. message(STATUS "Could NOT find OggVorbis libraries")
  53. endif (NOT OggVorbis_FIND_QUITELY)
  54. endif (OGGVORBIS_FOUND)
  55. #check_include_files(vorbis/vorbisfile.h HAVE_VORBISFILE_H)
  56. #check_library_exists(ogg ogg_page_version "" HAVE_LIBOGG)
  57. #check_library_exists(vorbis vorbis_info_init "" HAVE_LIBVORBIS)
  58. #check_library_exists(vorbisfile ov_open "" HAVE_LIBVORBISFILE)
  59. #check_library_exists(vorbisenc vorbis_info_clear "" HAVE_LIBVORBISENC)
  60. #check_library_exists(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2)
  61. #if (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC)
  62. # message(STATUS "Ogg/Vorbis found")
  63. # set (VORBIS_LIBS "-lvorbis -logg")
  64. # set (VORBISFILE_LIBS "-lvorbisfile")
  65. # set (VORBISENC_LIBS "-lvorbisenc")
  66. # set (OGGVORBIS_FOUND TRUE)
  67. # if (HAVE_LIBVORBISENC2)
  68. # set (HAVE_VORBIS 2)
  69. # else (HAVE_LIBVORBISENC2)
  70. # set (HAVE_VORBIS 1)
  71. # endif (HAVE_LIBVORBISENC2)
  72. #else (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC)
  73. # message(STATUS "Ogg/Vorbis not found")
  74. #endif (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC)