SDL: Initialize SDL_STATIC_PIC from CMAKE_POSITION_INDEPENDENT_CODE

From fd3f381021723c2dc4542505b38458b7d98af4c2 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Sat, 4 Jun 2022 03:16:27 +0200
Subject: [PATCH] Initialize SDL_STATIC_PIC from
 CMAKE_POSITION_INDEPENDENT_CODE

---
 CMakeLists.txt | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c988ef56c18..18cf7302b55 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -483,7 +483,12 @@ set(SDL_SHARED ${SDL_SHARED_ENABLED_BY_DEFAULT} CACHE BOOL "Build a shared versi
 set(SDL_STATIC ${SDL_STATIC_ENABLED_BY_DEFAULT} CACHE BOOL "Build a static version of the library")
 set(SDL_TEST   ${SDL_TEST_ENABLED_BY_DEFAULT} CACHE BOOL "Build the SDL2_test library")
 
-dep_option(SDL_STATIC_PIC      "Static version of the library should be built with Position Independent Code" OFF "SDL_STATIC" OFF)
+# Some platforms have CMAKE_POSITION_INDEPENDENT_CODE not defined
+if(NOT DEFINED CMAKE_POSITION_INDEPENDENT_CODE)
+  set(CMAKE_POSITION_INDEPENDENT_CODE FALSE)
+endif()
+
+dep_option(SDL_STATIC_PIC      "Static version of the library should be built with Position Independent Code" "${CMAKE_POSITION_INDEPENDENT_CODE}" "SDL_STATIC" OFF)
 dep_option(SDL_TESTS           "Build the test directory" OFF SDL_TEST OFF)
 set_option(SDL_INSTALL_TESTS   "Install test-cases" OFF)