From d98c71106d6fa5245741ef340f1c89c790a5cbf4 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Thu, 9 Feb 2023 20:37:28 +0100
Subject: [PATCH] cmake: cannot install SDL2_net when SDL2 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 11109c2..17dfb9f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -41,6 +41,12 @@ set(SDL2NET_DEBUG_POSTFIX "d"
CACHE STRING "Name suffix for debug builds")
mark_as_advanced(SDL2NET_DEBUG_POSTFIX)
+set(sdl2net_install_enableable ON)
+if ((TARGET SDL2 OR TARGET SDL2-static) AND SDL2_DISABLE_INSTALL)
+ # Cannot install SDL2_net when SDL2 is built in same built, and is not installed.
+ set(sdl2net_install_enableable OFF)
+endif()
+
include(CMakeDependentOption)
include(CMakePackageConfigHelpers)
include(GNUInstallDirs)
@@ -48,7 +54,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(SDL2NET_INSTALL "Enable SDL2_net install target" ${SDL2NET_ROOTPROJECT})
+cmake_dependent_option(SDL2NET_INSTALL "Enable SDL2_net install target" ${SDL2NET_ROOTPROJECT} ${sdl2net_install_enableable} OFF)
cmake_dependent_option(SDL2NET_SAMPLES "Build SDL2_net samples" ${SDL2NET_ROOTPROJECT} "${SDL2test_FOUND}" OFF)