From 11edae3fbf770695d1b263712ca4f3a40bdd70e3 Mon Sep 17 00:00:00 2001 From: rtk0c Date: Sun, 3 Apr 2022 18:36:23 -0700 Subject: Changeset: 1 Branch comment: [] Initial commit --- 3rdparty/glfw/source/CMake/GenerateMappings.cmake | 48 +++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 3rdparty/glfw/source/CMake/GenerateMappings.cmake (limited to '3rdparty/glfw/source/CMake/GenerateMappings.cmake') diff --git a/3rdparty/glfw/source/CMake/GenerateMappings.cmake b/3rdparty/glfw/source/CMake/GenerateMappings.cmake new file mode 100644 index 0000000..c8c9e23 --- /dev/null +++ b/3rdparty/glfw/source/CMake/GenerateMappings.cmake @@ -0,0 +1,48 @@ +# Usage: +# cmake -P GenerateMappings.cmake + +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) + string(APPEND GLFW_WIN32_MAPPINGS "\n") + endif() + string(APPEND GLFW_WIN32_MAPPINGS "\"${line}\",") + elseif (line MATCHES "platform:Mac OS X") + if (GLFW_COCOA_MAPPINGS) + string(APPEND GLFW_COCOA_MAPPINGS "\n") + endif() + string(APPEND GLFW_COCOA_MAPPINGS "\"${line}\",") + elseif (line MATCHES "platform:Linux") + if (GLFW_LINUX_MAPPINGS) + string(APPEND GLFW_LINUX_MAPPINGS "\n") + endif() + string(APPEND GLFW_LINUX_MAPPINGS "\"${line}\",") + endif() + endif() +endforeach() + +configure_file("${template_path}" "${target_path}" @ONLY NEWLINE_STYLE UNIX) +file(REMOVE "${source_path}") + -- cgit v1.2.3-70-g09d2