esp-idf/components/nvs_flash/CMakeLists.txt
Frantisek Hrbata fbe8bf89ee fix: properly resolve component dependencies
There is currently a bug in the __build_resolve_and_add_req function in
tools/cmake/build.cmake where the check for registered component
requirements is incorrectly applied to the component itself rather than
its dependencies. This issue likely originated from a typo, using
component_target instead of _component_target. To prevent further
confusion, _component_target has been renamed to _req_target.

Fixing this revealed multiple incorrect dependencies for the Linux
target, which have now been resolved by explicitly specifying the
dependencies for the Linux target.

Closes https://github.com/espressif/esp-idf/issues/13447

Signed-off-by: Frantisek Hrbata <frantisek.hrbata@espressif.com>
2024-05-30 22:01:55 +08:00

44 lines
1.6 KiB
CMake

idf_build_get_property(target IDF_TARGET)
set(srcs "src/nvs_api.cpp"
"src/nvs_cxx_api.cpp"
"src/nvs_item_hash_list.cpp"
"src/nvs_page.cpp"
"src/nvs_pagemanager.cpp"
"src/nvs_storage.cpp"
"src/nvs_handle_simple.cpp"
"src/nvs_handle_locked.cpp"
"src/nvs_partition.cpp"
"src/nvs_partition_lookup.cpp"
"src/nvs_partition_manager.cpp"
"src/nvs_types.cpp"
"src/nvs_platform.cpp")
set(requires esp_partition)
if(${target} STREQUAL "linux")
set(priv_requires spi_flash)
else()
set(priv_requires spi_flash newlib)
endif()
idf_component_register(SRCS "${srcs}"
REQUIRES "${requires}"
PRIV_REQUIRES "${priv_requires}"
INCLUDE_DIRS "include"
"../spi_flash/include"
PRIV_INCLUDE_DIRS "private_include")
# If we use the linux target, we need to redirect the crc functions to the linux
if(${target} STREQUAL "linux")
if(CONFIG_NVS_ENCRYPTION)
# mbedtls isn't configured for building with linux or as mock target. It will draw in all kind of dependencies
message(FATAL_ERROR "NVS currently doesn't support encryption if built for Linux.")
endif()
target_compile_options(${COMPONENT_LIB} PUBLIC "-DLINUX_TARGET")
target_compile_options(${COMPONENT_LIB} PUBLIC --coverage)
target_link_libraries(${COMPONENT_LIB} PUBLIC --coverage)
else()
target_sources(${COMPONENT_LIB} PRIVATE "src/nvs_encrypted_partition.cpp")
target_link_libraries(${COMPONENT_LIB} PRIVATE idf::mbedtls)
endif()