SDL: cmake: get rid of the duplicated _USE_MATH_DEFINES

From 68b30d24e0d4581f7e61c0b1dc8bc6e8b0594d01 Mon Sep 17 00:00:00 2001
From: pionere <[EMAIL REDACTED]>
Date: Tue, 22 Nov 2022 10:48:23 +0100
Subject: [PATCH] cmake: get rid of the duplicated _USE_MATH_DEFINES - define
 _USE_MATH_DEFINES in SDL_stdinc.h only - define _USE_MATH_DEFINES if not
 defined already

---
 CMakeLists.txt       | 1 -
 include/SDL_stdinc.h | 2 +-
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 702d0c433f64..c1bcefd3fb85 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -999,7 +999,6 @@ if(SDL_LIBC)
     endforeach()
     set(HAVE_ALLOCA 1)
     check_symbol_exists(M_PI math.h HAVE_M_PI)
-    target_compile_definitions(sdl-build-options INTERFACE "-D_USE_MATH_DEFINES") # needed for M_PI
     set(STDC_HEADERS 1)
   else()
     set(HAVE_LIBC TRUE)
diff --git a/include/SDL_stdinc.h b/include/SDL_stdinc.h
index 70dba7db6950..401515211313 100644
--- a/include/SDL_stdinc.h
+++ b/include/SDL_stdinc.h
@@ -80,7 +80,7 @@
 # include <ctype.h>
 #endif
 #ifdef HAVE_MATH_H
-# if defined(_MSC_VER)
+# if defined(_MSC_VER) && !defined(_USE_MATH_DEFINES)
 /* Defining _USE_MATH_DEFINES is required to get M_PI to be defined on
    Visual Studio.  See http://msdn.microsoft.com/en-us/library/4hwaceh6.aspx
    for more information.