From a6ec0bdd683410fee6bd083bd4a15f9f8b7ae711 Mon Sep 17 00:00:00 2001 From: ksqsf Date: Mon, 6 May 2024 10:35:05 +0800 Subject: [PATCH] Allow overriding iso-codes and xkb paths (#1042) --- CMakeLists.txt | 4 ++-- cmake/FindIsoCodes.cmake | 16 ++++++++++------ cmake/FindXKeyboardConfig.cmake | 8 ++++++-- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9c94be99a..a66f36296 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -124,8 +124,8 @@ if (ENABLE_KEYBOARD) pkg_check_modules(JsonC REQUIRED IMPORTED_TARGET "json-c") set(DEFAULT_XKB_RULES_FILES "${XKEYBOARDCONFIG_XKBBASE}/rules/${DEFAULT_XKB_RULES}.xml") - if (NOT EXISTS "${DEFAULT_XKB_RULES_FILES}") - message(FATAL_ERROR "Could not find default xkb rules file: ${DEFAULT_XKB_RULES_FILES}") + if (NOT EXISTS "${DEFAULT_XKB_RULES_FILES}" AND NOT APPLE) + message(WARNING "Could not find default xkb rules file: ${DEFAULT_XKB_RULES_FILES}") endif() endif() diff --git a/cmake/FindIsoCodes.cmake b/cmake/FindIsoCodes.cmake index d2d131874..2cdd765bd 100644 --- a/cmake/FindIsoCodes.cmake +++ b/cmake/FindIsoCodes.cmake @@ -18,13 +18,17 @@ endif(ISOCODES_INCLUDE_DIR AND ISOCODES_LIBRARIES) find_package(PkgConfig) pkg_check_modules(PC_ISOCODES iso-codes) -find_file(ISOCODES_ISO639_JSON iso_639-3.json - HINTS "${PC_ISOCODES_PREFIX}/share/iso-codes/json/" - ) +if(NOT DEFINED ISOCODES_ISO639_JSON) + find_file(ISOCODES_ISO639_JSON iso_639-3.json + HINTS "${PC_ISOCODES_PREFIX}/share/iso-codes/json/" + ) +endif() -find_file(ISOCODES_ISO3166_JSON iso_3166-1.json - HINTS "${PC_ISOCODES_PREFIX}/share/iso-codes/json/" - ) +if(NOT DEFINED ISOCODES_ISO3166_JSON) + find_file(ISOCODES_ISO3166_JSON iso_3166-1.json + HINTS "${PC_ISOCODES_PREFIX}/share/iso-codes/json/" + ) +endif() include(FindPackageHandleStandardArgs) find_package_handle_standard_args(IsoCodes DEFAULT_MSG ISOCODES_ISO639_JSON ISOCODES_ISO3166_JSON) diff --git a/cmake/FindXKeyboardConfig.cmake b/cmake/FindXKeyboardConfig.cmake index 5728debaf..a2b8e117f 100644 --- a/cmake/FindXKeyboardConfig.cmake +++ b/cmake/FindXKeyboardConfig.cmake @@ -2,8 +2,12 @@ find_package(PkgConfig) pkg_check_modules(PKG_XKEYBOARDCONFIG QUIET xkeyboard-config) -pkg_get_variable(XKEYBOARDCONFIG_XKBBASE xkeyboard-config xkb_base) -pkg_get_variable(XKEYBOARDCONFIG_DATADIR xkeyboard-config datadir) +if(NOT DEFINED XKEYBOARDCONFIG_XKBBASE) + pkg_get_variable(XKEYBOARDCONFIG_XKBBASE xkeyboard-config xkb_base) +endif() +if(NOT DEFINED XKEYBOARDCONFIG_DATADIR) + pkg_get_variable(XKEYBOARDCONFIG_DATADIR xkeyboard-config datadir) +endif() set(XKEYBOARDCONFIG_VERSION ${PKG_XKEYBOARDCONFIG_VERSION}) mark_as_advanced(XKEYBOARDCONFIG_VERSION)