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