From f0f9028d7f6aabf1f5d4575dfe16057a2c07a7b4 Mon Sep 17 00:00:00 2001 From: peak3d Date: Sun, 22 Jul 2018 21:15:42 +0200 Subject: Rework FindXkbcommon.cmake --- cmake/modules/FindXkbcommon.cmake | 37 ++++++++++++++++++++++++++++--------- 1 file changed, 28 insertions(+), 9 deletions(-) (limited to 'cmake') diff --git a/cmake/modules/FindXkbcommon.cmake b/cmake/modules/FindXkbcommon.cmake index 1bb2543ef3..40cbb314d7 100644 --- a/cmake/modules/FindXkbcommon.cmake +++ b/cmake/modules/FindXkbcommon.cmake @@ -7,15 +7,34 @@ # XKBCOMMON_FOUND - the system has libxkbcommon # XKBCOMMON_INCLUDE_DIRS - the libxkbcommon include directory # XKBCOMMON_LIBRARIES - the libxkbcommon libraries -# XKBCOMMON_DEFINITIONS - the libxkbcommon definitions -pkg_check_modules (XKBCOMMON xkbcommon) +if(PKG_CONFIG_FOUND) + pkg_check_modules(PC_XKBCOMMON xkbcommon QUIET) +endif() -include (FindPackageHandleStandardArgs) -find_package_handle_standard_args (Xkbcommon - REQUIRED_VARS - XKBCOMMON_FOUND) -set(XKBCOMMON_DEFINITIONS -DHAVE_XKBCOMMON=1) -set(XKBCOMMON_LIBRARIES ${XKBCOMMON_LDFLAGS}) -set(XKBCOMMON_INCLUDE_DIRS ${XKBCOMMON_INCLUDEDIR}) +find_path(XKBCOMMON_INCLUDE_DIR NAMES xkbcommon/xkbcommon.h + PATHS ${PC_XKBCOMMON_INCLUDEDIR}) +find_library(XKBCOMMON_LIBRARY NAMES xkbcommon + PATHS ${PC_XKBCOMMON_LIBDIR}) + +set(XKBCOMMON_VERSION ${PC_XKBCOMMON_VERSION}) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(Xkbcommon + REQUIRED_VARS XKBCOMMON_LIBRARY XKBCOMMON_INCLUDE_DIR + VERSION_VAR XKBCOMMON_VERSION) + +if(XKBCOMMON_FOUND) + set(XKBCOMMON_INCLUDE_DIRS ${XKBCOMMON_INCLUDE_DIR}) + set(XKBCOMMON_LIBRARIES ${XKBCOMMON_LIBRARY}) + + if(NOT TARGET XKBCOMMON::XKBCOMMON) + add_library(XKBCOMMON::XKBCOMMON UNKNOWN IMPORTED) + set_target_properties(XKBCOMMON::XKBCOMMON PROPERTIES + IMPORTED_LOCATION "${XKBCOMMON_LIBRARY}" + INTERFACE_INCLUDE_DIRECTORIES "${XKBCOMMON_INCLUDE_DIR}") + endif() +endif() + +mark_as_advanced(XKBCOMMON_INCLUDE_DIR XKBCOMMON_LIBRARY) -- cgit v1.2.3