cmake_modules/FindOggVorbis.cmake
changeset 2214 eacb5b19d587
parent 2211 288360b78f30
child 2336 66c751f7a28e
equal deleted inserted replaced
2213:bd51bbf06033 2214:eacb5b19d587
     1 FIND_PATH(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h)
     1 ### SuperTux - Removed unused vorbisenc library
     2 FIND_PATH(OGG_INCLUDE_DIR ogg/ogg.h)
       
     3 
     2 
     4 FIND_LIBRARY(OGG_LIBRARY NAMES ogg)
     3 # - Try to find the OggVorbis libraries
       
     4 # Once done this will define
       
     5 #
       
     6 #  OGGVORBIS_FOUND - system has OggVorbis
       
     7 #  OGGVORBIS_VERSION - set either to 1 or 2
       
     8 #  OGGVORBIS_INCLUDE_DIR - the OggVorbis include directory
       
     9 #  OGGVORBIS_LIBRARIES - The libraries needed to use OggVorbis
       
    10 #  OGG_LIBRARY         - The Ogg library
       
    11 #  VORBIS_LIBRARY      - The Vorbis library
       
    12 #  VORBISFILE_LIBRARY  - The VorbisFile library
       
    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.
     5 
    17 
     6 FIND_LIBRARY(VORBIS_LIBRARY NAMES vorbis)
    18 include (CheckLibraryExists)
     7 FIND_LIBRARY(VORBISFILE_LIBRARY NAMES vorbisfile)
    19 find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h)
     8 
    20 find_library(OGG_LIBRARY NAMES ogg)
     9 IF(VORBIS_INCLUDE_DIR AND OGG_LIBRARY AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY)
    21 find_library(VORBIS_LIBRARY NAMES vorbis)
    10     SET(OGGVORBIS_FOUND TRUE)
    22 find_library(VORBISFILE_LIBRARY NAMES vorbisfile)
    11     SET(OGGVORBIS_LIBRARIES ${OGG_LIBRARY} ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY})
    23 if (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY)
    12     SET(OGGVORBIS_INCLUDE_DIRS ${VORBIS_INCLUDE_DIR} ${OGG_INCLUDE_DIR})
    24    set(OGGVORBIS_FOUND TRUE)
    13 ELSE(VORBIS_INCLUDE_DIR AND OGG_LIBRARY AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY)
    25 #  [sommer] (for SuperTux) reversed order of libraries, so that cmake 2.4.5 for Windows generates an MSYS Makefile that will link correctly
    14     SET(OGGVORBIS_FOUND FALSE)
    26 #  set(OGGVORBIS_LIBRARIES ${OGG_LIBRARY} ${VORBIS_LIBRARY} ${VORBISFILE_LIBRARY})
    15 ENDIF(VORBIS_INCLUDE_DIR AND OGG_LIBRARY AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY)
    27    set(OGGVORBIS_LIBRARIES ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY} ${OGG_LIBRARY})
    16 
    28    set(_CMAKE_REQUIRED_LIBRARIES_TMP ${CMAKE_REQUIRED_LIBRARIES})
    17 IF(OGGVORBIS_FOUND)
    29    set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${OGGVORBIS_LIBRARIES})
    18     MESSAGE(STATUS "Found OggVorbis: ${OGGVORBIS_LIBRARIES}")
    30    check_library_exists(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2)
    19 ELSE(OGGVORBIS_FOUND)
    31    set(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_TMP})
    20     MESSAGE(FATAL_ERROR "Could NOT find Ogg and/or Vorbis - Visit xiph.org and download latest version")
    32    if (HAVE_LIBVORBISENC2)
    21 ENDIF(OGGVORBIS_FOUND)
    33       set (OGGVORBIS_VERSION 2)
       
    34    else (HAVE_LIBVORBISENC2)
       
    35       set (OGGVORBIS_VERSION 1)
       
    36    endif (HAVE_LIBVORBISENC2)
       
    37 else (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY)
       
    38    set (OGGVORBIS_VERSION)
       
    39    set(OGGVORBIS_FOUND FALSE)
       
    40 endif (VORBIS_INCLUDE_DIR AND VORBIS_LIBRARY AND VORBISFILE_LIBRARY)
       
    41 if (OGGVORBIS_FOUND)
       
    42    if (NOT OggVorbis_FIND_QUIETLY)
       
    43       message(STATUS "Found OggVorbis: ${OGGVORBIS_LIBRARIES}")
       
    44    endif (NOT OggVorbis_FIND_QUIETLY)
       
    45 else (OGGVORBIS_FOUND)
       
    46    if (OggVorbis_FIND_REQUIRED)
       
    47       message(FATAL_ERROR "Could NOT find OggVorbis libraries")
       
    48    endif (OggVorbis_FIND_REQUIRED)
       
    49    if (NOT OggVorbis_FIND_QUIETLY)
       
    50       message(STATUS "Could NOT find OggVorbis libraries")
       
    51    endif (NOT OggVorbis_FIND_QUIETLY)
       
    52 endif (OGGVORBIS_FOUND)
       
    53 #check_include_files(vorbis/vorbisfile.h HAVE_VORBISFILE_H)
       
    54 #check_library_exists(ogg ogg_page_version "" HAVE_LIBOGG)
       
    55 #check_library_exists(vorbis vorbis_info_init "" HAVE_LIBVORBIS)
       
    56 #check_library_exists(vorbisfile ov_open "" HAVE_LIBVORBISFILE)
       
    57 #check_library_exists(vorbis vorbis_bitrate_addblock "" HAVE_LIBVORBISENC2)
       
    58 #if (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE)
       
    59 #    message(STATUS "Ogg/Vorbis found")
       
    60 #    set (VORBIS_LIBS "-lvorbis -logg")
       
    61 #    set (VORBISFILE_LIBS "-lvorbisfile")
       
    62 #    set (OGGVORBIS_FOUND TRUE)
       
    63 #    if (HAVE_LIBVORBISENC2)
       
    64 #        set (HAVE_VORBIS 2)
       
    65 #    else (HAVE_LIBVORBISENC2)
       
    66 #        set (HAVE_VORBIS 1)
       
    67 #    endif (HAVE_LIBVORBISENC2)
       
    68 #else (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE)
       
    69 #    message(STATUS "Ogg/Vorbis not found")
       
    70 #endif (HAVE_LIBOGG AND HAVE_VORBISFILE_H AND HAVE_LIBVORBIS AND HAVE_LIBVORBISFILE)
    22 
    71 
    23 
    72