summaryrefslogtreecommitdiff
path: root/cmake/config/ecore_x.cmake
blob: e95e6b2abac997bbdaa812ca0d76d6fd9f8eb5f5 (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
101
102
103
104
105
106
107
108
109
110
include(FindX11)

EFL_OPTION(XGESTURE "Whenever you want ecore_x to use gesture" OFF)
EFL_OPTION(XPRESENT "Whenever you want ecore_x to use xpresent" OFF)
EFL_OPTION(XINPUT2 "Whenever you want ecore_x to use xinput2" ON)
EFL_OPTION(XINPUT22 "Whenever you want ecore_x to use xinput22" OFF)

#the rest is just statically enabled
CHECK_APPEND_DEFINE(HAVE_ECORE_X_XLIB ON)
CHECK_APPEND_DEFINE(ECORE_XKB ON)
CHECK_APPEND_DEFINE(ECORE_XCOMPOSITE ON)
CHECK_APPEND_DEFINE(ECORE_XDAMAGE ON)
CHECK_APPEND_DEFINE(ECORE_XDPMS ON)
CHECK_APPEND_DEFINE(ECORE_XFIXES ON)
CHECK_APPEND_DEFINE(ECORE_XINERAMA ON)
CHECK_APPEND_DEFINE(ECORE_XRANDR ON)
CHECK_APPEND_DEFINE(ECORE_XSS ON)
CHECK_APPEND_DEFINE(ECORE_XTEST ON)

#FindX11 does not cover all parts we need so here are the 4 extensions we need to check

#copied from https://github.com/Kitware/CMake/blob/master/Modules/FindX11.cmake#L65
set(X11_INC_SEARCH_PATH
  /usr/pkg/xorg/include
  /usr/X11R6/include
  /usr/X11R7/include
  /usr/include/X11
  /usr/openwin/include
  /usr/openwin/share/include
  /opt/graphics/OpenGL/include
  /opt/X11/include
)

set(X11_LIB_SEARCH_PATH
  /usr/pkg/xorg/lib
  /usr/X11R6/lib
  /usr/X11R7/lib
  /usr/openwin/lib
  /opt/X11/lib
)

macro(find_lib_and_include name path lib)
  string(TOUPPER ${name} ecore_name)
  set(X11_${name}_FOUND OFF)
  find_library(X11_${name}_LIB ${lib} ${X11_LIB_SEARCH_PATH})
  find_path(X11_${name}_INCLUDE_PATH X11/extensions/${path} ${X11_INC_SEARCH_PATH})
  if (X11_${name}_LIB AND X11_${name}_INCLUDE_PATH)
    set(X11_${name}_FOUND ON)
  endif()

  CHECK_APPEND_DEFINE(ECORE_${ecore_name} ON)
endmacro()

if (${XGESTURE})
  find_lib_and_include(XGesture gesture.h Xgesture)
endif()

if(${XPRESENT})
  find_lib_and_include(Xpresent Xpresent.h Xpresent)
endif()

if(${XINPUT2})
  find_lib_and_include(Xi2 XInput2.h Xi)
endif()

if(${XINPUT22})
  find_lib_and_include(Xi2_2 Xpresent2.h Xi)
endif()

#build a list of all components we use
set(_X_EXTENSIONS
  X11
  X11_Xkb
  X11_Xcomposite
  X11_Xdamage
  X11_dpms
  X11_Xfixes
  X11_Xinerama
  X11_Xrandr
  X11_Xrender
  X11_XTest
  X11_Xscreensaver
)

if(${XGESTURE})
  list(APPEND _X_EXTENSIONS X11_Xgesture)
endif()

if(${XPRESENT})
  list(APPEND _X_EXTENSIONS X11_Xpresent)
endif()

if(${XINPUT2})
  list(APPEND _X_EXTENSIONS X11_Xi2)
endif()

if(${XINPUT22})
  list(APPEND _X_EXTENSIONS X11_Xi2_2)
endif()

foreach(ext ${_X_EXTENSIONS})
  if (NOT ${ext}_FOUND)
    message(FATAL_ERROR "Xserver extension ${ext} not found")
  endif()
  list(APPEND X_EXTENSIONS find-${ext})
endforeach()

configure_file(
  ${PROJECT_SOURCE_DIR}/src/lib/ecore_x/ecore_x_version.h.cmake
  ${PROJECT_BINARY_DIR}/src/lib/ecore_x/ecore_x_version.h)