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

From b5eb704fa8d95fc1e4389c0f5b0cdf494de67228 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Sun, 10 Mar 2024 23:57:24 +0100
Subject: [PATCH] cmake: we only need a C++ compiler for Android, Haiku and UWP

Our CMake script does (currently) not support NGage, Xbox One, or Xbox Series.
---
 CMakeLists.txt                   | 4 +++-
 build-scripts/test-versioning.sh | 2 +-
 cmake/sdlchecks.cmake            | 1 +
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7002af4867ca9..9e5e4bcf094bf 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -8,7 +8,7 @@ endif()
 set(CMAKE_POLICY_DEFAULT_CMP0091 NEW)
 
 # See docs/release_checklist.md
-project(SDL3 LANGUAGES C CXX VERSION "3.0.0")
+project(SDL3 LANGUAGES C VERSION "3.0.0")
 
 if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR)
   set(SDL3_SUBPROJECT OFF)
@@ -1788,6 +1788,7 @@ elseif(WINDOWS)
   sdl_glob_sources("${SDL3_SOURCE_DIR}/src/core/windows/*.c")
 
   if(WINDOWS_STORE)
+    enable_language(CXX)
     sdl_glob_sources(
       "${SDL3_SOURCE_DIR}/src/core/winrt/*.c"
       "${SDL3_SOURCE_DIR}/src/core/winrt/*.cpp"
@@ -2357,6 +2358,7 @@ elseif(APPLE)
   endif()
 
 elseif(HAIKU)
+  enable_language(CXX)
   if(SDL_AUDIO)
     set(SDL_AUDIO_DRIVER_HAIKU 1)
     sdl_glob_sources("${SDL3_SOURCE_DIR}/src/audio/haiku/*.cc")
diff --git a/build-scripts/test-versioning.sh b/build-scripts/test-versioning.sh
index 9dd9b18af167a..a887a9cc86946 100755
--- a/build-scripts/test-versioning.sh
+++ b/build-scripts/test-versioning.sh
@@ -25,7 +25,7 @@ not_ok () {
     failed=1
 }
 
-version=$(sed -Ene 's/^project\(SDL[0-9]+ LANGUAGES C CXX VERSION "([0-9.]*)"\)$/\1/p' CMakeLists.txt)
+version=$(sed -Ene 's/^project\(SDL[0-9]+ LANGUAGES C VERSION "([0-9.]*)"\)$/\1/p' CMakeLists.txt)
 
 if [ "$ref_version" = "$version" ]; then
     ok "CMakeLists.txt $version"
diff --git a/cmake/sdlchecks.cmake b/cmake/sdlchecks.cmake
index aec4f479faeb7..6a12b3049f0f3 100644
--- a/cmake/sdlchecks.cmake
+++ b/cmake/sdlchecks.cmake
@@ -1068,6 +1068,7 @@ macro(CheckHIDAPI)
 
     if(HAVE_HIDAPI)
       if(ANDROID)
+        enable_language(CXX)
         sdl_sources("${SDL3_SOURCE_DIR}/src/hidapi/android/hid.cpp")
       endif()
       if(IOS OR TVOS)