summaryrefslogtreecommitdiff
path: root/src/contrib/SDL-3.2.20/build-scripts/pkg-support/msvc/cmake
diff options
context:
space:
mode:
author3gg <3gg@shellblade.net>2025-08-30 16:53:58 -0700
committer3gg <3gg@shellblade.net>2025-08-30 16:53:58 -0700
commit6aaedb813fa11ba0679c3051bc2eb28646b9506c (patch)
tree34acbfc9840e02cb4753e6306ea7ce978bf8b58e /src/contrib/SDL-3.2.20/build-scripts/pkg-support/msvc/cmake
parent8f228ade99dd3d4c8da9b78ade1815c9adf85c8f (diff)
Update to SDL3
Diffstat (limited to 'src/contrib/SDL-3.2.20/build-scripts/pkg-support/msvc/cmake')
-rw-r--r--src/contrib/SDL-3.2.20/build-scripts/pkg-support/msvc/cmake/SDL3Config.cmake.in135
-rw-r--r--src/contrib/SDL-3.2.20/build-scripts/pkg-support/msvc/cmake/SDL3ConfigVersion.cmake.in38
2 files changed, 173 insertions, 0 deletions
diff --git a/src/contrib/SDL-3.2.20/build-scripts/pkg-support/msvc/cmake/SDL3Config.cmake.in b/src/contrib/SDL-3.2.20/build-scripts/pkg-support/msvc/cmake/SDL3Config.cmake.in
new file mode 100644
index 0000000..6387376
--- /dev/null
+++ b/src/contrib/SDL-3.2.20/build-scripts/pkg-support/msvc/cmake/SDL3Config.cmake.in
@@ -0,0 +1,135 @@
1# @<@PROJECT_NAME@>@ CMake configuration file:
2# This file is meant to be placed in a cmake subfolder of @<@PROJECT_NAME@>@-devel-@<@PROJECT_VERSION@>@-VC.zip
3
4cmake_minimum_required(VERSION 3.0...3.28)
5
6include(FeatureSummary)
7set_package_properties(SDL3 PROPERTIES
8 URL "https://www.libsdl.org/"
9 DESCRIPTION "low level access to audio, keyboard, mouse, joystick, and graphics hardware"
10)
11
12# Copied from `configure_package_config_file`
13macro(set_and_check _var _file)
14 set(${_var} "${_file}")
15 if(NOT EXISTS "${_file}")
16 message(FATAL_ERROR "File or directory ${_file} referenced by variable ${_var} does not exist !")
17 endif()
18endmacro()
19
20# Copied from `configure_package_config_file`
21macro(check_required_components _NAME)
22 foreach(comp ${${_NAME}_FIND_COMPONENTS})
23 if(NOT ${_NAME}_${comp}_FOUND)
24 if(${_NAME}_FIND_REQUIRED_${comp})
25 set(${_NAME}_FOUND FALSE)
26 endif()
27 endif()
28 endforeach()
29endmacro()
30
31set(SDL3_FOUND TRUE)
32
33if(SDL_CPU_X86)
34 set(_sdl_arch_subdir "x86")
35elseif(SDL_CPU_X64 OR SDL_CPU_ARM64EC)
36 set(_sdl_arch_subdir "x64")
37elseif(SDL_CPU_ARM64)
38 set(_sdl_arch_subdir "arm64")
39else()
40 set(SDL3_FOUND FALSE)
41 return()
42endif()
43
44get_filename_component(_sdl3_prefix "${CMAKE_CURRENT_LIST_DIR}/.." ABSOLUTE)
45set_and_check(_sdl3_prefix "${_sdl3_prefix}")
46set(_sdl3_include_dirs "${_sdl3_prefix}/include")
47
48set(_sdl3_implib "${_sdl3_prefix}/lib/${_sdl_arch_subdir}/SDL3.lib")
49set(_sdl3_dll "${_sdl3_prefix}/lib/${_sdl_arch_subdir}/SDL3.dll")
50set(_sdl3test_lib "${_sdl3_prefix}/lib/${_sdl_arch_subdir}/SDL3_test.lib")
51
52unset(_sdl_arch_subdir)
53unset(_sdl3_prefix)
54
55# All targets are created, even when some might not be requested though COMPONENTS.
56# This is done for compatibility with CMake generated SDL3-target.cmake files.
57
58if(NOT TARGET SDL3::Headers)
59 add_library(SDL3::Headers INTERFACE IMPORTED)
60 set_target_properties(SDL3::Headers
61 PROPERTIES
62 INTERFACE_INCLUDE_DIRECTORIES "${_sdl3_include_dirs}"
63 )
64endif()
65set(SDL3_Headers_FOUND TRUE)
66unset(_sdl3_include_dirs)
67
68if(EXISTS "${_sdl3_implib}" AND EXISTS "${_sdl3_dll}")
69 if(NOT TARGET SDL3::SDL3-shared)
70 add_library(SDL3::SDL3-shared SHARED IMPORTED)
71 set_target_properties(SDL3::SDL3-shared
72 PROPERTIES
73 INTERFACE_LINK_LIBRARIES "SDL3::Headers"
74 IMPORTED_IMPLIB "${_sdl3_implib}"
75 IMPORTED_LOCATION "${_sdl3_dll}"
76 COMPATIBLE_INTERFACE_BOOL "SDL3_SHARED"
77 INTERFACE_SDL3_SHARED "ON"
78 COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
79 INTERFACE_SDL_VERSION "SDL3"
80 )
81 endif()
82 set(SDL3_SDL3-shared_FOUND TRUE)
83else()
84 set(SDL3_SDL3-shared_FOUND FALSE)
85endif()
86unset(_sdl3_implib)
87unset(_sdl3_dll)
88
89set(SDL3_SDL3-static_FOUND FALSE)
90
91if(EXISTS "${_sdl3test_lib}")
92 if(NOT TARGET SDL3::SDL3_test)
93 add_library(SDL3::SDL3_test STATIC IMPORTED)
94 set_target_properties(SDL3::SDL3_test
95 PROPERTIES
96 INTERFACE_LINK_LIBRARIES "SDL3::Headers"
97 IMPORTED_LOCATION "${_sdl3test_lib}"
98 COMPATIBLE_INTERFACE_STRING "SDL_VERSION"
99 INTERFACE_SDL_VERSION "SDL3"
100 )
101 endif()
102 set(SDL3_SDL3_test_FOUND TRUE)
103else()
104 set(SDL3_SDL3_test_FOUND FALSE)
105endif()
106unset(_sdl3test_lib)
107
108if(SDL3_SDL3-shared_FOUND OR SDL3_SDL3-static_FOUND)
109 set(SDL3_SDL3_FOUND TRUE)
110endif()
111
112function(_sdl_create_target_alias_compat NEW_TARGET TARGET)
113 if(CMAKE_VERSION VERSION_LESS "3.18")
114 # Aliasing local targets is not supported on CMake < 3.18, so make it global.
115 add_library(${NEW_TARGET} INTERFACE IMPORTED)
116 set_target_properties(${NEW_TARGET} PROPERTIES INTERFACE_LINK_LIBRARIES "${TARGET}")
117 else()
118 add_library(${NEW_TARGET} ALIAS ${TARGET})
119 endif()
120endfunction()
121
122# Make sure SDL3::SDL3 always exists
123if(NOT TARGET SDL3::SDL3)
124 if(TARGET SDL3::SDL3-shared)
125 _sdl_create_target_alias_compat(SDL3::SDL3 SDL3::SDL3-shared)
126 endif()
127endif()
128
129check_required_components(SDL3)
130
131set(SDL3_LIBRARIES SDL3::SDL3)
132set(SDL3_STATIC_LIBRARIES SDL3::SDL3-static)
133set(SDL3_STATIC_PRIVATE_LIBS)
134
135set(SDL3TEST_LIBRARY SDL3::SDL3_test)
diff --git a/src/contrib/SDL-3.2.20/build-scripts/pkg-support/msvc/cmake/SDL3ConfigVersion.cmake.in b/src/contrib/SDL-3.2.20/build-scripts/pkg-support/msvc/cmake/SDL3ConfigVersion.cmake.in
new file mode 100644
index 0000000..82b6af0
--- /dev/null
+++ b/src/contrib/SDL-3.2.20/build-scripts/pkg-support/msvc/cmake/SDL3ConfigVersion.cmake.in
@@ -0,0 +1,38 @@
1# @<@PROJECT_NAME@>@ CMake version configuration file:
2# This file is meant to be placed in a cmake subfolder of @<@PROJECT_NAME@>@-devel-@<@PROJECT_VERSION@>@-VC.zip
3
4set(PACKAGE_VERSION "@<@PROJECT_VERSION@>@")
5
6if(PACKAGE_FIND_VERSION_RANGE)
7 # Package version must be in the requested version range
8 if ((PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MIN)
9 OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_GREATER PACKAGE_FIND_VERSION_MAX)
10 OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION_MAX)))
11 set(PACKAGE_VERSION_COMPATIBLE FALSE)
12 else()
13 set(PACKAGE_VERSION_COMPATIBLE TRUE)
14 endif()
15else()
16 if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
17 set(PACKAGE_VERSION_COMPATIBLE FALSE)
18 else()
19 set(PACKAGE_VERSION_COMPATIBLE TRUE)
20 if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION)
21 set(PACKAGE_VERSION_EXACT TRUE)
22 endif()
23 endif()
24endif()
25
26# if the using project doesn't have CMAKE_SIZEOF_VOID_P set, fail.
27if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "")
28 set(PACKAGE_VERSION_UNSUITABLE TRUE)
29endif()
30
31include("${CMAKE_CURRENT_LIST_DIR}/sdlcpu.cmake")
32SDL_DetectTargetCPUArchitectures(_detected_archs)
33
34# check that the installed version has a compatible architecture as the one which is currently searching:
35if(NOT(SDL_CPU_X86 OR SDL_CPU_X64 OR SDL_CPU_ARM64 OR SDL_CPU_ARM64EC))
36 set(PACKAGE_VERSION "${PACKAGE_VERSION} (X86,X64,ARM64)")
37 set(PACKAGE_VERSION_UNSUITABLE TRUE)
38endif()