Cmake does not have access to kconfig variables before register
Posted: Sun Nov 19, 2023 8:27 pm
I am trying to do conditional compilation for my project based on menuconfig selections.
I have a custom Kconfig.projbuild and setting options via menuconfig. In my SDKConfig I see
In my cmake file I then have
This fails because it claims both of those options are not set, and thus my fatal message gets called.
However, putting this block after the component register "works". It appears that we do not have access to the kconfig variables until *after* the `idf_component_register()` call. This seems to be in direct contradiction to the build system documentation.
Am I doing something wrong? Is there a way to add sources after a `idf_component_register()` call?
I have a custom Kconfig.projbuild and setting options via menuconfig. In my SDKConfig I see
Code: Select all
CONFIG_MICROGPU_DATABUS_SPI=y
Code: Select all
set(SOURCES
displays/i80_display.c
main.c
${MICROGPU_COMMON_SOURCES}
../../microgpu-common/color_rgb565.c
)
if (CONFIG_MICROGPU_DATABUS_SPI)
list(APPEND SOURCES "spi_databus.c")
elseif (CONFIG_MICROGPU_DATABUS_BENCHMARK)
list(APPEND SOURCES "benchmark_databus.c")
else ()
message(FATAL_ERROR "No databus type set")
endif ()
idf_component_register(SRCS ${SOURCES}
INCLUDE_DIRS "." "../../")
However, putting this block after the component register "works". It appears that we do not have access to the kconfig variables until *after* the `idf_component_register()` call. This seems to be in direct contradiction to the build system documentation.
Am I doing something wrong? Is there a way to add sources after a `idf_component_register()` call?