-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
86 lines (66 loc) · 2.67 KB
/
CMakeLists.txt
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
cmake_minimum_required(VERSION 3.18.4)
project(termux-gfx-wrapper)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
option(X11_PLATFORM "Provide X11 drawing though libxcb" ON)
option(WAYLAND_PLATFORM "Provide Wayland drawing though libwayland and the hardware buffer exchange protocol if supported" OFF)
set(EGL_DEFAULT_DISPLAY_PLAYFORM "X11" CACHE STRING "The default EGLDisplay platform: NATIVE for pass-through of Android libEGL, WAYLAND or X11.")
# Termux dependency packages: libglvnd, libx11 libxcb
# Termux build dependencies: vulkan-headers, xorgproto, libglvnd-dev, mesa-dev, libx11 libxcb
# without wayland
set(sources-egl
egl
dispatch
android-display
x11-display
gles
surface
)
list(TRANSFORM sources-egl PREPEND src/egl/)
list(TRANSFORM sources-egl APPEND .cpp)
set(sources-vulkan
vulkan
)
list(TRANSFORM sources-vulkan PREPEND src/vulkan/)
list(TRANSFORM sources-vulkan APPEND .cpp)
add_compile_options(-Wall -Wpedantic)
add_library(vulkan-android SHARED ${sources-vulkan} wayland/hwbuf.c src/common/android.cpp)
target_link_libraries(vulkan-android dl)
if(X11_PLATFORM)
target_link_libraries(vulkan-android dl xcb xcb-shm xcb-sync xcb-present X11 X11-xcb)
target_compile_definitions(vulkan-android PUBLIC X11_PLATFORM)
endif()
if(WAYLAND_PLATFORM)
target_link_libraries(vulkan-android dl wayland)
target_compile_definitions(vulkan-android PUBLIC WAYLAND_PLATFORM)
endif()
if(ANDROID EQUAL 1)
target_link_libraries(vulkan-android android)
endif()
target_include_directories(vulkan-android PRIVATE wayland src/common)
add_library(egl-android SHARED
${sources-egl}
src/common/android.cpp
#src/common/format.cpp
)
target_link_libraries(egl-android dl)
if(X11_PLATFORM)
target_link_libraries(egl-android dl xcb xcb-shm xcb-sync xcb-present X11 X11-xcb)
target_compile_definitions(egl-android PUBLIC X11_PLATFORM)
endif()
if(WAYLAND_PLATFORM)
target_link_libraries(egl-android dl wayland)
target_compile_definitions(egl-android PUBLIC WAYLAND_PLATFORM)
endif()
if(ANDROID EQUAL 1)
target_link_libraries(egl-android android)
endif()
target_compile_definitions(egl-android PRIVATE DEFAULT_DISPLAY_PLAYFORM=${EGL_DEFAULT_DISPLAY_PLAYFORM})
target_include_directories(egl-android PRIVATE wayland src/common)
install(TARGETS egl-android LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
install(FILES 10_android_wrapper.json DESTINATION ${CMAKE_INSTALL_PREFIX}/share/glvnd/egl_vendor.d/)
add_custom_target(uninstall)
add_custom_command(TARGET uninstall POST_BUILD COMMAND rm ARGS -v -f
${CMAKE_INSTALL_PREFIX}/share/glvnd/egl_vendor.d/10_android_wrapper.json
${CMAKE_INSTALL_PREFIX}/lib/libegl-android.so
)