I am trying to configure to my build process for ESP-IDF to slim down the build. What I have tried : I've added custom entries to the menuconfig:
menu "Install Sensor Device Drivers"
config LISD3H_CHECK
bool "Include LISD3H Accel Sensor"
default "n"
help
Install required drivers for LISD3H and check if device present
config SHT30_CHECK
bool "Include SHT30 Temp & Hum Sensor"
default "n"
help
Install required drivers for SHT30 and check if device present
endmenu
and tried using these to reduce unnecessary components getting compiled into the project. The config variables are correctly created and accessible within the source code. Now, I tried to control the build within the top level cmake file:
set(component_dirs "${CMAKE_CURRENT_LIST_DIR}/../components/comp1")
message(STATUS ${component_dirs})
message(STATUS ${CONFIG_LISD3H_CHECK})
message(STATUS ${CONFIG_SHT30_CHECK})
if(CONFIG_LISD3H_CHECK)
list(APPEND component_dirs "${CMAKE_CURRENT_LIST_DIR}/../components/comp2" )
message(STATUS ${component_dirs})
else()
message(STATUS "config not equal to whategver...")
endif()
However, the if statement is always false because cmake cannot see the CONFIG_XXXX variables from Kconfig (the messages are blank) Is there a way to access Kconfig varaibles inside cmake? Or a means of using menuconfig to control the build?
Basically, How do you exclude a component from the build? Should I just use C precompile directives inside the source code and ignore what gets compiled, since it will get optimised out of the final binary?
question from:
https://stackoverflow.com/questions/65894376/how-do-you-pass-menuconfig-variables-to-your-cmake-file-in-esp-idf 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…