FindOggVorbis.cmake 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. if (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY)
  24. set(OGGVORBIS_FOUND TRUE)
  25. set(OGGVORBIS_LIBRARIES ${OGG_LIBRARY} ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBISENC_LIBRARY})
  26. set(_CMAKE_REQUIRED_LIBRARIES_TMP ${CMAKE_REQUIRED_LIBRARIES})
  27. set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${OGGVORBIS_LIBRARIES})
  28. check_library_exists(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2)
  29. set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_TMP})
  30. if (HAVE_LIBVORBISENC2)
  31. set (OGGVORBIS_VERSION 2)
  32. else (HAVE_LIBVORBISENC2)
  33. set (OGGVORBIS_VERSION 1)
  34. endif (HAVE_LIBVORBISENC2)
  35. else (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY)
  36. set (OGGVORBIS_VERSION)
  37. set(OGGVORBIS_FOUND FALSE)
  38. endif (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY)
  39. if (OGGVORBIS_FOUND)
  40. if (NOT OggVorbis_FIND_QUIETLY)
  41. message(STATUS "Found OggVorbis: ${OGGVORBIS_LIBRARIES}")
  42. endif (NOT OggVorbis_FIND_QUIETLY)
  43. else (OGGVORBIS_FOUND)
  44. if (OggVorbis_FIND_REQUIRED)
  45. message(FATAL_ERROR "Could NOT find OggVorbis libraries")
  46. endif (OggVorbis_FIND_REQUIRED)
  47. if (NOT OggVorbis_FIND_QUITELY)
  48. message(STATUS "Could NOT find OggVorbis libraries")
  49. endif (NOT OggVorbis_FIND_QUITELY)
  50. endif (OGGVORBIS_FOUND)
  51. #check_include_files(vorbis/vorbisfile.h HAVE_VORBISFILE_H)
  52. #check_library_exists(ogg ogg_page_version "" HAVE_LIBOGG)
  53. #check_library_exists(vorbis vorbis_info_init "" HAVE_LIBVORBIS)
  54. #check_library_exists(vorbisfile ov_open "" HAVE_LIBVORBISFILE)
  55. #check_library_exists(vorbisenc vorbis_info_clear "" HAVE_LIBVORBISENC)
  56. #check_library_exists(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2)
  57. #if (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC)
  58. # message(STATUS "Ogg/Vorbis found")
  59. # set (VORBIS_LIBS "-lvorbis -logg")
  60. # set (VORBISFILE_LIBS "-lvorbisfile")
  61. # set (VORBISENC_LIBS "-lvorbisenc")
  62. # set (OGGVORBIS_FOUND TRUE)
  63. # if (HAVE_LIBVORBISENC2)
  64. # set (HAVE_VORBIS 2)
  65. # else (HAVE_LIBVORBISENC2)
  66. # set (HAVE_VORBIS 1)
  67. # endif (HAVE_LIBVORBISENC2)
  68. #else (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC)
  69. # message(STATUS "Ogg/Vorbis not found")
  70. #endif (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC)