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