SDL_mixer: Set CMAKE_FIND_PACKAGE_PREFER_CONFIG if undefined.

From 247407b272cabd0856a61d39961ed21e9047157d Mon Sep 17 00:00:00 2001
From: Pierre Wendling <[EMAIL REDACTED]>
Date: Wed, 8 Mar 2023 16:37:02 -0500
Subject: [PATCH] Set CMAKE_FIND_PACKAGE_PREFER_CONFIG if undefined.

---
 CMakeLists.txt                  | 4 ++++
 cmake/SDL3_mixerConfig.cmake.in | 4 ++++
 2 files changed, 8 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0a325abf..212c649c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -60,6 +60,10 @@ if ((TARGET SDL3 OR TARGET SDL3-static) AND SDL3_DISABLE_INSTALL)
     set(sdl3mixer_install_enableable OFF)
 endif()
 
+if(NOT DEFINED CMAKE_FIND_PACKAGE_PREFER_CONFIG)
+    set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
+endif()
+
 include(CheckIncludeFile)
 include(CheckSymbolExists)
 include(CMakeDependentOption)
diff --git a/cmake/SDL3_mixerConfig.cmake.in b/cmake/SDL3_mixerConfig.cmake.in
index 436dccb6..b644605d 100644
--- a/cmake/SDL3_mixerConfig.cmake.in
+++ b/cmake/SDL3_mixerConfig.cmake.in
@@ -62,6 +62,10 @@ if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/SDL3_mixer-static-targets.cmake")
     include(CMakeFindDependencyMacro)
     include(PkgConfigHelper)
 
+    if(NOT DEFINED CMAKE_FIND_PACKAGE_PREFER_CONFIG)
+        set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ON)
+    endif()
+
     if(SDL3MIXER_SNDFILE AND NOT SDL3MIXER_VENDORED AND NOT TARGET SndFile::sndfile)
         find_dependency(SndFile)
     endif()