ScrapExplorer - GenerateMappings.cmake

Home / ext / glfw / CMake Lines: 4 | Size: 1623 bytes [Download] [Show on GitHub] [Search similar files] [Raw] [Raw (proxy)]
[FILE BEGIN]
1# Usage: 2# cmake -P GenerateMappings.cmake <path/to/mappings.h.in> <path/to/mappings.h> 3 4cmake_policy(VERSION 3.16) 5 6set(source_url "https://raw.githubusercontent.com/gabomdq/SDL_GameControllerDB/master/gamecontrollerdb.txt") 7set(source_path "${CMAKE_CURRENT_BINARY_DIR}/gamecontrollerdb.txt") 8set(template_path "${CMAKE_ARGV3}") 9set(target_path "${CMAKE_ARGV4}") 10 11if (NOT EXISTS "${template_path}") 12 message(FATAL_ERROR "Failed to find template file ${template_path}") 13endif() 14 15file(DOWNLOAD "${source_url}" "${source_path}" 16 STATUS download_status 17 TLS_VERIFY on) 18 19list(GET download_status 0 status_code) 20list(GET download_status 1 status_message) 21 22if (status_code) 23 message(FATAL_ERROR "Failed to download ${source_url}: ${status_message}") 24endif() 25 26file(STRINGS "${source_path}" lines) 27list(FILTER lines INCLUDE REGEX "^[0-9a-fA-F]") 28 29foreach(line IN LISTS lines) 30 if (line MATCHES "platform:Windows") 31 if (GLFW_WIN32_MAPPINGS) 32 string(APPEND GLFW_WIN32_MAPPINGS "\n") 33 endif() 34 string(APPEND GLFW_WIN32_MAPPINGS "\"${line}\",") 35 elseif (line MATCHES "platform:Mac OS X") 36 if (GLFW_COCOA_MAPPINGS) 37 string(APPEND GLFW_COCOA_MAPPINGS "\n") 38 endif() 39 string(APPEND GLFW_COCOA_MAPPINGS "\"${line}\",") 40 elseif (line MATCHES "platform:Linux") 41 if (GLFW_LINUX_MAPPINGS) 42 string(APPEND GLFW_LINUX_MAPPINGS "\n") 43 endif() 44 string(APPEND GLFW_LINUX_MAPPINGS "\"${line}\",") 45 endif() 46endforeach() 47 48configure_file("${template_path}" "${target_path}" @ONLY NEWLINE_STYLE UNIX) 49file(REMOVE "${source_path}") 50 51
[FILE END]
(C) 2025 0x4248 (C) 2025 4248 Media and 4248 Systems, All part of 0x4248 See LICENCE files for more information. Not all files are by 0x4248 always check Licencing.