CMake: Check and enable use of libxkbcommon

CMake's has built-in support for checking xkbcommon using FindX11 since
3.18.

But because older CMake versions are supported, add our own module that
checks if the header and library is available.

See #23410.

Closes #23613.
This commit is contained in:
Maarten Bent 2023-06-06 00:16:08 +02:00 committed by Vadim Zeitlin
parent 241ed70b5b
commit a801057f1a
3 changed files with 44 additions and 1 deletions

View file

@ -614,7 +614,19 @@ if(wxUSE_GUI)
wx_option_force_value(wxUSE_CAIRO OFF)
endif()
endif()
endif()
if(WXGTK AND NOT APPLE AND NOT WIN32)
find_package(XKBCommon)
if(XKBCOMMON_FOUND)
list(APPEND wxTOOLKIT_INCLUDE_DIRS ${XKBCOMMON_INCLUDE_DIRS})
list(APPEND wxTOOLKIT_LIBRARIES ${XKBCOMMON_LIBRARIES})
set(HAVE_XKBCOMMON ON)
else()
message(STATUS "libxkbcommon not found, key codes in key events may be incorrect")
endif()
endif()
endif(wxUSE_GUI)
# test if precompiled headers are supported using the cotire test project
if(DEFINED wxBUILD_PRECOMP_PREV AND NOT wxBUILD_PRECOMP STREQUAL wxBUILD_PRECOMP_PREV)

View file

@ -0,0 +1,28 @@
# FindXKBCommon
find_package(PkgConfig)
pkg_check_modules(PC_XKBCOMMON QUIET xkbcommon)
find_path(XKBCOMMON_INCLUDE_DIRS
NAMES xkbcommon.h
HINTS ${PC_XKBCOMMON_INCLUDEDIR}
${PC_XKBCOMMON_INCLUDE_DIRS}
PATH_SUFFIXES xkbcommon
)
find_library(XKBCOMMON_LIBRARIES
NAMES xkbcommon
HINTS ${PC_XKBCOMMON_LIBDIR}
${PC_XKBCOMMON_LIBRARY_DIRS}
)
set(XKBCOMMON_VERSION ${PC_XKBCOMMON_VERSION})
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(XKBCommon REQUIRED_VARS XKBCOMMON_INCLUDE_DIRS XKBCOMMON_LIBRARIES
VERSION_VAR XKBCOMMON_VERSION)
mark_as_advanced(
XKBCOMMON_INCLUDE_DIRS
XKBCOMMON_LIBRARIES
)

View file

@ -1110,6 +1110,9 @@
/* Define if setpriority() is available. */
#cmakedefine HAVE_SETPRIORITY 1
/* Define if xkbcommon is available */
#cmakedefine HAVE_XKBCOMMON 1
/* Define if xlocale.h header file exists. */
#cmakedefine HAVE_XLOCALE_H 1