SDL_mixer: cmake: fix finding ogg through opusfile

From a7a2e0844aa038dd9755878739a0529cf497e37f Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Fri, 12 Jan 2024 18:30:11 +0100
Subject: [PATCH] cmake: fix finding ogg through opusfile

---
 CMakeLists.txt           |  1 +
 cmake/FindOgg.cmake      | 10 ++++------
 cmake/FindOpusFile.cmake |  4 ++--
 3 files changed, 7 insertions(+), 8 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3321a62d..4c3bde96 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1146,6 +1146,7 @@ if(SDL3MIXER_INSTALL)
             cmake/Findlibxmp.cmake
             cmake/Findlibxmp-lite.cmake
             cmake/Findmodplug.cmake
+            cmake/FindOgg.cmake
             cmake/FindOpusFile.cmake
             cmake/Findmpg123.cmake
             cmake/FindVorbis.cmake
diff --git a/cmake/FindOgg.cmake b/cmake/FindOgg.cmake
index 1d3c7cf9..ef88bff3 100644
--- a/cmake/FindOgg.cmake
+++ b/cmake/FindOgg.cmake
@@ -25,18 +25,16 @@ set(Ogg_LINK_OPTIONS "${_ogg_link_options}" CACHE STRING "Extra link flags of og
 
 set(Ogg_LINK_DIRECTORIES "${_ogg_link_directories}" CACHE PATH "Extra link directories of ogg")
 
-find_package(Ogg)
-
 find_package_handle_standard_args(Ogg
-    REQUIRED_VARS Ogg_LIBRARY Ogg_INCLUDE_PATH Ogg_FOUND
+    REQUIRED_VARS Ogg_LIBRARY Ogg_INCLUDE_PATH
 )
 
 if(Ogg_FOUND)
     set(Ogg_dirs ${Ogg_INCLUDE_PATH})
-    if(EXISTS "${Ogg_INCLUDE_PATH}/opus")
-        list(APPEND Ogg_dirs "${Ogg_INCLUDE_PATH}/opus")
+    if(EXISTS "${Ogg_INCLUDE_PATH}/ogg")
+        list(APPEND Ogg_dirs "${Ogg_INCLUDE_PATH}/ogg")
     endif()
-    if (NOT TARGET Ogg::Ogg)
+    if(NOT TARGET Ogg::Ogg)
         add_library(Ogg::Ogg UNKNOWN IMPORTED)
         set_target_properties(Ogg::Ogg PROPERTIES
             IMPORTED_LOCATION "${Ogg_LIBRARY}"
diff --git a/cmake/FindOpusFile.cmake b/cmake/FindOpusFile.cmake
index 578e136a..fabd6cf0 100644
--- a/cmake/FindOpusFile.cmake
+++ b/cmake/FindOpusFile.cmake
@@ -31,12 +31,12 @@ find_package_handle_standard_args(OpusFile
     REQUIRED_VARS OpusFile_LIBRARY OpusFile_INCLUDE_PATH Ogg_FOUND
 )
 
-if(OpusFile_FOUND AND Ogg_FOUND)
+if(OpusFile_FOUND)
     set(OpusFile_dirs ${OpusFile_INCLUDE_PATH})
     if(EXISTS "${OpusFile_INCLUDE_PATH}/opus")
         list(APPEND OpusFile_dirs "${OpusFile_INCLUDE_PATH}/opus")
     endif()
-    if (NOT TARGET OpusFile::opusfile)
+    if(NOT TARGET OpusFile::opusfile)
         add_library(OpusFile::opusfile UNKNOWN IMPORTED)
         set_target_properties(OpusFile::opusfile PROPERTIES
             IMPORTED_LOCATION "${OpusFile_LIBRARY}"