FindOggVorbis.cmake 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. ### SuperTux - Removed unused vorbisenc library
  2. # - Try to find the OggVorbis libraries
  3. # Once done this will define
  4. #
  5. # OGGVORBIS_FOUND - system has OggVorbis
  6. # OGGVORBIS_VERSION - set either to 1 or 2
  7. # OGGVORBIS_INCLUDE_DIR - the OggVorbis include directory
  8. # OGGVORBIS_LIBRARIES - The libraries needed to use OggVorbis
  9. # OGG_LIBRARY - The Ogg library
  10. # VORBIS_LIBRARY - The Vorbis library
  11. # VORBISFILE_LIBRARY - The VorbisFile 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(VORBIS_INCLUDE_DIR NAMES vorbis/vorbisfile.h PATHS "${VORBIS_INCLUDE_DIR}" "${DEPENDENCY_FOLDER}/include")
  19. find_library(OGG_LIBRARY NAMES ogg)
  20. find_library(VORBIS_LIBRARY NAMES vorbis)
  21. find_library(VORBISFILE_LIBRARY NAMES vorbisfile)
  22. find_library(OGG_LIBRARY NAMES ogg Ogg libogg PATHS "${DEPENDENCY_FOLDER}/lib")
  23. find_library(VORBIS_LIBRARY NAMES vorbis Vorbis libvorbis PATHS "${DEPENDENCY_FOLDER}/lib")
  24. find_library(VORBISFILE_LIBRARY NAMES vorbisfile libvorbisfile PATHS "${DEPENDENCY_FOLDER}/lib")
  25. if (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY)
  26. set(OGGVORBIS_FOUND TRUE)
  27. # [sommer] (for SuperTux) reversed order of libraries, so that cmake 2.4.5 for Windows generates an MSYS Makefile that will link correctly
  28. # set(OGGVORBIS_LIBRARIES ${OGG_LIBRARY} ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY})
  29. set(OGGVORBIS_LIBRARIES ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${OGG_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)
  40. set (OGGVORBIS_VERSION)
  41. set(OGGVORBIS_FOUND FALSE)
  42. endif (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_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_QUIETLY)
  52. message(STATUS "Could NOT find OggVorbis libraries")
  53. endif (NOT OggVorbis_FIND_QUIETLY)
  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(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2)
  60. #if (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE)
  61. # message(STATUS "Ogg/Vorbis found")
  62. # set (VORBIS_LIBS "-lvorbis -logg")
  63. # set (VORBISFILE_LIBS "-lvorbisfile")
  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)
  71. # message(STATUS "Ogg/Vorbis not found")
  72. #endif (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE)