From 56a20dcfff11ca2fb0b198ab0f3181bb5c8dd172 Mon Sep 17 00:00:00 2001 From: Gelmo Date: Thu, 9 Jan 2025 18:54:11 -0700 Subject: [PATCH] [temp] Manually find Ogg/Vorbis when using system libs Revert once resolved: https://github.com/ValveSoftware/steam-runtime/issues/735 --- source/extern/CMakeLists.txt | 53 ++++++++++++++++++++++++++++++++++-- 1 file changed, 50 insertions(+), 3 deletions(-) diff --git a/source/extern/CMakeLists.txt b/source/extern/CMakeLists.txt index b4e07a2272..2434217cc2 100644 --- a/source/extern/CMakeLists.txt +++ b/source/extern/CMakeLists.txt @@ -37,7 +37,23 @@ endif() if(USE_SYSTEM_OGG) - find_package(Ogg REQUIRED GLOBAL) + 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 PATH_SUFFIXES include) + # 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) else() add_subdirectory(ogg) set_target_properties(ogg PROPERTIES FOLDER extern) @@ -53,7 +69,39 @@ endif() if(USE_SYSTEM_VORBIS) - find_package(Vorbis REQUIRED GLOBAL) + 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 PATH_SUFFIXES include) + # 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) + if (NOT ${VORBIS_LIBRARY} MATCHES ".framework") + find_library(VORBISFILE_LIBRARY NAMES vorbisfile vorbisfile_static libvorbisfile libvorbisfile_static) + else() + set(VORBISFILE_LIBRARY ${VORBIS_LIBRARY}) + endif() + # 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) else() if(NOT USE_SYSTEM_OGG) set(OGG_LIBRARY ogg) @@ -61,7 +109,6 @@ else() endif() add_subdirectory(vorbis) endif() - if (USE_SYSTEM_OPENAL) find_package(OpenAL REQUIRED GLOBAL)