SDL_ttf: cmake: by default, don't create install target when building as a subproject

From d0e2d21590403d0eaf149f637e9b1f54f8ef2615 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Sat, 23 Jul 2022 17:26:56 +0200
Subject: [PATCH] cmake: by default, don't create install target when building
 as a subproject

---
 CMakeLists.txt | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index af29f94..ff1ad09 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -25,6 +25,12 @@ project(SDL2_ttf
 
 message(STATUS "Configuring ${PROJECT_NAME} ${PROJECT_VERSION}")
 
+if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
+    set(SDL2TTF_ROOTPROJECT ON)
+else()
+    set(SDL2TTF_ROOTPROJECT OFF)
+endif()
+
 # Set defaults preventing destination file conflicts
 set(SDL2TTF_DEBUG_POSTFIX "d"
     CACHE STRING "Name suffix for debug builds")
@@ -47,8 +53,8 @@ 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(SDL2TTF_SAMPLES "Build the SDL2_ttf sample program(s)" ON)
-option(SDL2TTF_INSTALL "Enable SDL2_ttf install target" ON)
+option(SDL2TTF_SAMPLES "Build the SDL2_ttf sample program(s)" ${SDL2TTF_ROOTPROJECT})
+option(SDL2TTF_INSTALL "Enable SDL2_ttf install target" ${SDL2TTF_ROOTPROJECT})
 option(SDL2TTF_VENDORED "Use vendored third-party libraries" ${vendored_default})
 
 # For style consistency, create a SDL2TTF_FREETYPE CMake variable. This variable is NOT configurable.