From d1809ab662b1e54b8177cf4f07c43870f4bf254d Mon Sep 17 00:00:00 2001
From: Semphriss <[EMAIL REDACTED]>
Date: Mon, 17 May 2021 19:49:30 +0000
Subject: [PATCH] Allow skipping find_package() for SDL and Freetype if they
are going to be built (#128)
* Skip find_packages()'s for targets
SDL_image has a similar mechanism: If SDL (and/or Freetype) are going to be built, skip the find_package().
NOTE: SDL_image also checks for Android builds; this commit does not perform a similar check.
* Fixed indentation
---
CMakeLists.txt | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e9f1d26..f56ab42 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -44,8 +44,12 @@ else()
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
-find_package(SDL2 REQUIRED)
-find_package(Freetype REQUIRED)
+if (NOT (TARGET SDL2 OR TARGET SDL2-static))
+ find_package(SDL2 REQUIRED)
+endif()
+if (NOT (TARGET Freetype::Freetype))
+ find_package(Freetype REQUIRED)
+endif()
find_package(PkgConfig QUIET)
set(SDL_TTF_MAJOR_VERSION 2)