SDL_mixer: cmake: find libogg in CMakeLists.txt

From f89dc788278b9124d63309069c7e5bbca68897ac Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Fri, 12 Jan 2024 18:54:57 +0100
Subject: [PATCH] cmake: find libogg in CMakeLists.txt

---
 CMakeLists.txt           | 6 +++++-
 cmake/FindOpusFile.cmake | 6 ++----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 4c3bde96..6930ffd5 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -468,7 +468,8 @@ if(SDL3MIXER_OPUS)
         endif()
     else()
         find_package(OpusFile ${required})
-        if(OpusFile_FOUND)
+        find_package(Ogg ${required})
+        if(OpusFile_FOUND AND Ogg_FOUND)
             set(SDL3MIXER_OPUS_ENABLED TRUE)
             message(STATUS "Using system opusfile")
             if(NOT SDL3MIXER_OPUS_SHARED)
@@ -485,6 +486,9 @@ if(SDL3MIXER_OPUS)
                 $<TARGET_PROPERTY:OpusFile::opusfile,INCLUDE_DIRECTORIES>
                 $<TARGET_PROPERTY:OpusFile::opusfile,INTERFACE_INCLUDE_DIRECTORIES>
                 $<TARGET_PROPERTY:OpusFile::opusfile,INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>
+                $<TARGET_PROPERTY:Ogg::Ogg,INCLUDE_DIRECTORIES>
+                $<TARGET_PROPERTY:Ogg::Ogg,INTERFACE_INCLUDE_DIRECTORIES>
+                $<TARGET_PROPERTY:Ogg::Ogg,INTERFACE_SYSTEM_INCLUDE_DIRECTORIES>
             )
             target_get_dynamic_library(dynamic_opusfile OpusFile::opusfile)
             message(STATUS "Dynamic opus (opusfile): ${dynamic_opusfile}")
diff --git a/cmake/FindOpusFile.cmake b/cmake/FindOpusFile.cmake
index fabd6cf0..4f7d9cc5 100644
--- a/cmake/FindOpusFile.cmake
+++ b/cmake/FindOpusFile.cmake
@@ -25,10 +25,8 @@ set(OpusFile_LINK_OPTIONS "${_opusfile_link_options}" CACHE STRING "Extra link f
 
 set(OpusFile_LINK_DIRECTORIES "${_opusfile_link_directories}" CACHE PATH "Extra link directories of opusfile")
 
-find_package(Ogg)
-
 find_package_handle_standard_args(OpusFile
-    REQUIRED_VARS OpusFile_LIBRARY OpusFile_INCLUDE_PATH Ogg_FOUND
+    REQUIRED_VARS OpusFile_LIBRARY OpusFile_INCLUDE_PATH
 )
 
 if(OpusFile_FOUND)
@@ -40,7 +38,7 @@ if(OpusFile_FOUND)
         add_library(OpusFile::opusfile UNKNOWN IMPORTED)
         set_target_properties(OpusFile::opusfile PROPERTIES
             IMPORTED_LOCATION "${OpusFile_LIBRARY}"
-            INTERFACE_INCLUDE_DIRECTORIES "${OpusFile_dirs};$<TARGET_PROPERTY:Ogg::Ogg,INTERFACE_INCLUDE_DIRECTORIES>"
+            INTERFACE_INCLUDE_DIRECTORIES "${OpusFile_dirs};$<TARGET_PROPERTY>"
             INTERFACE_COMPILE_OPTIONS "${OpusFile_COMPILE_OPTIONS}"
             INTERFACE_LINK_LIBRARIES "${OpusFile_LINK_LIBRARIES}"
             INTERFACE_LINK_OPTIONS "${OpusFile_LINK_OPTIONS}"