CMakeLists.txt 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. idf_build_get_property(target IDF_TARGET)
  2. set(srcs "src/nvs_api.cpp"
  3. "src/nvs_cxx_api.cpp"
  4. "src/nvs_item_hash_list.cpp"
  5. "src/nvs_page.cpp"
  6. "src/nvs_pagemanager.cpp"
  7. "src/nvs_storage.cpp"
  8. "src/nvs_handle_simple.cpp"
  9. "src/nvs_handle_locked.cpp"
  10. "src/nvs_partition.cpp"
  11. "src/nvs_partition_lookup.cpp"
  12. "src/nvs_partition_manager.cpp"
  13. "src/nvs_types.cpp")
  14. idf_component_register(SRCS "${srcs}"
  15. REQUIRES "spi_flash"
  16. INCLUDE_DIRS "include")
  17. # If we use the linux target, we need to redirect the crc functions to the linux
  18. if(${target} STREQUAL "linux")
  19. if(CONFIG_NVS_ENCRYPTION)
  20. # mbedtls isn't configured for building with linux or as mock target. It will draw in all kind of dependencies
  21. message(FATAL_ERROR "NVS currently doesn't support encryption if built for Linux.")
  22. endif()
  23. target_compile_options(${COMPONENT_LIB} PUBLIC "-DLINUX_TARGET")
  24. else()
  25. # TODO: this is a workaround until IDF-2085 is fixed
  26. idf_component_get_property(mbedtls_lib mbedtls COMPONENT_LIB)
  27. target_link_libraries(${COMPONENT_LIB} PUBLIC ${mbedtls_lib})
  28. endif()
  29. if(CONFIG_NVS_ENCRYPTION)
  30. target_sources(${COMPONENT_LIB} PRIVATE "src/nvs_encrypted_partition.cpp")
  31. idf_component_get_property(mbedtls_lib mbedtls COMPONENT_LIB)
  32. target_link_libraries(${COMPONENT_LIB} PUBLIC ${mbedtls_lib})
  33. endif()
  34. if(${target} STREQUAL "linux")
  35. target_compile_options(${COMPONENT_LIB} PUBLIC --coverage)
  36. target_link_libraries(${COMPONENT_LIB} PUBLIC --coverage)
  37. endif()