SDL_mixer: cmake: Set CMP0077 to NEW (24216)

From 24216e41783d6273db64431cbe72bb7111e0fccb Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Fri, 25 Aug 2023 02:08:42 +0200
Subject: [PATCH] cmake: Set CMP0077 to NEW

This avoids the need for settings CACHE variables, and will now show warnings messages.
---
 CMakeLists.txt | 52 +++++++++++++++++++++++++++-----------------------
 1 file changed, 28 insertions(+), 24 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 35bb721d..ddba063d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -33,6 +33,10 @@ if(ANDROID)
     set(SDL2MIXER_SAMPLES_DEFAULT OFF)
 endif()
 
+# option() honors normal variables.
+cmake_policy(SET CMP0077 NEW)
+set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
+
 if(POLICY CMP0112)
     # Target file component generator expressions do not add target dependencies.
     cmake_policy(SET CMP0112 NEW)
@@ -356,8 +360,8 @@ if(SDL2MIXER_OGG)
     if(SDL2MIXER_VENDORED)
         message(STATUS "Using vendored libogg")
         set(BUILD_SHARED_LIBS ${SDL2MIXER_OGG_SHARED})
-        set(INSTALL_CMAKE_PACKAGE_MODULE FALSE CACHE BOOL "Don't install cmake module for libogg")
-        set(BUILD_TESTING OFF CACHE BOOL "Build tests")
+        set(INSTALL_CMAKE_PACKAGE_MODULE FALSE)
+        set(BUILD_TESTING OFF)
         sdl_check_project_in_subfolder(external/ogg ogg SDL2MIXER_VENDORED)
         add_subdirectory(external/ogg EXCLUDE_FROM_ALL)
         if(SDL2MIXER_OGG_install)
@@ -375,13 +379,13 @@ if(SDL2MIXER_OPUS)
         endif()
         message(STATUS "Using vendored opus")
         set(BUILD_SHARED_LIBS ${SDL2MIXER_OPUS_SHARED})
-        set(BUILD_PROGRAMS OFF CACHE BOOL "Build programs")
+        set(BUILD_PROGRAMS OFF)
         sdl_check_project_in_subfolder(external/opus opus SDL2MIXER_VENDORED)
         add_subdirectory(external/opus EXCLUDE_FROM_ALL)
 
-        set(OP_DISABLE_DOCS TRUE CACHE BOOL "Disable opusfile documentation")
-        set(OP_DISABLE_EXAMPLES TRUE CACHE BOOL "Disable opusfile examples")
-        set(OP_DISABLE_HTTP TRUE CACHE BOOL "Disable opusfile HTTP SUPPORT")
+        set(OP_DISABLE_DOCS TRUE)
+        set(OP_DISABLE_EXAMPLES TRUE)
+        set(OP_DISABLE_HTTP TRUE)
         message(STATUS "Using vendored opusfile")
         set(BUILD_SHARED_LIBS ${SDL2MIXER_OPUS_SHARED})
         sdl_check_project_in_subfolder(external/opusfile opusfile SDL2MIXER_VENDORED)
@@ -539,13 +543,13 @@ if(SDL2MIXER_FLAC_LIBFLAC)
             message(FATAL_ERROR "ogg target not present")
         endif()
         set(BUILD_SHARED_LIBS "${SDL2MIXER_FLAC_LIBFLAC_SHARED}")
-        set(INSTALL_CMAKE_CONFIG_MODULE OFF CACHE BOOL "Disable libflac installation")
-        set(WITH_OGG OFF CACHE BOOL "Disable finding ogg using `find_package` (we have vendored it)")
-        set(BUILD_CXXLIBS OFF CACHE BOOL "Build FLAC++")
-        set(BUILD_EXAMPLES OFF CACHE BOOL "Build FLAC examples")
-        set(BUILD_PROGRAMS OFF CACHE BOOL "Build programs")
-        set(BUILD_TESTING OFF CACHE BOOL "Build tests")
-        set(INSTALL_MANPAGES OFF CACHE BOOL "Install FLAC manpages")
+        set(INSTALL_CMAKE_CONFIG_MODULE OFF)
+        set(WITH_OGG OFF)
+        set(BUILD_CXXLIBS OFF)
+        set(BUILD_EXAMPLES OFF)
+        set(BUILD_PROGRAMS OFF)
+        set(BUILD_TESTING OFF)
+        set(INSTALL_MANPAGES OFF)
         message(STATUS "Using vendored libflac")
         sdl_check_project_in_subfolder(external/flac libflac SDL2MIXER_VENDORED)
         add_subdirectory(external/flac EXCLUDE_FROM_ALL)
@@ -587,9 +591,9 @@ if(SDL2MIXER_GME)
     target_compile_definitions(SDL2_mixer PRIVATE MUSIC_GME)
     if(SDL2MIXER_VENDORED)
         set(BUILD_SHARED_LIBS "${SDL2MIXER_GME_SHARED}")
-        set(ENABLE_UBSAN OFF CACHE BOOL "UB sanitizer")
-        set(BUILD_FRAMEWORK OFF CACHE BOOL "macos framework")
-        set(GME_ZLIB OFF CACHE BOOL "GME supports compressed formats")
+        set(ENABLE_UBSAN OFF)
+        set(BUILD_FRAMEWORK OFF)
+        set(GME_ZLIB OFF)
         message(STATUS "Using vendored libgme")
         sdl_check_project_in_subfolder(external/libgme libgme SDL2MIXER_VENDORED)
         add_subdirectory(external/libgme EXCLUDE_FROM_ALL)
@@ -658,8 +662,8 @@ if(SDL2MIXER_MOD_XMP)
     if(SDL2MIXER_VENDORED)
         message(STATUS "Using vendored libxmp")
         sdl_check_project_in_subfolder(external/libxmp libxmp SDL2MIXER_VENDORED)
-        set(LIBXMP_DISABLE_DEPACKERS ON CACHE BOOL "Disable archive depackers")
-        set(LIBXMP_DISABLE_PROWIZARD ON CACHE BOOL "Disable ProWizard format loaders")
+        set(LIBXMP_DISABLE_DEPACKERS ON)
+        set(LIBXMP_DISABLE_PROWIZARD ON)
         if(SDL2MIXER_MOD_XMP_SHARED)
             set(BUILD_STATIC OFF)
             set(BUILD_SHARED ON)
@@ -728,8 +732,8 @@ if(SDL2MIXER_MP3_MPG123)
     if(SDL2MIXER_VENDORED)
         message(STATUS "Using vendored mpg123")
         sdl_check_project_in_subfolder(external/mpg123/ports/cmake mpg123 SDL2MIXER_VENDORED)
-        set(BUILD_LIBOUT123 FALSE CACHE BOOL "Don't configure libout123")
-        set(BUILD_PROGRAMS OFF CACHE BOOL "Build programs")
+        set(BUILD_LIBOUT123 FALSE)
+        set(BUILD_PROGRAMS OFF)
         set(BUILD_SHARED_LIBS "${SDL2MIXER_MP3_MPG123_SHARED}")
         add_subdirectory(external/mpg123/ports/cmake EXCLUDE_FROM_ALL)
         if(NOT TARGET MPG123::libmpg123)
@@ -837,10 +841,10 @@ if(SDL2MIXER_WAVPACK)
     if(SDL2MIXER_VENDORED)
         message(STATUS "Using vendored WevPack")
         sdl_check_project_in_subfolder(external/wavpack WavPack SDL2MIXER_VENDORED)
-        set(WAVPACK_BUILD_PROGRAMS FALSE CACHE BOOL "Don't build WavPack programs")
-        set(WAVPACK_BUILD_COOLEDIT_PLUGIN OFF CACHE BOOL "Don't build WavPack CoolEdit plugin")
-        set(WAVPACK_BUILD_WINAMP_PLUGIN OFF CACHE BOOL "Don't build WavPack WinAMP plugin")
-        set(WAVPACK_BUILD_DOCS OFF CACHE BOOL "Don't build WavPack documentation")
+        set(WAVPACK_BUILD_PROGRAMS FALSE)
+        set(WAVPACK_BUILD_COOLEDIT_PLUGIN OFF)
+        set(WAVPACK_BUILD_WINAMP_PLUGIN OFF)
+        set(WAVPACK_BUILD_DOCS OFF)
         set(BUILD_SHARED_LIBS "${SDL2MIXER_WAVPACK_SHARED}")
         add_subdirectory(external/wavpack EXCLUDE_FROM_ALL)
         if(SDL2MIXER_WAVPACK_SHARED OR NOT SDL2MIXER_BUILD_SHARED_LIBS)