Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(CMakeLists): add options to select backend #52

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 35 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,48 @@
cmake_minimum_required(VERSION 3.10)
project(lvgl)
project(lvgl LANGUAGES C)

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(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)

add_subdirectory(lvgl)
target_include_directories(lvgl PUBLIC ${PROJECT_SOURCE_DIR})

add_executable(main main.c mouse_cursor_icon.c)

include(${CMAKE_CURRENT_LIST_DIR}/lvgl/tests/FindLibDRM.cmake)
include_directories(${Libdrm_INCLUDE_DIRS})

find_package(SDL2)
find_package(SDL2_image)
include_directories(${SDL2_INCLUDE_DIRS} ${SDL2_IMAGE_INCLUDE_DIRS})
option(USE_FBDEV "Use the framebuffer backend" ON)
option(USE_DRM "Use the DRM backend" OFF)
option(USE_SDL2 "Use the SDL2 backend" OFF)
option(USE_THOR "Link with the ThorVG vector grapics library" OFF)

if(USE_FBDEV)
add_compile_definitions(LV_USE_LINUX_FBDEV=1)
elseif(USE_DRM)
add_compile_definitions(LV_USE_LINUX_FBDEV=0)
add_compile_definitions(LV_USE_LINUX_DRM=1)
include(${CMAKE_CURRENT_LIST_DIR}/lvgl/tests/FindLibDRM.cmake)
include_directories(${Libdrm_INCLUDE_DIRS})
target_link_libraries(main ${Libdrm_LIBRARIES})
elseif(USE_SDL2)
add_compile_definitions(LV_USE_LINUX_FBDEV=0)
add_compile_definitions(LV_USE_SDL=1)
find_package(SDL2)
target_link_libraries(main ${SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES})
include_directories(${SDL2_INCLUDE_DIRS} ${SDL2_IMAGE_INCLUDE_DIRS})
endif()

if(USE_THOR)
enable_language(CXX)
target_link_libraries(main lvgl::thorvg)
add_compile_definitions(LV_USE_THORVG_INTERNAL=1)
else()
add_compile_definitions(LV_USE_THORVG_INTERNAL=0)
endif()

add_subdirectory(lvgl EXCLUDE_FROM_ALL)
target_include_directories(lvgl PUBLIC ${PROJECT_SOURCE_DIR})

target_link_libraries(main lvgl lvgl::examples lvgl::demos lvgl::thorvg ${SDL2_LIBRARIES} ${SDL2_IMAGE_LIBRARIES} ${Libdrm_LIBRARIES} m pthread)
target_link_libraries(main lvgl lvgl::examples lvgl::demos m pthread)
add_custom_target (run COMMAND ${EXECUTABLE_OUTPUT_PATH}/main DEPENDS main)

set_target_properties(main PROPERTIES OUTPUT_NAME lv_port_linux)
install(TARGETS main DESTINATION local/bin)
10 changes: 9 additions & 1 deletion lv_conf.h
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,9 @@
#define LV_USE_VECTOR_GRAPHIC 1

/* Enable ThorVG (vector graphics library) from the src/libs folder */
#define LV_USE_THORVG_INTERNAL 1
#ifndef LV_USE_THORVG_INTERNAL
#define LV_USE_THORVG_INTERNAL 0
#endif // LV_USE_THORVG_INTERNAL

/* Enable ThorVG by assuming that its installed and linked to the project */
#define LV_USE_THORVG_EXTERNAL 0
Expand Down Expand Up @@ -829,7 +831,9 @@
*==================*/

/*Use SDL to open window on PC and handle mouse and keyboard*/
#ifndef LV_USE_SDL
#define LV_USE_SDL 0
#endif // LV_USE_SDL
#if LV_USE_SDL
#define LV_SDL_INCLUDE_PATH <SDL2/SDL.h>
#define LV_SDL_RENDER_MODE LV_DISPLAY_RENDER_MODE_DIRECT /*LV_DISPLAY_RENDER_MODE_DIRECT is recommended for best performance*/
Expand All @@ -850,7 +854,9 @@
#endif

/*Driver for /dev/fb*/
#ifndef LV_USE_LINUX_FBDEV
#define LV_USE_LINUX_FBDEV 1
#endif // LV_USE_LINUX_FBDEV
#if LV_USE_LINUX_FBDEV
#define LV_LINUX_FBDEV_BSD 0
#define LV_LINUX_FBDEV_RENDER_MODE LV_DISPLAY_RENDER_MODE_DIRECT
Expand Down Expand Up @@ -880,7 +886,9 @@
#endif

/*Driver for /dev/dri/card*/
#ifndef LV_USE_LINUX_DRM
#define LV_USE_LINUX_DRM 0
#endif // LV_USE_LINUX_DRM

/*Interface for TFT_eSPI*/
#define LV_USE_TFT_ESPI 0
Expand Down