1# Downloaded from: http://websvn.kde.org/trunk/KDE/kdelibs/cmake/modules/ 2# License: see the accompanying COPYING-CMAKE-SCRIPTS file 3# 4# Modifications: 5# 2008.01.16 Tobi Vollebregt -- Moved ${OGG_LIBRARY} to the back of OGGVORBIS_LIBRARIES, 6# this allows vorbis to link to ogg on MinGW. 7# -- Moved ${VORBIS_LIBRARY} just before OGGVORBIS_LIBRARIES, 8# this allows vorbis{file,enc} to link to vorbis on MinGW. 9 10# - Try to find the OggVorbis libraries 11# Once done this will define 12# 13# OGGVORBIS_FOUND - system has OggVorbis 14# OGGVORBIS_VERSION - set either to 1 or 2 15# OGGVORBIS_INCLUDE_DIR - the OggVorbis include directory 16# OGGVORBIS_LIBRARIES - The libraries needed to use OggVorbis 17# OGG_LIBRARY - The Ogg library 18# VORBIS_LIBRARY - The Vorbis library 19# VORBISFILE_LIBRARY - The VorbisFile library 20# VORBISENC_LIBRARY - The VorbisEnc library 21 22# Copyright (c) 2006, Richard Laerkaeng, <richard@goteborg.utfors.se> 23# 24# Redistribution and use is allowed according to the terms of the BSD license. 25# For details see the accompanying COPYING-CMAKE-SCRIPTS file. 26 27 28include (CheckLibraryExists) 29 30if (VORBIS_INCLUDE_DIR AND OGG_INCLUDE_DIR AND OGG_LIBRARY AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY) 31 set (OggVorbis_FIND_QUIETLY TRUE) 32endif (VORBIS_INCLUDE_DIR AND OGG_INCLUDE_DIR AND OGG_LIBRARY AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY) 33 34find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h) 35find_path(OGG_INCLUDE_DIR ogg/ogg.h) 36 37find_library(OGG_LIBRARY NAMES ogg) 38find_library(VORBIS_LIBRARY NAMES vorbis) 39find_library(VORBISFILE_LIBRARY NAMES vorbisfile) 40#find_library(VORBISENC_LIBRARY NAMES vorbisenc) 41 42 43if (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY) # AND VORBISENC_LIBRARY) 44 set(OGGVORBIS_FOUND TRUE) 45 46 set(OGGVORBIS_LIBRARIES ${OGG_LIBRARY} ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY}) # ${VORBISENC_LIBRARY}) 47 48 set(_CMAKE_REQUIRED_LIBRARIES_TMP ${CMAKE_REQUIRED_LIBRARIES}) 49 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${OGGVORBIS_LIBRARIES}) 50 check_library_exists(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2) 51 set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_TMP}) 52 53 if (HAVE_LIBVORBISENC2) 54 set (OGGVORBIS_VERSION 2) 55 else (HAVE_LIBVORBISENC2) 56 set (OGGVORBIS_VERSION 1) 57 endif (HAVE_LIBVORBISENC2) 58 59else (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY) # AND VORBISENC_LIBRARY) 60 set (OGGVORBIS_VERSION) 61 set(OGGVORBIS_FOUND FALSE) 62endif (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY) # AND VORBISENC_LIBRARY) 63 64 65if (OGGVORBIS_FOUND) 66 if (NOT OggVorbis_FIND_QUIETLY) 67 message(STATUS "Found OggVorbis: ${OGGVORBIS_LIBRARIES}") 68 endif (NOT OggVorbis_FIND_QUIETLY) 69else (OGGVORBIS_FOUND) 70 if (OggVorbis_FIND_REQUIRED) 71 message(FATAL_ERROR "Could NOT find OggVorbis libraries") 72 endif (OggVorbis_FIND_REQUIRED) 73 if (NOT OggVorbis_FIND_QUITELY) 74 message(STATUS "Could NOT find OggVorbis libraries") 75 endif (NOT OggVorbis_FIND_QUITELY) 76endif (OGGVORBIS_FOUND) 77 78mark_as_advanced(VORBIS_INCLUDE_DIR OGG_INCLUDE_DIR OGG_LIBRARY VORBIS_LIBRARY VORBISFILE_LIBRARY) # VORBISENC_LIBRARY) 79 80#check_include_files(vorbis/vorbisfile.h HAVE_VORBISFILE_H) 81#check_library_exists(ogg ogg_page_version "" HAVE_LIBOGG) 82#check_library_exists(vorbis vorbis_info_init "" HAVE_LIBVORBIS) 83#check_library_exists(vorbisfile ov_open "" HAVE_LIBVORBISFILE) 84#check_library_exists(vorbisenc vorbis_info_clear "" HAVE_LIBVORBISENC) 85#check_library_exists(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2) 86 87#if (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC) 88# message(STATUS "Ogg/Vorbis found") 89# set (VORBIS_LIBS "-lvorbis -logg") 90# set (VORBISFILE_LIBS "-lvorbisfile") 91# set (VORBISENC_LIBS "-lvorbisenc") 92# set (OGGVORBIS_FOUND TRUE) 93# if (HAVE_LIBVORBISENC2) 94# set (HAVE_VORBIS 2) 95# else (HAVE_LIBVORBISENC2) 96# set (HAVE_VORBIS 1) 97# endif (HAVE_LIBVORBISENC2) 98#else (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC) 99# message(STATUS "Ogg/Vorbis not found") 100#endif (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC) 101 102