summaryrefslogtreecommitdiff
path: root/deps/glfw-3.3.8/CMake/GenerateMappings.cmake
diff options
context:
space:
mode:
authorOmniscient <17525998+omnisci3nce@users.noreply.github.com>2024-02-24 22:47:46 +1100
committerOmniscient <17525998+omnisci3nce@users.noreply.github.com>2024-02-24 22:47:46 +1100
commit7b3afcaf77f96e7d62f6cd1623ead7f17512d79f (patch)
treeb5f82c64e9c06a84e4d095ab4ac48712e860b673 /deps/glfw-3.3.8/CMake/GenerateMappings.cmake
parentb047be5252aeb981faea077409c1768fda0301d9 (diff)
repo init. partial port of existing code
Diffstat (limited to 'deps/glfw-3.3.8/CMake/GenerateMappings.cmake')
-rw-r--r--deps/glfw-3.3.8/CMake/GenerateMappings.cmake48
1 files changed, 48 insertions, 0 deletions
diff --git a/deps/glfw-3.3.8/CMake/GenerateMappings.cmake b/deps/glfw-3.3.8/CMake/GenerateMappings.cmake
new file mode 100644
index 0000000..47e6374
--- /dev/null
+++ b/deps/glfw-3.3.8/CMake/GenerateMappings.cmake
@@ -0,0 +1,48 @@
+# Usage:
+# cmake -P GenerateMappings.cmake <path/to/mappings.h.in> <path/to/mappings.h>
+
+set(source_url "https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt")
+set(source_path "${CMAKE_CURRENT_BINARY_DIR}/gamecontrollerdb.txt")
+set(template_path "${CMAKE_ARGV3}")
+set(target_path "${CMAKE_ARGV4}")
+
+if (NOT EXISTS "${template_path}")
+ message(FATAL_ERROR "Failed to find template file ${template_path}")
+endif()
+
+file(DOWNLOAD "${source_url}" "${source_path}"
+ STATUS download_status
+ TLS_VERIFY on)
+
+list(GET download_status 0 status_code)
+list(GET download_status 1 status_message)
+
+if (status_code)
+ message(FATAL_ERROR "Failed to download ${source_url}: ${status_message}")
+endif()
+
+file(STRINGS "${source_path}" lines)
+foreach(line ${lines})
+ if (line MATCHES "^[0-9a-fA-F]")
+ if (line MATCHES "platform:Windows")
+ if (GLFW_WIN32_MAPPINGS)
+ set(GLFW_WIN32_MAPPINGS "${GLFW_WIN32_MAPPINGS}\n")
+ endif()
+ set(GLFW_WIN32_MAPPINGS "${GLFW_WIN32_MAPPINGS}\"${line}\",")
+ elseif (line MATCHES "platform:Mac OS X")
+ if (GLFW_COCOA_MAPPINGS)
+ set(GLFW_COCOA_MAPPINGS "${GLFW_COCOA_MAPPINGS}\n")
+ endif()
+ set(GLFW_COCOA_MAPPINGS "${GLFW_COCOA_MAPPINGS}\"${line}\",")
+ elseif (line MATCHES "platform:Linux")
+ if (GLFW_LINUX_MAPPINGS)
+ set(GLFW_LINUX_MAPPINGS "${GLFW_LINUX_MAPPINGS}\n")
+ endif()
+ set(GLFW_LINUX_MAPPINGS "${GLFW_LINUX_MAPPINGS}\"${line}\",")
+ endif()
+ endif()
+endforeach()
+
+configure_file("${template_path}" "${target_path}" @ONLY NEWLINE_STYLE UNIX)
+file(REMOVE "${source_path}")
+