Warning, /multimedia/audiocd-kio/cmake/FindOggVorbis.cmake is written in an unsupported language. File is not indexed.

0001 # - Try to find the OggVorbis libraries
0002 # Once done this will define
0003 #
0004 #  OGGVORBIS_FOUND - system has OggVorbis
0005 #  OGGVORBIS_VERSION - set either to 1 or 2
0006 #  OGGVORBIS_INCLUDE_DIR - the OggVorbis include directory
0007 #  OGGVORBIS_LIBRARIES - The libraries needed to use OggVorbis
0008 #  OGG_LIBRARY         - The Ogg library
0009 #  VORBIS_LIBRARY      - The Vorbis library
0010 #  VORBISFILE_LIBRARY  - The VorbisFile library
0011 #  VORBISENC_LIBRARY   - The VorbisEnc library
0012 
0013 # Copyright (c) 2006, Richard Laerkaeng, <richard@goteborg.utfors.se>
0014 #
0015 # Redistribution and use is allowed according to the terms of the BSD license.
0016 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
0017 
0018 
0019 include (CheckLibraryExists)
0020 
0021 find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h)
0022 find_path(OGG_INCLUDE_DIR ogg/ogg.h)
0023 
0024 find_library(OGG_LIBRARY NAMES ogg)
0025 find_library(VORBIS_LIBRARY NAMES vorbis)
0026 find_library(VORBISFILE_LIBRARY NAMES vorbisfile)
0027 find_library(VORBISENC_LIBRARY NAMES vorbisenc)
0028 
0029 mark_as_advanced(
0030     VORBIS_INCLUDE_DIR
0031     OGG_INCLUDE_DIR
0032     OGG_LIBRARY
0033     VORBIS_LIBRARY
0034     VORBISFILE_LIBRARY
0035     VORBISENC_LIBRARY
0036 )
0037 
0038 if (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY AND VORBISENC_LIBRARY)
0039    set(OGGVORBIS_FOUND TRUE)
0040 
0041    set(OGGVORBIS_LIBRARIES ${OGG_LIBRARY} ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY} ${VORBISENC_LIBRARY})
0042 
0043    set(_CMAKE_REQUIRED_LIBRARIES_TMP ${CMAKE_REQUIRED_LIBRARIES})
0044    set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${OGGVORBIS_LIBRARIES})
0045    check_library_exists(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2)
0046    set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_TMP})
0047 
0048    if (HAVE_LIBVORBISENC2)
0049       set (OGGVORBIS_VERSION 2)
0050    else ()
0051       set (OGGVORBIS_VERSION 1)
0052    endif ()
0053 
0054 else ()
0055    set (OGGVORBIS_VERSION)
0056    set(OGGVORBIS_FOUND FALSE)
0057 endif ()
0058 
0059 
0060 if (OGGVORBIS_FOUND)
0061    if (NOT OggVorbis_FIND_QUIETLY)
0062       message(STATUS "Found OggVorbis: ${OGGVORBIS_LIBRARIES}")
0063    endif ()
0064 else ()
0065    if (OggVorbis_FIND_REQUIRED)
0066       message(FATAL_ERROR "Could NOT find OggVorbis libraries")
0067    endif (OggVorbis_FIND_REQUIRED)
0068    if (NOT OggVorbis_FIND_QUITELY)
0069       message(STATUS "Could NOT find OggVorbis libraries")
0070    endif ()
0071 endif ()
0072 
0073 #check_include_files(vorbis/vorbisfile.h HAVE_VORBISFILE_H)
0074 #check_library_exists(ogg ogg_page_version "" HAVE_LIBOGG)
0075 #check_library_exists(vorbis vorbis_info_init "" HAVE_LIBVORBIS)
0076 #check_library_exists(vorbisfile ov_open "" HAVE_LIBVORBISFILE)
0077 #check_library_exists(vorbisenc vorbis_info_clear "" HAVE_LIBVORBISENC)
0078 #check_library_exists(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2)
0079 
0080 #if (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC)
0081 #    message(STATUS "Ogg/Vorbis found")
0082 #    set (VORBIS_LIBS "-lvorbis -logg")
0083 #    set (VORBISFILE_LIBS "-lvorbisfile")
0084 #    set (VORBISENC_LIBS "-lvorbisenc")
0085 #    set (OGGVORBIS_FOUND TRUE)
0086 #    if (HAVE_LIBVORBISENC2)
0087 #        set (HAVE_VORBIS 2)
0088 #    else (HAVE_LIBVORBISENC2)
0089 #        set (HAVE_VORBIS 1)
0090 #    endif (HAVE_LIBVORBISENC2)
0091 #else (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC)
0092 #    message(STATUS "Ogg/Vorbis not found")
0093 #endif (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE AND HAVE_LIBVORBISENC)
0094 
0095 if(OGGVORBIS_FOUND AND NOT TARGET OGGVORBIS::vorbis)
0096     add_library(OGGVORBIS::ogg UNKNOWN IMPORTED)
0097     set_target_properties(OGGVORBIS::ogg PROPERTIES
0098         IMPORTED_LOCATION "${OGG_LIBRARY}"
0099         INTERFACE_INCLUDE_DIRECTORIES "${OGG_INCLUDE_DIR}"
0100     )
0101     add_library(OGGVORBIS::vorbis UNKNOWN IMPORTED)
0102     set_target_properties(OGGVORBIS::vorbis PROPERTIES
0103         IMPORTED_LOCATION "${VORBIS_LIBRARY}"
0104         INTERFACE_INCLUDE_DIRECTORIES "${VORBIS_INCLUDE_DIR}"
0105         INTERFACE_LINK_LIBRARIES "OGGVORBIS::ogg;${VORBISFILE_LIBRARY};${VORBISENC_LIBRARY}"
0106     )
0107 endif()