From 3705bb808267b8de1b9fec83d9f8380ec25a3ceb Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Thu, 9 Feb 2023 20:34:38 +0100
Subject: [PATCH] cmake: cannot install SDL3_image 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 83cbe4e9..e9449a67 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -42,6 +42,12 @@ else()
set(vendored_default OFF)
endif()
+set(sdl3image_install_enableable ON)
+if ((TARGET SDL3 OR TARGET SDL3-static) AND SDL3_DISABLE_INSTALL)
+ # Cannot install SDL3_image when SDL3 is built in same built, and is not installed.
+ set(sdl3image_install_enableable OFF)
+endif()
+
include(CMakeDependentOption)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
@@ -49,7 +55,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(SDL3IMAGE_INSTALL "Enable SDL3_image install target" ${SDL3IMAGE_ROOTPROJECT})
+cmake_dependent_option(SDL3IMAGE_INSTALL "Enable SDL3_image install target" ${SDL3IMAGE_ROOTPROJECT} "${sdl3image_install_enableable}" OFF)
option(SDL3IMAGE_DEPS_SHARED "Load dependencies dynamically" ON)
option(SDL3IMAGE_VENDORED "Use vendored third-party libraries" ${vendored_default})
option(SDL3IMAGE_WERROR "Treat warnings as errors" OFF)