1 # - Try to find the OggVorbis libraries
2 # Once done this will define
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
13 # Copyright (c) 2006, Richard Laerkaeng, <richard@goteborg.utfors.se>
15 # Redistribution and use is allowed according to the terms of the BSD license.
16 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
19 include (CheckFunctionExists)
21 find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h)
22 find_path(OGG_INCLUDE_DIR ogg/ogg.h)
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)
29 mark_as_advanced(VORBIS_INCLUDE_DIR OGG_INCLUDE_DIR
30 OGG_LIBRARY VORBIS_LIBRARY VORBISFILE_LIBRARY VORBISENC_LIBRARY)
33 if(VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY)
34 set(OGGVORBIS_FOUND TRUE)
36 set(OGGVORBIS_LIBRARIES ${OGG_LIBRARY} ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBISENC_LIBRARY})
37 set(OGGVORBIS_INCLUDE_DIRS ${OGG_INCLUDE_DIR} ${VORBIS_INCLUDE_DIR})
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})
44 if(HAVE_LIBVORBISENC2)
45 set(OGGVORBIS_VERSION 2)
46 else(HAVE_LIBVORBISENC2)
47 set(OGGVORBIS_VERSION 1)
48 endif(HAVE_LIBVORBISENC2)
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)
57 if(NOT OggVorbis_FIND_QUIETLY)
58 message(STATUS "Found OggVorbis: ${OGGVORBIS_LIBRARIES}")
59 endif(NOT OggVorbis_FIND_QUIETLY)
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)