/CMakeModules/FindOggVorbis.cmake

http://github.com/tomahawk-player/tomahawk · CMake · 89 lines · 37 code · 17 blank · 35 comment · 9 complexity · 8b682de848d5bd0834f407e55c9f5fe6 MD5 · raw file

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