1
1
cmake_minimum_required (VERSION 3.10)
2
2
project (lvgl)
3
3
4
- # Please set the wanted option to 'ON'. By default, FBDEV is used
5
- # be sure to also enable the selected driver in lv_conf.h
4
+ foreach (BACKEND_NAME "SDL" "LINUX_DRM" "LINUX_FBDEV" "X11" "WAYLAND" )
6
5
7
- option (LV_USE_WAYLAND "Use the wayland client backend" OFF )
8
- option (LV_USE_SDL "Use the SDL backend" OFF )
9
- option (LV_USE_DRM "Use the libdrm backend" OFF )
10
- option (DEBUG_MODE "Disable optimizations and enable debugging" OFF )
6
+ execute_process (COMMAND "scripts/backend_conf.sh" ${BACKEND_NAME} OUTPUT_VARIABLE IS_BACKEND_ENABLED)
7
+ set ("LV_USE_${BACKEND_NAME} " ${IS_BACKEND_ENABLED} )
8
+
9
+ endforeach ()
10
+
11
+ # Uncomment if the program needs debugging
12
+ #set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -ggdb")
11
13
12
14
set (CMAKE_C_STANDARD 99) # LVGL officially supports C99 and above
13
15
set (CMAKE_CXX_STANDARD 17) #C17
14
16
set (CMAKE_CXX_STANDARD_REQUIRED ON )
15
-
16
- if (DEBUG_MODE)
17
-
18
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0 -ggdb" )
19
-
20
- endif (DEBUG_MODE)
21
-
22
17
set (EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR} /bin)
23
18
24
19
add_subdirectory (lvgl)
25
20
target_include_directories (lvgl PUBLIC ${PROJECT_SOURCE_DIR} )
26
21
22
+
27
23
if (LV_USE_DRM)
28
24
29
25
include (${CMAKE_CURRENT_LIST_DIR} /lvgl/tests/FindLibDRM.cmake)
@@ -47,43 +43,12 @@ elseif (LV_USE_WAYLAND)
47
43
pkg_check_modules(xkbcommon REQUIRED xkbcommon)
48
44
49
45
# Wayland protocols
50
- set (WAYLAND_PROTOCOLS_DIR "${CMAKE_CURRENT_SOURCE_DIR} /protocols" )
51
- find_program (WAYLAND_SCANNER_EXECUTABLE NAMES wayland-scanner)
52
46
pkg_check_modules(WAYLAND_PROTOCOLS REQUIRED wayland-protocols>=1.25)
53
47
pkg_get_variable(WAYLAND_PROTOCOLS_BASE wayland-protocols pkgdatadir)
54
48
55
- macro (wayland_generate protocol_xml_file output_dir target )
56
- get_filename_component (output_file_base ${protocol_xml_file} NAME_WE )
57
- set (output_file_noext "${output_dir} /wayland-${output_file_base} -client-protocol" )
58
- add_custom_command (OUTPUT "${output_file_noext} .h"
59
- COMMAND "${WAYLAND_SCANNER_EXECUTABLE} " client-header "${protocol_xml_file} " "${output_file_noext} .h"
60
- DEPENDS "${protocol_xml_file} "
61
- VERBATIM )
62
-
63
- add_custom_command (OUTPUT "${output_file_noext} .c"
64
- COMMAND "${WAYLAND_SCANNER_EXECUTABLE} " private -code "${protocol_xml_file} " "${output_file_noext} .c"
65
- DEPENDS "${protocol_xml_file} "
66
- VERBATIM )
67
-
68
- if (NOT EXISTS ${protocol_xml_file} )
69
- message ("Protocol XML file not found: " ${protocol_xml_file} )
70
- else ()
71
- set_property (TARGET ${target} APPEND PROPERTY SOURCES "${output_file_noext} .h" "${output_file_noext} .c" )
72
- endif ()
73
-
74
- endmacro ()
75
-
76
- file (MAKE_DIRECTORY ${WAYLAND_PROTOCOLS_DIR} )
77
-
78
- add_custom_target (generate_protocols ALL )
79
-
80
- wayland_generate("${WAYLAND_PROTOCOLS_BASE} /stable/xdg-shell/xdg-shell.xml" ${WAYLAND_PROTOCOLS_DIR} generate_protocols)
81
-
82
- target_include_directories (lvgl PUBLIC ${PROJECT_SOURCE_DIR} ${WAYLAND_PROTOCOLS_DIR} )
83
-
84
- # TODO Add option to still be able to build wl_shell
85
- add_executable (lvglsim main.c ${WAYLAND_PROTOCOLS_DIR} /wayland-xdg-shell-client-protocol.c mouse_cursor_icon.c)
86
-
49
+ execute_process (COMMAND "scripts/gen_wl_protocols.sh" OUTPUT_VARIABLE WAYLAND_PROTOCOLS_SRC)
50
+ target_include_directories (lvgl PUBLIC ${PROJECT_SOURCE_DIR} "wl_protocols" )
51
+ add_executable (lvglsim main.c ${WAYLAND_PROTOCOLS_SRC} mouse_cursor_icon.c)
87
52
target_compile_definitions (lvglsim PRIVATE LV_CONF_INCLUDE_SIMPLE)
88
53
target_link_libraries (lvglsim lvgl lvgl::examples lvgl::demos lvgl::thorvg m wayland-client xkbcommon wayland-cursor)
89
54
0 commit comments