SDL: build: don't add SDL3 subfolder to include path for external projects

From 9f2ca87504173e550960422561d20ebcca4672c7 Mon Sep 17 00:00:00 2001
From: Anonymous Maarten <[EMAIL REDACTED]>
Date: Sun, 27 Nov 2022 18:36:54 +0100
Subject: [PATCH] build: don't add SDL3 subfolder to include path for external
 projects

---
 CMakeLists.txt                                      | 4 ----
 SDL3Config.cmake.in                                 | 4 ++--
 VisualC/pkg-support/cmake/sdl3-config-version.cmake | 8 ++++----
 cmake/test/main_cli.c                               | 2 +-
 cmake/test/main_gui.c                               | 2 +-
 cmake/test/main_lib.c                               | 2 +-
 mingw/pkg-support/cmake/sdl3-config-version.cmake   | 6 +++---
 mingw/pkg-support/cmake/sdl3-config.cmake           | 6 +++---
 sdl3.pc.in                                          | 2 +-
 9 files changed, 16 insertions(+), 20 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 154b2499d21f..34ee9bb6780b 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -3186,7 +3186,6 @@ if(NOT WINDOWS_STORE AND NOT SDL3_DISABLE_SDL3MAIN)
       "$<BUILD_INTERFACE:${SDL3_BINARY_DIR}/include>"
       "$<BUILD_INTERFACE:${SDL3_SOURCE_DIR}/include>"
       "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
-      "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL3>"
   )
   if (WIN32)
     target_link_libraries(SDL3main PRIVATE shell32)
@@ -3272,7 +3271,6 @@ if(SDL_SHARED)
       "$<BUILD_INTERFACE:${SDL3_BINARY_DIR}/include>"
       "$<BUILD_INTERFACE:${SDL3_SOURCE_DIR}/include>"
       "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
-      "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL3>"
   )
   # This picks up all the compiler options and such we've accumulated up to here.
   target_link_libraries(SDL3 PRIVATE $<BUILD_INTERFACE:sdl-build-options>)
@@ -3307,7 +3305,6 @@ if(SDL_STATIC)
       "$<BUILD_INTERFACE:${SDL3_BINARY_DIR}/include>"
       "$<BUILD_INTERFACE:${SDL3_SOURCE_DIR}/include>"
       "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
-      "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL3>"
   )
   # This picks up all the compiler options and such we've accumulated up to here.
   target_link_libraries(SDL3-static PRIVATE $<BUILD_INTERFACE:sdl-build-options>)
@@ -3338,7 +3335,6 @@ if(SDL_TEST)
       "$<BUILD_INTERFACE:${SDL3_BINARY_DIR}/include>"
       "$<BUILD_INTERFACE:${SDL3_SOURCE_DIR}/include>"
       "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>"
-      "$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/SDL3>"
   )
   target_link_libraries(SDL3_test PRIVATE ${EXTRA_TEST_LIBS})
 endif()
diff --git a/SDL3Config.cmake.in b/SDL3Config.cmake.in
index 52dcfb1982e7..792aefdc3156 100644
--- a/SDL3Config.cmake.in
+++ b/SDL3Config.cmake.in
@@ -47,8 +47,8 @@ endif()
 
 set(SDL3_PREFIX "@PACKAGE_CMAKE_INSTALL_PREFIX@")
 set(SDL3_EXEC_PREFIX "@PACKAGE_CMAKE_INSTALL_PREFIX@")
-set(SDL3_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR@/SDL3")
-set(SDL3_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR@;@PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR@/SDL3")
+set(SDL3_INCLUDE_DIR "@PACKAGE_CMAKE_INSTALL_FULL_INCLUDEDIR@")
+set(SDL3_INCLUDE_DIRS "${SDL3_INCLUDE_DIR}")
 set(SDL3_BINDIR "@PACKAGE_CMAKE_INSTALL_FULL_BINDIR@")
 set(SDL3_LIBDIR "@PACKAGE_CMAKE_INSTALL_FULL_LIBDIR@")
 set(SDL3_LIBRARIES SDL3::SDL3)
diff --git a/VisualC/pkg-support/cmake/sdl3-config-version.cmake b/VisualC/pkg-support/cmake/sdl3-config-version.cmake
index 500e88fdbfc5..3c455dc1917c 100644
--- a/VisualC/pkg-support/cmake/sdl3-config-version.cmake
+++ b/VisualC/pkg-support/cmake/sdl3-config-version.cmake
@@ -3,12 +3,12 @@
 # SDL CMake version configuration file:
 # This file is meant to be placed in a cmake subfolder of SDL3-devel-3.x.y-VC
 
-if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/../include/SDL_version.h")
-    message(AUTHOR_WARNING "Could not find SDL_version.h. This script is meant to be placed in the root of SDL3-devel-3.x.y-VC")
+if(NOT EXISTS "${CMAKE_CURRENT_LIST_DIR}/../include/SDL3/SDL_version.h")
+    message(AUTHOR_WARNING "Could not find SDL3/SDL_version.h. This script is meant to be placed in the root of SDL3-devel-3.x.y-VC")
     return()
 endif()
 
-file(READ "${CMAKE_CURRENT_LIST_DIR}/../include/SDL_version.h" _sdl_version_h)
+file(READ "${CMAKE_CURRENT_LIST_DIR}/../include/SDL3/SDL_version.h" _sdl_version_h)
 string(REGEX MATCH "#define[ \t]+SDL_MAJOR_VERSION[ \t]+([0-9]+)" _sdl_major_re "${_sdl_version_h}")
 set(_sdl_major "${CMAKE_MATCH_1}")
 string(REGEX MATCH "#define[ \t]+SDL_MINOR_VERSION[ \t]+([0-9]+)" _sdl_minor_re "${_sdl_version_h}")
@@ -18,7 +18,7 @@ set(_sdl_patch "${CMAKE_MATCH_1}")
 if(_sdl_major_re AND _sdl_minor_re AND _sdl_patch_re)
     set(PACKAGE_VERSION "${_sdl_major}.${_sdl_minor}.${_sdl_patch}")
 else()
-    message(AUTHOR_WARNING "Could not extract version from SDL_version.h.")
+    message(AUTHOR_WARNING "Could not extract version from SDL3/SDL_version.h.")
     return()
 endif()
 
diff --git a/cmake/test/main_cli.c b/cmake/test/main_cli.c
index 2bbedde88e2c..658b9d54b24d 100644
--- a/cmake/test/main_cli.c
+++ b/cmake/test/main_cli.c
@@ -1,5 +1,5 @@
 #define SDL_MAIN_HANDLED
-#include "SDL.h"
+#include <SDL3/SDL.h>
 #include <stdio.h>
 
 int main(int argc, char *argv[]) {
diff --git a/cmake/test/main_gui.c b/cmake/test/main_gui.c
index 3ba0adbeef48..1f482b6bbc05 100644
--- a/cmake/test/main_gui.c
+++ b/cmake/test/main_gui.c
@@ -1,4 +1,4 @@
-#include "SDL.h"
+#include <SDL3/SDL.h>
 #include <stdio.h>
 
 int main(int argc, char *argv[]) {
diff --git a/cmake/test/main_lib.c b/cmake/test/main_lib.c
index 0f8928b8d99e..5e7763df75c1 100644
--- a/cmake/test/main_lib.c
+++ b/cmake/test/main_lib.c
@@ -1,4 +1,4 @@
-#include "SDL.h"
+#include <SDL3/SDL.h>
 #include <stdio.h>
 
 #include EXPORT_HEADER
diff --git a/mingw/pkg-support/cmake/sdl3-config-version.cmake b/mingw/pkg-support/cmake/sdl3-config-version.cmake
index 2f2bdffd4916..5a78c11eed95 100644
--- a/mingw/pkg-support/cmake/sdl3-config-version.cmake
+++ b/mingw/pkg-support/cmake/sdl3-config-version.cmake
@@ -1,10 +1,10 @@
 # SDL3 CMake version configuration file:
-# This file is meant to be placed in a cmake subfolder of SDL3-devel-2.x.y-mingw
+# This file is meant to be placed in a cmake subfolder of SDL3-devel-3.x.y-mingw
 
 if(CMAKE_SIZEOF_VOID_P EQUAL 4)
-    set(sdl3_config_path "${CMAKE_CURRENT_LIST_DIR}/../i686-w64-mingw32/lib/cmake/SDL3/sdl3-config-version.cmake")
+    set(sdl3_config_path "${CMAKE_CURRENT_LIST_DIR}/../i686-w64-mingw32/lib/cmake/SDL3/SDL3ConfigVersion.cmake")
 elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
-    set(sdl3_config_path "${CMAKE_CURRENT_LIST_DIR}/../x86_64-w64-mingw32/lib/cmake/SDL3/sdl3-config-version.cmake")
+    set(sdl3_config_path "${CMAKE_CURRENT_LIST_DIR}/../x86_64-w64-mingw32/lib/cmake/SDL3/SDL3ConfigVersion.cmake")
 else()
     set(PACKAGE_VERSION_UNSUITABLE TRUE)
     return()
diff --git a/mingw/pkg-support/cmake/sdl3-config.cmake b/mingw/pkg-support/cmake/sdl3-config.cmake
index 291845f99507..71d7634ddd94 100644
--- a/mingw/pkg-support/cmake/sdl3-config.cmake
+++ b/mingw/pkg-support/cmake/sdl3-config.cmake
@@ -1,10 +1,10 @@
 # SDL3 CMake configuration file:
-# This file is meant to be placed in a cmake subfolder of SDL3-devel-2.x.y-mingw
+# This file is meant to be placed in a cmake subfolder of SDL3-devel-3.x.y-mingw
 
 if(CMAKE_SIZEOF_VOID_P EQUAL 4)
-    set(sdl3_config_path "${CMAKE_CURRENT_LIST_DIR}/../i686-w64-mingw32/lib/cmake/SDL3/sdl3-config.cmake")
+    set(sdl3_config_path "${CMAKE_CURRENT_LIST_DIR}/../i686-w64-mingw32/lib/cmake/SDL3/SDL3Config.cmake")
 elseif(CMAKE_SIZEOF_VOID_P EQUAL 8)
-    set(sdl3_config_path "${CMAKE_CURRENT_LIST_DIR}/../x86_64-w64-mingw32/lib/cmake/SDL3/sdl3-config.cmake")
+    set(sdl3_config_path "${CMAKE_CURRENT_LIST_DIR}/../x86_64-w64-mingw32/lib/cmake/SDL3/SDL3Config.cmake")
 else()
     set(SDL3_FOUND FALSE)
     return()
diff --git a/sdl3.pc.in b/sdl3.pc.in
index 96a480c86fee..0f8c374988bf 100644
--- a/sdl3.pc.in
+++ b/sdl3.pc.in
@@ -11,4 +11,4 @@ Version: @SDL_VERSION@
 Requires:
 Conflicts:
 Libs: -L${libdir} @SDL_RLD_FLAGS@ @SDL_LIBS@ @PKGCONFIG_LIBS_PRIV@ @SDL_STATIC_LIBS@
-Cflags: -I${includedir} -I${includedir}/SDL3 @SDL_CFLAGS@
+Cflags: -I${includedir} @SDL_CFLAGS@