Merge pull request #41 from TC01/unbundle-ogg-vorbis

If CAUDIO_SYSTEM_OGG is set, use system ogg/vorbis.
This commit is contained in:
Raynaldo Rivera 2016-07-29 08:54:30 -07:00 committed by GitHub
commit 3b9fd6e4df
4 changed files with 87 additions and 5 deletions

View File

@ -0,0 +1,28 @@
# - Find ogg
# Find the native ogg includes and libraries
#
# OGG_INCLUDE_DIR - where to find ogg.h, etc.
# OGG_LIBRARIES - List of libraries when using ogg.
# OGG_FOUND - True if ogg found.
# Taken from the allegro project, licensed under zlib.
# https://raw.githubusercontent.com/liballeg/allegro5/master/cmake/FindOgg.cmake
# https://github.com/liballeg/allegro5/blob/master/LICENSE.txt
if(OGG_INCLUDE_DIR)
# Already in cache, be silent
set(OGG_FIND_QUIETLY TRUE)
endif(OGG_INCLUDE_DIR)
find_path(OGG_INCLUDE_DIR ogg/ogg.h)
# MSVC built ogg may be named ogg_static.
# The provided project files name the library with the lib prefix.
find_library(OGG_LIBRARY NAMES ogg ogg_static libogg libogg_static)
# Handle the QUIETLY and REQUIRED arguments and set OGG_FOUND
# to TRUE if all listed variables are TRUE.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OGG DEFAULT_MSG OGG_INCLUDE_DIR OGG_LIBRARY)
set(OGG_LIBRARIES ${OGG_LIBRARY})
mark_as_advanced(OGG_INCLUDE_DIR)
mark_as_advanced(OGG_LIBRARY)

View File

@ -0,0 +1,43 @@
# - Find vorbis
# Find the native vorbis includes and libraries
#
# VORBIS_INCLUDE_DIR - where to find vorbis.h, etc.
# VORBIS_LIBRARIES - List of libraries when using vorbis(file).
# VORBIS_FOUND - True if vorbis found.
# Taken from the allegro project, licensed under zlib.
# https://raw.githubusercontent.com/liballeg/allegro5/master/cmake/FindOgg.cmake
# https://github.com/liballeg/allegro5/blob/master/LICENSE.txt
if(VORBIS_INCLUDE_DIR)
# Already in cache, be silent
set(VORBIS_FIND_QUIETLY TRUE)
endif(VORBIS_INCLUDE_DIR)
find_package(Ogg)
if(OGG_FOUND)
find_path(VORBIS_INCLUDE_DIR vorbis/vorbisfile.h)
# MSVC built vorbis may be named vorbis_static
# The provided project files name the library with the lib prefix.
find_library(VORBIS_LIBRARY
NAMES vorbis vorbis_static libvorbis libvorbis_static)
find_library(VORBISFILE_LIBRARY
NAMES vorbisfile vorbisfile_static libvorbisfile libvorbisfile_static)
# Handle the QUIETLY and REQUIRED arguments and set VORBIS_FOUND
# to TRUE if all listed variables are TRUE.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(VORBIS DEFAULT_MSG
VORBIS_INCLUDE_DIR
VORBIS_LIBRARY VORBISFILE_LIBRARY)
endif(OGG_FOUND)
if(VORBIS_FOUND)
set(VORBIS_LIBRARIES ${VORBISFILE_LIBRARY} ${VORBIS_LIBRARY}
${OGG_LIBRARY})
else(VORBIS_FOUND)
set(VORBIS_LIBRARIES)
endif(VORBIS_FOUND)
mark_as_advanced(VORBIS_INCLUDE_DIR)
mark_as_advanced(VORBIS_LIBRARY VORBISFILE_LIBRARY)

View File

@ -55,6 +55,7 @@ option(CAUDIO_BUILD_CSHARP_WRAPPER "Build CSharpWrapper - this wrapper is used w
option(CAUDIO_BUILD_EAX_PLUGIN "Build EAXLegacyPreset Plugin" FALSE)
option(CAUDIO_BUILD_MP3DECODER_PLUGIN "Build mp3Decoder Plugin" FALSE)
option(CAUDIO_ENABLE_OGG "Enable OGG decoder" TRUE)
option(CAUDIO_SYSTEM_OGG "Link against system OGG" FALSE)
option(CAUDIO_ENABLE_WAV "Enable RIFF/Wav decoder" TRUE)
option(CAUDIO_ENABLE_DEFAULT_FILESYSTEM "Enable default filesystem data source" TRUE)
option(CAUDIO_ENABLE_DEFAULT_FILE_LOGGER "Enable default file logger (html)" TRUE)
@ -101,8 +102,16 @@ include(Dependencies)
include(InstallDependencies)
if(CAUDIO_ENABLE_OGG)
add_subdirectory(DependenciesSource/libogg-1.2.2)
add_subdirectory(DependenciesSource/libvorbis-1.3.2)
if(CAUDIO_SYSTEM_OGG)
find_package(Ogg)
find_package(Vorbis)
else()
add_subdirectory(DependenciesSource/libogg-1.2.2)
add_subdirectory(DependenciesSource/libvorbis-1.3.2)
# Set OGG_LIBRARIES, VORBIS_LIBRARIES as appropriate.
set(OGG_LIBRARIES Ogg)
set(VORBIS_LIBRARIES Vorbis)
endif()
endif()
add_subdirectory(cAudio)
@ -128,4 +137,4 @@ if(CAUDIO_BUILD_SAMPLES)
add_subdirectory(Examples/Tutorial5_AudioEffects)
add_subdirectory(Examples/Tutorial6_CustomEventHandler)
add_subdirectory(Examples/Tutorial7_CustomLogReceiver)
endif()
endif()

View File

@ -17,8 +17,10 @@ add_library(cAudio ${CAUDIO_LIB_TYPE} ${file_root})
if(CAUDIO_ENABLE_OGG)
include_directories (include Headers ${CMAKE_BINARY_DIR}/include ${OPENAL_INCLUDE_DIRS} ${OGG_INCLUDE_DIR} ${VORBIS_INCLUDE_DIR})
target_link_libraries(cAudio Vorbis Ogg ${OPENAL_LIBRARIES})
add_dependencies(cAudio Vorbis Ogg)
target_link_libraries(cAudio ${VORBIS_LIBRARIES} ${OGG_LIBRARIES} ${OPENAL_LIBRARIES})
if(NOT CAUDIO_SYSTEM_OGG)
add_dependencies(cAudio Vorbis Ogg)
endif()
else()
include_directories (include Headers ${CMAKE_BINARY_DIR}/include ${OPENAL_INCLUDE_DIRS})
target_link_libraries(cAudio ${OPENAL_LIBRARIES})