FindOggVorbis.cmake 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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. if(WIN64)
  20. find_library(OGG_LIBRARY NAMES ogg_static Ogg_static libogg_static PATHS "${DEPENDENCY_FOLDER}/lib")
  21. find_library(VORBIS_LIBRARY NAMES vorbis_static Vorbis_static libvorbis_static PATHS "${DEPENDENCY_FOLDER}/lib")
  22. find_library(VORBISFILE_LIBRARY NAMES vorbisfile_static libvorbisfile_static PATHS "${DEPENDENCY_FOLDER}/lib")
  23. else(WIN64)
  24. find_library(OGG_LIBRARY NAMES ogg)
  25. find_library(VORBIS_LIBRARY NAMES vorbis)
  26. find_library(VORBISFILE_LIBRARY NAMES vorbisfile)
  27. find_library(OGG_LIBRARY NAMES ogg Ogg libogg PATHS "${DEPENDENCY_FOLDER}/lib")
  28. find_library(VORBIS_LIBRARY NAMES vorbis Vorbis libvorbis PATHS "${DEPENDENCY_FOLDER}/lib")
  29. find_library(VORBISFILE_LIBRARY NAMES vorbisfile libvorbisfile PATHS "${DEPENDENCY_FOLDER}/lib")
  30. endif(WIN64)
  31. if (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY)
  32. set(OGGVORBIS_FOUND TRUE)
  33. # [sommer] (for SuperTux) reversed order of libraries, so that cmake 2.4.5 for Windows generates an MSYS Makefile that will link correctly
  34. # set(OGGVORBIS_LIBRARIES ${OGG_LIBRARY} ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY})
  35. set(OGGVORBIS_LIBRARIES ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${OGG_LIBRARY})
  36. set(_CMAKE_REQUIRED_LIBRARIES_TMP ${CMAKE_REQUIRED_LIBRARIES})
  37. set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${OGGVORBIS_LIBRARIES})
  38. check_library_exists(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2)
  39. set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_TMP})
  40. if (HAVE_LIBVORBISENC2)
  41. set (OGGVORBIS_VERSION 2)
  42. else (HAVE_LIBVORBISENC2)
  43. set (OGGVORBIS_VERSION 1)
  44. endif (HAVE_LIBVORBISENC2)
  45. else (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY)
  46. set (OGGVORBIS_VERSION)
  47. set(OGGVORBIS_FOUND FALSE)
  48. endif (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY)
  49. if (OGGVORBIS_FOUND)
  50. if (NOT OggVorbis_FIND_QUIETLY)
  51. message(STATUS "Found OggVorbis: ${OGGVORBIS_LIBRARIES}")
  52. endif (NOT OggVorbis_FIND_QUIETLY)
  53. else (OGGVORBIS_FOUND)
  54. if (OggVorbis_FIND_REQUIRED)
  55. message(FATAL_ERROR "Could NOT find OggVorbis libraries")
  56. endif (OggVorbis_FIND_REQUIRED)
  57. if (NOT OggVorbis_FIND_QUIETLY)
  58. message(STATUS "Could NOT find OggVorbis libraries")
  59. endif (NOT OggVorbis_FIND_QUIETLY)
  60. endif (OGGVORBIS_FOUND)
  61. #check_include_files(vorbis/vorbisfile.h HAVE_VORBISFILE_H)
  62. #check_library_exists(ogg ogg_page_version "" HAVE_LIBOGG)
  63. #check_library_exists(vorbis vorbis_info_init "" HAVE_LIBVORBIS)
  64. #check_library_exists(vorbisfile ov_open "" HAVE_LIBVORBISFILE)
  65. #check_library_exists(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2)
  66. #if (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE)
  67. # message(STATUS "Ogg/Vorbis found")
  68. # set (VORBIS_LIBS "-lvorbis -logg")
  69. # set (VORBISFILE_LIBS "-lvorbisfile")
  70. # set (OGGVORBIS_FOUND TRUE)
  71. # if (HAVE_LIBVORBISENC2)
  72. # set (HAVE_VORBIS 2)
  73. # else (HAVE_LIBVORBISENC2)
  74. # set (HAVE_VORBIS 1)
  75. # endif (HAVE_LIBVORBISENC2)
  76. #else (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE)
  77. # message(STATUS "Ogg/Vorbis not found")
  78. #endif (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE)