cmake_minimum_required(VERSION 3.27)
project(HW_Lib CXX C)

set(CMAKE_C_STANDARD 23)
SET(CMAKE_CXX_FLAGS "-O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++23")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")

file(GLOB DEMO_SUBDIRS "demo/*/")
foreach (DEMO_SUBDIR ${DEMO_SUBDIRS})
    include_directories(${DEMO_SUBDIR})
endforeach ()

#include_directories("demo/tft")

file(GLOB SIM_SUBDIRS "sim/*")
foreach (SIM_SUBDIR ${SIM_SUBDIRS})
    include_directories(${SIM_SUBDIR})
endforeach ()

set(LVGL_ROOT_DIR lvgl)

include(lvgl/env_support/cmake/custom.cmake)

include_directories(easyx/include)
link_directories(easyx/lib64)


file(GLOB_RECURSE SOURCES "demo/*/*.*" "sim/*/*.*")
#message(${SOURCES})
add_subdirectory(SDL3 EXCLUDE_FROM_ALL)
link_libraries(SDL3::SDL3)

link_libraries(libeasyx.a libgdi32.a libole32.a)

add_executable(HW_Lib main.c ${SOURCES})

#导入库
add_subdirectory(lib)

target_link_libraries(HW_Lib HW_LIB_List HW_LIB_Task HW_LIB_Printf HW_LIB_Utils HW_LIB_Iic
        HW_LIB_Spi HW_LIB_Key HW_LIB_Oled HW_LIB_Font HW_LIB_Tft lvgl::lvgl HW_LIB_Lui
)

add_custom_command(TARGET HW_Lib POST_BUILD
        COMMAND ${CMAKE_COMMAND} -E copy_if_different
        $<TARGET_FILE:SDL3::SDL3>
        $<TARGET_FILE_DIR:HW_Lib>
)
