SDL_mixer: cmake: cannot install SDL3_mixer when SDL3 is also built but not installed

From 55c0899c9c064f31b998d1f0993fc2d124d83aeb Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Thu, 9 Feb 2023 20:28:51 +0100
Subject: [PATCH] cmake: cannot install SDL3_mixer when SDL3 is also built but
 not installed

---
 CMakeLists.txt | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 29ad642b..be5c22cf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -47,6 +47,12 @@ else()
     set(vendored_default OFF)
 endif()
 
+set(sdl3mixer_install_enableable ON)
+if ((TARGET SDL3 OR TARGET SDL3-static) AND SDL3_DISABLE_INSTALL)
+    # Cannot install SDL3_mixer when SDL3 is built in same built, and is not installed.
+    set(sdl3mixer_install_enableable OFF)
+endif()
+
 include(CheckIncludeFile)
 include(CheckSymbolExists)
 include(CMakeDependentOption)
@@ -56,7 +62,7 @@ include(GNUInstallDirs)
 option(CMAKE_POSITION_INDEPENDENT_CODE "Build static libraries with -fPIC" ON)
 option(BUILD_SHARED_LIBS "Build the library as a shared library" ON)
 
-option(SDL3MIXER_INSTALL "Enable SDL3mixer install target" ${SDL3MIXER_ROOTPROJECT})
+cmake_dependent_option(SDL3MIXER_INSTALL "Enable SDL3mixer install target" ${SDL3MIXER_ROOTPROJECT "${sdl3mixer_install_enableable}" OFF)
 option(SDL3MIXER_DEPS_SHARED "Default value for loading dependencies dynamically" ON)
 option(SDL3MIXER_VENDORED "Use vendored third-party libraries" ${vendored_default})
 option(SDL3MIXER_WERROR "Treat warnings as errors" OFF)