aboutsummaryrefslogtreecommitdiff
path: root/cmake/modules/FindXRandR.cmake
blob: 9feaedc6f754f5001b7e2211316fdbf093d8c7cf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#.rst:
# FindXRandR
# ----------
# Finds the XRandR library
#
# This will will define the following variables::
#
# XRANDR_FOUND - system has XRANDR
# XRANDR_INCLUDE_DIRS - the XRANDR include directory
# XRANDR_LIBRARIES - the XRANDR libraries
# XRANDR_DEFINITIONS - the XRANDR definitions
#
# and the following imported targets::
#
#   XRandR::XRandR   - The XRANDR library

if(PKG_CONFIG_FOUND)
  pkg_check_modules(PC_XRANDR xrandr QUIET)
endif()

find_path(XRANDR_INCLUDE_DIR NAMES X11/extensions/Xrandr.h
                             PATHS ${PC_XRANDR_INCLUDEDIR})
find_library(XRANDR_LIBRARY NAMES Xrandr
                            PATHS ${PC_XRANDR_LIBDIR})

set(XRANDR_VERSION ${PC_XRANDR_VERSION})

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(XRandR
                                  REQUIRED_VARS XRANDR_LIBRARY XRANDR_INCLUDE_DIR
                                  VERSION_VAR XRANDR_VERSION)

if(XRANDR_FOUND)
  set(XRANDR_LIBRARIES ${XRANDR_LIBRARY})
  set(XRANDR_INCLUDE_DIRS ${XRANDR_INCLUDE_DIR})
  set(XRANDR_DEFINITIONS -DHAVE_LIBXRANDR=1)

  if(NOT TARGET XRandR::XRandR)
    add_library(XRandR::XRandR UNKNOWN IMPORTED)
    set_target_properties(XRandR::XRandR PROPERTIES
                                         IMPORTED_LOCATION "${XRANDR_LIBRARY}"
                                         INTERFACE_INCLUDE_DIRECTORIES "${XRANDR_INCLUDE_DIR}"
                                         INTERFACE_COMPILE_DEFINITIONS HAVE_LIBXRANDR=1)
  endif()
endif()

mark_as_advanced(XRANDR_INCLUDE_DIR XRANDR_LIBRARY)