SDL_ttf: Build dependencies as a static library

From d1b82447c9a38501cf5c862b240c6f7f14faf111 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Mon, 16 May 2022 16:00:02 +0200
Subject: [PATCH] Build dependencies as a static library

---
 CMakeLists.txt | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index f4070b1..022e51f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -126,6 +126,12 @@ set(INSTALL_EXTRA_TARGETS)
 set(PC_LIBS)
 set(PC_REQUIRES)
 
+# Save BUILD_SHARED_LIBS variable
+set(SDL2TTF_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
+
+# Build freetype and harfbuzz as a static library (avoid cyclic dependency between shared libraries)
+set(BUILD_SHARED_LIBS OFF)
+
 if (TTF_WITH_HARFBUZZ)
     target_compile_definitions(SDL2_ttf PRIVATE TTF_USE_HARFBUZZ=1)
     if (TTF_WITH_HARFBUZZ_VENDORED)
@@ -173,6 +179,9 @@ if (TTF_WITH_FREETYPE)
     target_link_libraries(SDL2_ttf PRIVATE Freetype::Freetype)
 endif()
 
+# Restore BUILD_SHARED_LIBS variable
+set(BUILD_SHARED_LIBS ${SDL2TTF_BUILD_SHARED_LIBS})
+
 set_target_properties(SDL2_ttf PROPERTIES
     DEFINE_SYMBOL DLL_EXPORT
     PUBLIC_HEADER SDL_ttf.h