@@ -22,38 +22,19 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
2222set (EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR} /bin)
2323set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wpedantic" )
2424
25- option (CONFIG "Config to use leave empty for `lv_conf.defaults`" "default " )
25+ set (CONFIG "default" CACHE STRING " Config name to use. Leave empty for default `lv_conf.defaults`" )
2626
2727set (LV_CONF_DEFAULTS_PATH "${CMAKE_SOURCE_DIR} /lv_conf.defaults" )
28- set (LV_CONF_DEFAULTS_OLD_PATH "${CMAKE_SOURCE_DIR} /lv_conf.defaults.old" )
2928
30- # If CONFIG is not default, copy the selected config to lv_conf.defaults
29+ # If CONFIG is not default, update LV_CONF_DEFAULTS_PATH to the selected config
3130if (NOT CONFIG STREQUAL "default" )
32- set (CONFIG_FILE "${CMAKE_SOURCE_DIR} /configs/${CONFIG} .defaults" )
33-
34- # Verify the config file exists
35- if (NOT EXISTS "${CONFIG_FILE} " )
36- message (FATAL_ERROR "Config file not found: ${CONFIG_FILE} " )
37- endif ()
38-
39- # Backup the current lv_conf.defaults to lv_conf.defaults.old
40- if (EXISTS "${LV_CONF_DEFAULTS_PATH} " )
41- file (RENAME "${LV_CONF_DEFAULTS_PATH} " "${LV_CONF_DEFAULTS_OLD_PATH} " )
42- message (STATUS "Backed up lv_conf.defaults to lv_conf.defaults.old" )
43- endif ()
44-
45- # Copy the config file to lv_conf.defaults
46- configure_file ("${CONFIG_FILE} " "${LV_CONF_DEFAULTS_PATH} " COPYONLY )
47- message (STATUS "Copied configs/${CONFIG} .defaults to ${LV_CONF_DEFAULTS_PATH} " )
48- message (STATUS "Using config: configs/${CONFIG} .defaults" )
49- else ()
50- if (NOT EXISTS "${LV_CONF_DEFAULTS_PATH} " )
51- message (FATAL_ERROR "Config file not found: ${LV_CONF_DEFAULTS_PATH} " )
52- endif ()
53- message (STATUS "Using default lv_conf.defaults" )
54- message (STATUS "Using config: ${LV_CONF_DEFAULTS_PATH} " )
31+ set (LV_CONF_DEFAULTS_PATH "${CMAKE_SOURCE_DIR} /configs/${CONFIG} .defaults" )
5532endif ()
5633
34+ if (NOT EXISTS "${LV_CONF_DEFAULTS_PATH} " )
35+ message (FATAL_ERROR "Config file not found: ${LV_CONF_DEFAULTS_PATH} " )
36+ endif ()
37+ message (STATUS "Using config: ${LV_CONF_DEFAULTS_PATH} " )
5738
5839set (LV_BUILD_SET_CONFIG_OPTS ON CACHE BOOL
5940 "create CMAKE variables from lv_conf_internal.h" FORCE)
@@ -65,12 +46,9 @@ set(LV_BUILD_CONF_PATH
6546set (LVGL_TEMPLATE_PATH "${CMAKE_SOURCE_DIR} /lvgl/lv_conf_template.h" )
6647set (GENERATE_SCRIPT_PATH "${CMAKE_SOURCE_DIR} /lvgl/scripts/generate_lv_conf.py" )
6748
68- configure_file (${LVGL_TEMPLATE_PATH} ${CMAKE_BINARY_DIR} /lv_conf_template.h
69- COPYONLY )
70- configure_file (${LV_CONF_DEFAULTS_PATH} ${CMAKE_BINARY_DIR} /lv_conf.defaults
71- COPYONLY )
72- configure_file (${GENERATE_SCRIPT_PATH} ${CMAKE_BINARY_DIR} /generate_lv_conf.py
73- COPYONLY )
49+ set_property (DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LVGL_TEMPLATE_PATH} )
50+ set_property (DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${LV_CONF_DEFAULTS_PATH} )
51+ set_property (DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${GENERATE_SCRIPT_PATH} )
7452
7553execute_process (
7654 COMMAND
0 commit comments