From 8a2375a5f1c869b88a9093e65ac40de615df0dcf Mon Sep 17 00:00:00 2001 From: Sam Edwards Date: Sun, 13 Jan 2019 11:31:43 -0700 Subject: [PATCH] CMake: Detect Ogg+Vorbis --- cmake/modules/FindOgg.cmake | 20 ++++++++++++++++++ cmake/modules/FindVorbisFile.cmake | 34 ++++++++++++++++++++++++++++++ dtool/Package.cmake | 7 ++++++ panda/src/movies/CMakeLists.txt | 3 ++- 4 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 cmake/modules/FindOgg.cmake create mode 100644 cmake/modules/FindVorbisFile.cmake diff --git a/cmake/modules/FindOgg.cmake b/cmake/modules/FindOgg.cmake new file mode 100644 index 0000000000..88bcfe81cd --- /dev/null +++ b/cmake/modules/FindOgg.cmake @@ -0,0 +1,20 @@ +# Filename: FindOgg.cmake +# Authors: CFSworks (13 Jan, 2019) +# +# Usage: +# find_package(Ogg [REQUIRED] [QUIET]) +# +# Once done this will define: +# OGG_FOUND - system has Ogg +# OGG_INCLUDE_DIR - the include directory containing ogg/ +# OGG_LIBRARY - the path to the ogg library +# + +find_path(OGG_INCLUDE_DIR NAMES "ogg/ogg.h") + +find_library(OGG_LIBRARY NAMES "ogg") + +mark_as_advanced(OGG_INCLUDE_DIR OGG_LIBRARY) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Ogg DEFAULT_MSG OGG_INCLUDE_DIR OGG_LIBRARY) diff --git a/cmake/modules/FindVorbisFile.cmake b/cmake/modules/FindVorbisFile.cmake new file mode 100644 index 0000000000..654219c3f7 --- /dev/null +++ b/cmake/modules/FindVorbisFile.cmake @@ -0,0 +1,34 @@ +# Filename: FindVorbisFile.cmake +# Authors: CFSworks (13 Jan, 2019) +# +# Usage: +# find_package(VorbisFile [REQUIRED] [QUIET]) +# +# Once done this will define: +# VORBISFILE_FOUND - system has Ogg and vorbisfile +# VORBISFILE_INCLUDE_DIRS - the include directory/ies containing vorbis/ and ogg/ +# VORBISFILE_LIBRARIES - the paths to the vorbis and vorbisfile libraries +# + +# Find Ogg +find_package(Ogg QUIET) + +# Find Vorbis +find_path(VORBIS_INCLUDE_DIR NAMES "vorbis/vorbisfile.h") + +find_library(VORBIS_vorbis_LIBRARY NAMES "vorbis") +find_library(VORBIS_vorbisfile_LIBRARY NAMES "vorbisfile") + +mark_as_advanced(VORBIS_INCLUDE_DIR VORBIS_vorbis_LIBRARY VORBIS_vorbisfile_LIBRARY) + +# Define output variables +set(VORBISFILE_INCLUDE_DIRS ${VORBIS_INCLUDE_DIR}) +if(NOT OGG_INCLUDE_DIR STREQUAL VORBIS_INCLUDE_DIR) + list(APPEND VORBISFILE_INCLUDE_DIRS ${OGG_INCLUDE_DIR}) +endif() +set(VORBISFILE_LIBRARIES ${OGG_LIBRARY} ${VORBIS_vorbis_LIBRARY} ${VORBIS_vorbisfile_LIBRARY}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(VorbisFile DEFAULT_MSG + Ogg_FOUND + VORBIS_INCLUDE_DIR VORBIS_vorbis_LIBRARY VORBIS_vorbisfile_LIBRARY) diff --git a/dtool/Package.cmake b/dtool/Package.cmake index 39a80cb080..01e14dfa0d 100644 --- a/dtool/Package.cmake +++ b/dtool/Package.cmake @@ -241,6 +241,13 @@ else() endif() package_status(FFMPEG "FFmpeg" "${ffmpeg_features}") +# Vorbis +find_package(VorbisFile QUIET) +package_option(VORBIS + FOUND_AS VORBISFILE + "Enables support for decoding Vorbis-encoded .ogg audio files via libvorbisfile.") +package_status(VORBIS "Vorbis") + # # ------------ Audio libraries ------------ # diff --git a/panda/src/movies/CMakeLists.txt b/panda/src/movies/CMakeLists.txt index c35c4bf33b..5646bde08c 100644 --- a/panda/src/movies/CMakeLists.txt +++ b/panda/src/movies/CMakeLists.txt @@ -45,7 +45,8 @@ set(P3MOVIES_SOURCES composite_sources(p3movies P3MOVIES_SOURCES) add_component_library(p3movies SYMBOL BUILDING_PANDA_MOVIES ${P3MOVIES_HEADERS} ${P3MOVIES_SOURCES}) -target_link_libraries(p3movies p3pstatclient p3gobj p3pandabase pandaexpress) +target_link_libraries(p3movies p3pstatclient p3gobj p3pandabase pandaexpress + PKG::VORBIS) target_interrogate(p3movies ALL) if(NOT BUILD_METALIBS)