Imported Upstream version 1.2
[platform/upstream/alure.git] / 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_DIRS - the OggVorbis include directories
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
13 # Copyright (c) 2006, Richard Laerkaeng, <richard@goteborg.utfors.se>
14 #
15 # Redistribution and use is allowed according to the terms of the BSD license.
16 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
17
18
19 include (CheckFunctionExists)
20
21 find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h)
22 find_path(OGG_INCLUDE_DIR ogg/ogg.h)
23
24 find_library(OGG_LIBRARY NAMES ogg)
25 find_library(VORBIS_LIBRARY NAMES vorbis)
26 find_library(VORBISFILE_LIBRARY NAMES vorbisfile)
27 find_library(VORBISENC_LIBRARY NAMES vorbisenc)
28
29 mark_as_advanced(VORBIS_INCLUDE_DIR OGG_INCLUDE_DIR
30                  OGG_LIBRARY VORBIS_LIBRARY VORBISFILE_LIBRARY VORBISENC_LIBRARY)
31
32
33 if(VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY)
34    set(OGGVORBIS_FOUND TRUE)
35
36    set(OGGVORBIS_LIBRARIES ${OGG_LIBRARY} ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBISENC_LIBRARY})
37    set(OGGVORBIS_INCLUDE_DIRS ${OGG_INCLUDE_DIR} ${VORBIS_INCLUDE_DIR})
38
39    set(_CMAKE_REQUIRED_LIBRARIES_TMP ${CMAKE_REQUIRED_LIBRARIES})
40    set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${OGGVORBIS_LIBRARIES})
41    check_function_exists(vorbis_bitrate_addblock HAVE_LIBVORBISENC2)
42    set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_TMP})
43
44    if(HAVE_LIBVORBISENC2)
45       set(OGGVORBIS_VERSION 2)
46    else(HAVE_LIBVORBISENC2)
47       set(OGGVORBIS_VERSION 1)
48    endif(HAVE_LIBVORBISENC2)
49
50 else(VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY)
51    set(OGGVORBIS_VERSION)
52    set(OGGVORBIS_FOUND FALSE)
53 endif(VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY)
54
55
56 if(OGGVORBIS_FOUND)
57    if(NOT OggVorbis_FIND_QUIETLY)
58       message(STATUS "Found OggVorbis: ${OGGVORBIS_LIBRARIES}")
59    endif(NOT OggVorbis_FIND_QUIETLY)
60 else(OGGVORBIS_FOUND)
61    if(OggVorbis_FIND_REQUIRED)
62       message(FATAL_ERROR "Could NOT find OggVorbis libraries")
63    endif(OggVorbis_FIND_REQUIRED)
64    if(NOT OggVorbis_FIND_QUITELY)
65       message(STATUS "Could NOT find OggVorbis libraries")
66    endif(NOT OggVorbis_FIND_QUITELY)
67 endif(OGGVORBIS_FOUND)