summaryrefslogtreecommitdiff
path: root/Tests/FindX11/Test/CMakeLists.txt
blob: b2adfb2bcb7840416c3b965d34973015081dd187 (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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
cmake_minimum_required(VERSION 3.10)
project(TestFindX11 C)
include(CTest)

find_package(X11 REQUIRED)

function (test_x11_component have_var component)
  if (NOT X11_${component}_FOUND)
    message("Skipping ${component} because it was not found.")
    return ()
  endif ()

  add_executable(test_tgt_${component} main.c)
  target_link_libraries(test_tgt_${component} PRIVATE X11::${component})
  target_compile_definitions(test_tgt_${component} PRIVATE HAVE_X11_${component})
  add_test(NAME test_tgt_${component} COMMAND test_tgt_${component})

  # Add to the list of components to test for the parent.
  set(${have_var}
    ${${have_var}}
    HAVE_X11_${component}
    PARENT_SCOPE)
endfunction ()

set(x11_components)
test_x11_component(x11_components ICE)
test_x11_component(x11_components SM)
# Not a component; hack it up.
set(X11_X11_FOUND ${X11_FOUND})
test_x11_component(x11_components X11)
test_x11_component(x11_components Xau)
test_x11_component(x11_components xcb)
test_x11_component(x11_components X11_xcb)
test_x11_component(x11_components xcb_icccm)
test_x11_component(x11_components xcb_xkb)
test_x11_component(x11_components Xcomposite)
test_x11_component(x11_components Xdamage)
test_x11_component(x11_components Xdmcp)
test_x11_component(x11_components Xext)
test_x11_component(x11_components Xxf86misc)
test_x11_component(x11_components Xxf86vm)
test_x11_component(x11_components Xfixes)
# We ignore the Xft component because the variables do not provide the required
# dependency information (Freetype and Fontconfig).
test_x11_component(x11_components_ignore Xft)
test_x11_component(x11_components Xi)
test_x11_component(x11_components Xinerama)
test_x11_component(x11_components xkbcommon)
test_x11_component(x11_components xkbcommon_X11)
test_x11_component(x11_components Xkb)
test_x11_component(x11_components xkbfile)
test_x11_component(x11_components Xmu)
test_x11_component(x11_components Xpm)
test_x11_component(x11_components Xtst)
test_x11_component(x11_components Xrandr)
test_x11_component(x11_components Xrender)
test_x11_component(x11_components XRes)
test_x11_component(x11_components Xss)
test_x11_component(x11_components Xt)
test_x11_component(x11_components Xutil)
test_x11_component(x11_components Xv)

# The variables do not include dependency information. Just test "everything".
add_executable(test_var main.c)
target_include_directories(test_var PRIVATE ${X11_INCLUDE_DIRS})
target_link_libraries(test_var PRIVATE ${X11_LIBRARIES})
# Not included in X11_LIBRARIES.
foreach(lib
    Xau
    xcb
    X11_xcb
    xcb_icccm
    Xcomposite
    Xdamage
    Xdmcp
    Xxf86misc
    Xxf86vm
    Xfixes
    Xi
    Xinerama
    xkbcommon
    xkbcommon_X11
    Xkb
    xkbfile
    Xmu
    Xpm
    Xtst
    Xrandr
    Xrender
    XRes
    Xss
    Xt
    Xv
    )
  if (X11_${lib}_FOUND)
    target_link_libraries(test_var PRIVATE ${X11_${lib}_LIB})
  endif ()
endforeach()
target_compile_definitions(test_var PRIVATE ${x11_components})
add_test(NAME test_var COMMAND test_var)