fix: can compile in msvc
This commit is contained in:
parent
9337906544
commit
d721bed6aa
@ -91,11 +91,11 @@ endif()
|
||||
|
||||
# Define LVGL configuration as a simple include
|
||||
target_compile_definitions(main PRIVATE LV_CONF_INCLUDE_SIMPLE)
|
||||
target_link_libraries(main lvgl lvgl::examples lvgl::demos lvgl::thorvg ${SDL2_LIBRARIES} m pthread)
|
||||
|
||||
# Platform configuration
|
||||
if(CMAKE_HOST_WIN32)
|
||||
target_link_libraries(main -mconsole)
|
||||
if(MSVC)
|
||||
target_link_libraries(main lvgl lvgl::examples lvgl::demos lvgl::thorvg ${SDL2_LIBRARIES})
|
||||
else()
|
||||
target_link_libraries(main lvgl lvgl::examples lvgl::demos lvgl::thorvg ${SDL2_LIBRARIES} m pthread)
|
||||
endif()
|
||||
|
||||
# Only link freertos_config if the FreeRTOS directory exists
|
||||
@ -140,6 +140,16 @@ if(LV_USE_FREETYPE)
|
||||
target_link_libraries(main ${FREETYPE_LIBRARIES})
|
||||
endif()
|
||||
|
||||
# On Windows, GUI applications do not show a console by default,
|
||||
# which hides log output. This ensures a console is available for logging.
|
||||
if (WIN32)
|
||||
if (MSVC)
|
||||
target_link_options(main PRIVATE "/SUBSYSTEM:CONSOLE")
|
||||
else()
|
||||
target_link_options(main PRIVATE "-mconsole")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Apply additional compile options if the build type is Debug
|
||||
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
message(STATUS "Debug mode enabled")
|
||||
@ -181,4 +191,4 @@ if (ASAN)
|
||||
else()
|
||||
message(STATUS "AddressSanitizer disabled")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
@ -7,11 +7,18 @@
|
||||
/*********************
|
||||
* INCLUDES
|
||||
*********************/
|
||||
#define _DEFAULT_SOURCE /* needed for usleep() */
|
||||
#ifndef _DEFAULT_SOURCE
|
||||
#define _DEFAULT_SOURCE /* needed for usleep() */
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#ifdef _MSC_VER
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <pthread.h>
|
||||
#endif
|
||||
#include "lvgl/lvgl.h"
|
||||
#include "lvgl/examples/lv_examples.h"
|
||||
#include "lvgl/demos/lv_demos.h"
|
||||
@ -88,7 +95,11 @@ int main(int argc, char **argv)
|
||||
/* Periodically call the lv_task handler.
|
||||
* It could be done in a timer interrupt or an OS task too.*/
|
||||
lv_timer_handler();
|
||||
#ifdef _MSC_VER
|
||||
Sleep(5);
|
||||
#else
|
||||
usleep(5 * 1000);
|
||||
#endif
|
||||
}
|
||||
|
||||
#elif LV_USE_OS == LV_OS_FREERTOS
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user