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 13# SPDX-FileCopyrightText: 2006 Richard Laerkaeng <richard@goteborg.utfors.se> 14# SPDX-License-Identifier: BSD-3-Clause 15 16include (CheckLibraryExists) 17 18find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h) 19find_path(OGG_INCLUDE_DIR ogg/ogg.h) 20 21find_library(OGG_LIBRARY NAMES ogg) 22find_library(VORBIS_LIBRARY NAMES vorbis) 23find_library(VORBISFILE_LIBRARY NAMES vorbisfile) 24find_library(VORBISENC_LIBRARY NAMES vorbisenc) 25 26mark_as_advanced(VORBIS_INCLUDE_DIR OGG_INCLUDE_DIR 27 OGG_LIBRARY VORBIS_LIBRARY VORBISFILE_LIBRARY VORBISENC_LIBRARY) 28 29 30if (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY) 31 32 set(OGGVORBIS_LIBRARIES ${OGG_LIBRARY} ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBISENC_LIBRARY}) 33 34 set(_CMAKE_REQUIRED_LIBRARIES_TMP ${CMAKE_REQUIRED_LIBRARIES}) 35 set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${OGGVORBIS_LIBRARIES}) 36 check_library_exists(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2) 37 set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_TMP}) 38 39 if (HAVE_LIBVORBISENC2) 40 set (OGGVORBIS_VERSION 2) 41 else (HAVE_LIBVORBISENC2) 42 set (OGGVORBIS_VERSION 1) 43 endif (HAVE_LIBVORBISENC2) 44 45endif (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY) 46 47 48include(FindPackageHandleStandardArgs) 49find_package_handle_standard_args(OggVorbis REQUIRED_VARS VORBIS_LIBRARY OGG_LIBRARY VORBISFILE_LIBRARY VORBISENC_LIBRARY 50 VORBIS_INCLUDE_DIR OGG_INCLUDE_DIR) 51 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 59#if (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC) 60# message(STATUS "Ogg/Vorbis found") 61# set (VORBIS_LIBS "-lvorbis -logg") 62# set (VORBISFILE_LIBS "-lvorbisfile") 63# set (VORBISENC_LIBS "-lvorbisenc") 64# set (OGGVORBIS_FOUND TRUE) 65# if (HAVE_LIBVORBISENC2) 66# set (HAVE_VORBIS 2) 67# else (HAVE_LIBVORBISENC2) 68# set (HAVE_VORBIS 1) 69# endif (HAVE_LIBVORBISENC2) 70#else (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC) 71# message(STATUS "Ogg/Vorbis not found") 72#endif (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC) 73 74