Skip to content
Permalink
Browse files

cmake: Use an imported library for XkbCommon

This modifies FindLibxkbcommon.cmake so it will create the
XkbCommon::libxkbcommon imported library target, and also
makes use of it in CMakeLists.txt
  • Loading branch information...
aperezdc committed Aug 15, 2019
1 parent c1975f4 commit dcf990e8cf77c89b6576c4d4ba2cbd7818dd5f44
Showing with 34 additions and 8 deletions.
  1. +1 −2 CMakeLists.txt
  2. +33 −6 cmake/FindLibxkbcommon.cmake
@@ -55,12 +55,11 @@ set(WPE_INCLUDE_DIRECTORIES
"include"
"src"
${DERIVED_SOURCES_DIR}
${LIBXKBCOMMON_INCLUDE_DIRS}
)

set(WPE_LIBRARIES
dl
${LIBXKBCOMMON_LIBRARIES}
XkbCommon::libxkbcommon
)

set(WPE_SOURCES
@@ -1,11 +1,12 @@
# - Try to find libxkbcommon.
# Once done, this will define
#
# XkbCommon::libxkbcommon
# LIBXKBCOMMON_FOUND - system has libxkbcommon.
# LIBXKBCOMMON_INCLUDE_DIRS - the libxkbcommon include directories
# LIBXKBCOMMON_LIBRARIES - link these to use libxkbcommon.
# LIBXKBCOMMON_INCLUDE_DIR - directory containing the xkbcommon include directories
# LIBXKBCOMMON_LIBRARY - link these to use libxkbcommon.
#
# Copyright (C) 2014 Igalia S.L.
# Copyright (C) 2014, 2019 Igalia S.L.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
@@ -29,8 +30,34 @@
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

find_package(PkgConfig)
pkg_check_modules(LIBXKBCOMMON xkbcommon)
pkg_check_modules(LIBXKBCOMMON IMPORTED_TARGET xkbcommon)

find_path(LIBXKBCOMMON_INCLUDE_DIR
NAMES xkbcommon/xkbcommon.h
HINTS ${LIBXKBCOMMON_INCLUDEDIR} ${LIBXKBCOMMON_INCLUDE_DIRS}
)
find_library(LIBXKBCOMMON_LIBRARY
NAMES xkbcommon
HINTS ${LIBXKBCOMMON_LIBDIR} ${LIBXKBCOMMON_LIBRARY_DIRS}
)

# If pkg-config has not found the module but find_path+find_library have
# figured out where the header and library are, create the
# XkbCommon::Libxkbcommon imported target anyway with the found paths.
#
if (LIBXKBCOMMON_LIBRARY AND NOT TARGET XkbCommon::libxkbcommon)
add_library(XkbCommon::libxkbcommon INTERFACE IMPORTED)
if (TARGET PkgConfig::LIBXKBCOMMON)
target_link_libraries(XkbCommon::libxkbcommon INTERFACE PkgConfig::LIBXKBCOMMON)
else ()
set_property(TARGET XkbCommon::libxkbcommon PROPERTY
INTERFACE_LINK_LIBRARIES ${LIBXKBCOMMON_LIBRARY})
set_property(TARGET XkbCommon::libxkbcommon PROPERTY
INTERFACE_INCLUDE_DIRECTORIES ${LIBXKBCOMMON_INCLUDE_DIR})
endif ()
endif ()


include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Libxkbcommon REQUIRED_VARS LIBXKBCOMMON_FOUND
FOUND_VAR LIBXKBCOMMON_FOUND)
find_package_handle_standard_args(LIBXKBCOMMON REQUIRED_VARS
LIBXKBCOMMON_LIBRARY LIBXKBCOMMON_INCLUDE_DIR)

0 comments on commit dcf990e

Please sign in to comment.
You can’t perform that action at this time.