SDL: cmake: check if CMP0087 exists before setting it (#8613)

From 0fb36f29a8c548bb338dc27beab4b2bf4ef9f149 Mon Sep 17 00:00:00 2001
From: CasualPokePlayer <[EMAIL REDACTED]>
Date: Sat, 25 Nov 2023 13:42:55 -0800
Subject: [PATCH] cmake: check if CMP0087 exists before setting it (#8613)

Fixes builds using < CMake 3.14
---
 cmake/macros.cmake | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/cmake/macros.cmake b/cmake/macros.cmake
index 2087e54b681d..5060923e8ec5 100644
--- a/cmake/macros.cmake
+++ b/cmake/macros.cmake
@@ -126,7 +126,9 @@ if(CMAKE_VERSION VERSION_LESS 3.13.0)
 endif()
 
 # CMP0087: install(CODE) and install(SCRIPT) support generator expressions.
-cmake_policy(SET CMP0087 NEW)
+if(POLICY CMP0087)
+  cmake_policy(SET CMP0087 NEW)
+endif()
 function(SDL_install_pdb TARGET DIRECTORY)
   get_property(type TARGET ${TARGET} PROPERTY TYPE)
   if(type MATCHES "^(SHARED_LIBRARY|EXECUTABLE)$")