aboutsummaryrefslogtreecommitdiff
path: root/raylib/src/external/glfw/CMake/GenerateMappings.cmake
diff options
context:
space:
mode:
authorSebastiano Tronto <sebastiano@tronto.net>2025-04-21 11:09:56 +0200
committerSebastiano Tronto <sebastiano@tronto.net>2025-04-21 11:09:56 +0200
commit123144c93bfc77883c8fb517828b47bbe13b8671 (patch)
tree762739afedb5f3f168051367515cb9b9a06ec68d /raylib/src/external/glfw/CMake/GenerateMappings.cmake
downloadminesweeper-123144c93bfc77883c8fb517828b47bbe13b8671.tar.gz
minesweeper-123144c93bfc77883c8fb517828b47bbe13b8671.zip
Initial commitHEADmaster
Diffstat (limited to 'raylib/src/external/glfw/CMake/GenerateMappings.cmake')
-rw-r--r--raylib/src/external/glfw/CMake/GenerateMappings.cmake48
1 files changed, 48 insertions, 0 deletions
diff --git a/raylib/src/external/glfw/CMake/GenerateMappings.cmake b/raylib/src/external/glfw/CMake/GenerateMappings.cmake
new file mode 100644
index 0000000..c8c9e23
--- /dev/null
+++ b/raylib/src/external/glfw/CMake/GenerateMappings.cmake
@@ -0,0 +1,48 @@
1# Usage:
2# cmake -P GenerateMappings.cmake <path/to/mappings.h.in> <path/to/mappings.h>
3
4set(source_url "https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt")
5set(source_path "${CMAKE_CURRENT_BINARY_DIR}/gamecontrollerdb.txt")
6set(template_path "${CMAKE_ARGV3}")
7set(target_path "${CMAKE_ARGV4}")
8
9if (NOT EXISTS "${template_path}")
10 message(FATAL_ERROR "Failed to find template file ${template_path}")
11endif()
12
13file(DOWNLOAD "${source_url}" "${source_path}"
14 STATUS download_status
15 TLS_VERIFY on)
16
17list(GET download_status 0 status_code)
18list(GET download_status 1 status_message)
19
20if (status_code)
21 message(FATAL_ERROR "Failed to download ${source_url}: ${status_message}")
22endif()
23
24file(STRINGS "${source_path}" lines)
25foreach(line ${lines})
26 if (line MATCHES "^[0-9a-fA-F]")
27 if (line MATCHES "platform:Windows")
28 if (GLFW_WIN32_MAPPINGS)
29 string(APPEND GLFW_WIN32_MAPPINGS "\n")
30 endif()
31 string(APPEND GLFW_WIN32_MAPPINGS "\"${line}\",")
32 elseif (line MATCHES "platform:Mac OS X")
33 if (GLFW_COCOA_MAPPINGS)
34 string(APPEND GLFW_COCOA_MAPPINGS "\n")
35 endif()
36 string(APPEND GLFW_COCOA_MAPPINGS "\"${line}\",")
37 elseif (line MATCHES "platform:Linux")
38 if (GLFW_LINUX_MAPPINGS)
39 string(APPEND GLFW_LINUX_MAPPINGS "\n")
40 endif()
41 string(APPEND GLFW_LINUX_MAPPINGS "\"${line}\",")
42 endif()
43 endif()
44endforeach()
45
46configure_file("${template_path}" "${target_path}" @ONLY NEWLINE_STYLE UNIX)
47file(REMOVE "${source_path}")
48

Generated with cgit - Back to sebastiano.tronto.net