-
Notifications
You must be signed in to change notification settings - Fork 0
/
SDL2-CMakeLists.txt
97 lines (82 loc) · 3.3 KB
/
SDL2-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
87
88
89
90
91
92
93
94
95
96
97
cmake_minimum_required(VERSION 3.25)
project(wallclock)
option(LV_USE_DRAW_SDL "Use SDL draw unit" OFF)
option(LV_USE_LIBPNG "Use libpng to decode PNG" OFF)
option(LV_USE_LIBJPEG_TURBO "Use libjpeg turbo to decode JPEG" OFF)
option(LV_USE_FFMPEG "Use libffmpeg to display video using lv_ffmpeg" OFF)
option(LV_USE_FREETYPE "Use freetype lib" OFF)
set(CMAKE_C_STANDARD 99)#C99 # lvgl officially support C99 and above
set(CMAKE_CXX_STANDARD 17)#C17
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(LVGL_TOP, managed_components/lvgl__lvgl)
set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
find_package(SDL2 REQUIRED SDL2)
add_compile_definitions($<$<BOOL:${LV_USE_DRAW_SDL}>:LV_USE_DRAW_SDL=1>)
add_compile_definitions($<$<BOOL:${LV_USE_LIBPNG}>:LV_USE_LIBPNG=1>)
add_compile_definitions($<$<BOOL:${LV_USE_LIBJPEG_TURBO}>:LV_USE_LIBJPEG_TURBO=1>)
add_compile_definitions($<$<BOOL:${LV_USE_FFMPEG}>:LV_USE_FFMPEG=1>)
add_subdirectory(${LVGL_TOP})
target_include_directories(lvgl PUBLIC ${PROJECT_SOURCE_DIR} ${SDL2_INCLUDE_DIRS})
add_executable(sdl-main sdl-main.c)
target_compile_definitions(sdl-main PRIVATE LV_CONF_INCLUDE_SIMPLE)
target_link_libraries(sdl-main lvgl ${SDL2_LIBRARIES} m pthread)
add_custom_target (run COMMAND ${EXECUTABLE_OUTPUT_PATH}/sdl-main DEPENDS sdl-main)
if(LV_USE_DRAW_SDL)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
# Need to install libsdl2-image-dev
# `sudo apt install libsdl2-image-dev`
# `brew install sdl2_image`
find_package(SDL2_image REQUIRED)
target_include_directories(lvgl PUBLIC ${SDL2_IMAGE_INCLUDE_DIRS})
target_link_libraries(sdl-main ${SDL2_IMAGE_LIBRARIES})
endif(LV_USE_DRAW_SDL)
if(LV_USE_LIBPNG)
find_package(PNG REQUIRED)
target_include_directories(lvgl PUBLIC ${PNG_INCLUDE_DIR})
target_link_libraries(sdl-main ${PNG_LIBRARY})
endif(LV_USE_LIBPNG)
if(LV_USE_LIBJPEG_TURBO)
# Need to install libjpeg-turbo8-dev
# `sudo apt install libjpeg-turbo8-dev`
# `brew install libjpeg-turbo`
find_package(JPEG REQUIRED)
target_include_directories(lvgl PUBLIC ${JPEG_INCLUDE_DIRS})
target_link_libraries(sdl-main ${JPEG_LIBRARIES})
endif(LV_USE_LIBJPEG_TURBO)
if(LV_USE_FFMPEG)
target_link_libraries(sdl-main avformat avcodec avutil swscale)
endif(LV_USE_FFMPEG)
if(LV_USE_FREETYPE)
find_package(Freetype REQUIRED)
target_link_libraries(sdl-main ${FREETYPE_LIBRARIES})
target_include_directories(lvgl PUBLIC ${FREETYPE_INCLUDE_DIRS})
endif(LV_USE_FREETYPE)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
target_compile_options(lvgl PRIVATE
-pedantic-errors
-Wall
-Wclobbered
-Wdeprecated
-Wdouble-promotion
-Wempty-body
-Wextra
-Wformat-security
-Wmaybe-uninitialized
# -Wmissing-prototypes
-Wpointer-arith
-Wmultichar
-Wno-pedantic # ignored for now, we convert functions to pointers for propertis table.
-Wreturn-type
-Wshadow
-Wshift-negative-value
-Wsizeof-pointer-memaccess
-Wtype-limits
-Wundef
-Wuninitialized
-Wunreachable-code
-Wfloat-conversion
-Wstrict-aliasing
)
target_compile_options(sdl-main PRIVATE -fsanitize=address,leak,undefined)
target_link_options(sdl-main PRIVATE -fsanitize=address,leak,undefined)
endif()