SDL: cmake: we only need a C++ compiler for Android, Haiku and UWP (31849)

From 31849369506d54aac7fa799c8c2851ded18c87f5 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Mon, 11 Mar 2024 01:07:14 +0100
Subject: [PATCH] cmake: we only need a C++ compiler for Android, Haiku and UWP

---
 CMakeLists.txt        | 4 +++-
 cmake/sdlchecks.cmake | 1 +
 test/CMakeLists.txt   | 2 +-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 53a5894f99beb..2cda5e0585542 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,7 +6,7 @@ endif()
 set(CMAKE_POLICY_DEFAULT_CMP0091 NEW)
 
 cmake_minimum_required(VERSION 3.0.0...3.5)
-project(SDL2 C CXX)
+project(SDL2 C)
 
 if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
   set(SDL2_SUBPROJECT OFF)
@@ -15,6 +15,7 @@ else()
 endif()
 
 if (HAIKU)
+  enable_language(CXX)
   set(LINKER_LANGUAGE CXX)
 endif()
 
@@ -1787,6 +1788,7 @@ elseif(WINDOWS)
   list(APPEND SOURCE_FILES ${CORE_SOURCES})
 
   if(WINDOWS_STORE)
+    enable_language(CXX)
     file(GLOB WINRT_SOURCE_FILES ${SDL2_SOURCE_DIR}/src/core/winrt/*.c ${SDL2_SOURCE_DIR}/src/core/winrt/*.cpp)
     list(APPEND SOURCE_FILES ${WINRT_SOURCE_FILES})
   endif()
diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake
index 815665364785c..1f070cc51400b 100644
--- a/cmake/sdlchecks.cmake
+++ b/cmake/sdlchecks.cmake
@@ -1249,6 +1249,7 @@ macro(CheckHIDAPI)
 
     if(HAVE_HIDAPI)
       if(ANDROID)
+        enable_language(CXX)
         list(APPEND SOURCE_FILES ${SDL2_SOURCE_DIR}/src/hidapi/android/hid.cpp)
       endif()
       if(IOS OR TVOS)
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt
index f048d51f9edcd..54912ffefa09a 100644
--- a/test/CMakeLists.txt
+++ b/test/CMakeLists.txt
@@ -1,5 +1,5 @@
 cmake_minimum_required(VERSION 3.0...3.5)
-project(SDL2_test)
+project(SDL2_test C)
 
 include(CheckCCompilerFlag)
 include(CMakeParseArguments)