SDL_ttf: cmake: cannot install SDL3_ttf when SDL3 is also built but not installed

From ac67507a5f2cf381f736446f18a3d4b16b1ebf3d Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Thu, 9 Feb 2023 20:32:13 +0100
Subject: [PATCH] cmake: cannot install SDL3_ttf 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 99da048..64c5935 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -37,6 +37,12 @@ else()
     set(vendored_default FALSE)
 endif()
 
+set(sdl3ttf_install_enableable ON)
+if ((TARGET SDL3 OR TARGET SDL3-static) AND SDL3_DISABLE_INSTALL)
+    # Cannot install SDL3_ttf when SDL3 is built in same built, and is not installed.
+    set(sdl3ttf_install_enableable OFF)
+endif()
+
 include(CMakeDependentOption)
 include(CMakePackageConfigHelpers)
 include(GNUInstallDirs)
@@ -45,7 +51,7 @@ include(CheckSymbolExists)
 option(CMAKE_POSITION_INDEPENDENT_CODE "Build static libraries with -fPIC" ON)
 option(BUILD_SHARED_LIBS "Build the library as a shared library" ON)
 
-option(SDL3TTF_INSTALL "Enable SDL3_ttf install target" ${SDL3TTF_ROOTPROJECT})
+cmake_dependent_option(SDL3TTF_INSTALL "Enable SDL3_ttf install target" ${SDL3TTF_ROOTPROJECT} "${sdl3ttf_install_enableable}" OFF)
 option(SDL3TTF_VENDORED "Use vendored third-party libraries" ${vendored_default})
 option(SDL3TTF_WERROR "Treat warnings as errors" OFF)