4 # Finds the X11 library
6 # This will define the following targets:
8 # ${APP_NAME_LC}::X - The X11 library
9 # ${APP_NAME_LC}::Xext - The X11 extension library
11 if(NOT TARGET ${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME})
12 find_package(PkgConfig)
14 pkg_check_modules(PC_X x11 xext QUIET)
17 find_path(X_INCLUDE_DIR NAMES X11/Xlib.h
18 HINTS ${PC_X_x11_INCLUDEDIR})
19 find_library(X_LIBRARY NAMES X11
20 HINTS ${PC_X_x11_LIBDIR})
21 find_library(X_EXT_LIBRARY NAMES Xext
22 HINTS ${PC_X_xext_LIBDIR})
24 set(X_VERSION ${PC_X_x11_VERSION})
26 include(FindPackageHandleStandardArgs)
27 find_package_handle_standard_args(X
28 REQUIRED_VARS X_LIBRARY X_EXT_LIBRARY X_INCLUDE_DIR
29 VERSION_VAR X_VERSION)
32 add_library(${APP_NAME_LC}::Xext UNKNOWN IMPORTED)
33 set_target_properties(${APP_NAME_LC}::Xext PROPERTIES
34 IMPORTED_LOCATION "${X_EXT_LIBRARY}"
35 INTERFACE_INCLUDE_DIRECTORIES "${X_INCLUDE_DIR}")
36 add_library(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} UNKNOWN IMPORTED)
37 set_target_properties(${APP_NAME_LC}::${CMAKE_FIND_PACKAGE_NAME} PROPERTIES
38 IMPORTED_LOCATION "${X_LIBRARY}"
39 INTERFACE_INCLUDE_DIRECTORIES "${X_INCLUDE_DIR}"
40 INTERFACE_COMPILE_DEFINITIONS HAVE_X11
41 INTERFACE_LINK_LIBRARIES ${APP_NAME_LC}::Xext)