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

Add CMake file to build under Windows #1

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
6 changes: 5 additions & 1 deletion .vscode/c_cpp_properties.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@
},
"compilerPath": "/usr/bin/gcc",
"cStandard": "c11",
"cppStandard": "c++17"
"cppStandard": "c++17",
},
{
"name": "CMake",
"configurationProvider": "ms-vscode.cmake-tools"
}
],
"version": 4
Expand Down
29 changes: 29 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
cmake_minimum_required(VERSION 3.13)

project(lvgl_simulator)

set(LVGL_SIMULATOR_SDL_DIR "path-to-sdl-dir" CACHE STRING "Path to the SDL directory")
set(SDL_INCLUDE_DIR ${LVGL_SIMULATOR_SDL_DIR}/include)
set(SDL_LIB_DIR ${LVGL_SIMULATOR_SDL_DIR}/lib)
set(SDL_BIN_DIR ${LVGL_SIMULATOR_SDL_DIR}/bin)

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

add_subdirectory(lv_examples)
target_include_directories(lv_examples PUBLIC ${CMAKE_CURRENT_LIST_DIR})
target_link_libraries(lv_examples lvgl)

add_subdirectory(lv_drivers)
target_include_directories(lv_drivers PUBLIC ${CMAKE_CURRENT_LIST_DIR})
target_include_directories(lv_drivers PUBLIC ${SDL_INCLUDE_DIR} )

add_executable(lv_simulator
main/src/main.c
main/src/mouse_cursor_icon.c
)
target_link_libraries(lv_simulator lvgl lv_examples lv_drivers SDL2)
target_link_directories(lv_simulator PRIVATE ${SDL_LIB_DIR})

# Copy SDL2 DLL to the binary dir to avoid adding SDL dir to PATH.
add_custom_command(TARGET lv_simulator POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${SDL_BIN_DIR}/SDL2.dll ${CMAKE_BINARY_DIR}/. )
2 changes: 1 addition & 1 deletion lv_drivers
2 changes: 1 addition & 1 deletion lv_examples
2 changes: 1 addition & 1 deletion lvgl
Submodule lvgl updated 238 files
9 changes: 9 additions & 0 deletions main/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@
*********************/
#define _DEFAULT_SOURCE /* needed for usleep() */
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#define SDL_MAIN_HANDLED /*To fix SDL's "undefined reference to WinMain" \
issue*/
#include <SDL2/SDL.h>
#include "lvgl/lvgl.h"
#include "lv_drivers/display/monitor.h"
#include "lv_drivers/indev/mouse.h"
#include "lv_drivers/indev/keyboard.h"
#include "lv_examples/lv_examples.h"

/*********************
Expand Down Expand Up @@ -111,6 +113,13 @@ static void hal_init(void) {
lv_img_set_src(cursor_obj, &mouse_cursor_icon); /*Set the image source*/
lv_indev_set_cursor(mouse_indev, cursor_obj); /*Connect the image object to the driver*/

/* Add keyboard as input device */
lv_indev_drv_t kb_drv;
lv_indev_drv_init(&kb_drv);
kb_drv.type = LV_INDEV_TYPE_KEYPAD;
kb_drv.read_cb = keyboard_read;
lv_indev_t * kb_indev = lv_indev_drv_register(&kb_drv);

/* Tick init.
* You have to call 'lv_tick_inc()' in periodically to inform LittelvGL about
* how much time were elapsed Create an SDL thread to do this*/
Expand Down