CMakeLists.txt 1.7 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 "esp_partition"
  16. PRIV_REQUIRES spi_flash
  17. INCLUDE_DIRS "include"
  18. "../spi_flash/include"
  19. PRIV_INCLUDE_DIRS "private_include")
  20. # If we use the linux target, we need to redirect the crc functions to the linux
  21. if(${target} STREQUAL "linux")
  22. if(CONFIG_NVS_ENCRYPTION)
  23. # mbedtls isn't configured for building with linux or as mock target. It will draw in all kind of dependencies
  24. message(FATAL_ERROR "NVS currently doesn't support encryption if built for Linux.")
  25. endif()
  26. target_compile_options(${COMPONENT_LIB} PUBLIC "-DLINUX_TARGET")
  27. target_compile_options(${COMPONENT_LIB} PUBLIC --coverage)
  28. target_link_libraries(${COMPONENT_LIB} PUBLIC --coverage)
  29. find_library(LIB_BSD bsd)
  30. if(LIB_BSD)
  31. target_link_libraries(${COMPONENT_LIB} PRIVATE ${LIB_BSD})
  32. elseif(NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
  33. message(WARNING "Missing LIBBSD library. Install libbsd-dev package and/or check linker directories.")
  34. endif()
  35. else()
  36. target_sources(${COMPONENT_LIB} PRIVATE "src/nvs_encrypted_partition.cpp")
  37. target_link_libraries(${COMPONENT_LIB} PRIVATE idf::mbedtls)
  38. endif()