CMakeLists.txt 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. set(srcs "partition.c")
  2. set(priv_reqs esp_system bootloader_support spi_flash app_update partition_table)
  3. set(reqs)
  4. set(include_dirs "include")
  5. idf_build_get_property(build_dir BUILD_DIR)
  6. idf_build_get_property(target IDF_TARGET)
  7. if(${target} STREQUAL "linux")
  8. list(APPEND srcs "partition_linux.c")
  9. set(priv_reqs partition_table)
  10. # Steal some include directories from bootloader_support hal and spi_flash components:
  11. idf_component_get_property(hal_dir hal COMPONENT_DIR)
  12. idf_component_get_property(bootloader_support_dir bootloader_support COMPONENT_DIR)
  13. idf_component_get_property(spi_flash_dir spi_flash COMPONENT_DIR)
  14. list(APPEND include_dirs include ${hal_dir}/include ${bootloader_support_dir}/include ${spi_flash_dir}/include)
  15. else()
  16. list(APPEND srcs "partition_target.c")
  17. endif()
  18. idf_component_register(SRCS "${srcs}"
  19. INCLUDE_DIRS ${include_dirs}
  20. REQUIRES ${reqs}
  21. PRIV_REQUIRES ${priv_reqs})
  22. if(${target} STREQUAL "linux")
  23. # set BUILD_DIR because partition_linux.c uses a file created in the build directory
  24. target_compile_definitions(${COMPONENT_LIB} PRIVATE "BUILD_DIR=\"${build_dir}\"")
  25. # link bsd library for strlcpy
  26. find_library(LIB_BSD bsd)
  27. if(LIB_BSD)
  28. target_link_libraries(${COMPONENT_LIB} PRIVATE ${LIB_BSD})
  29. elseif(NOT CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
  30. message(WARNING "Missing LIBBSD library. Install libbsd-dev package and/or check linker directories.")
  31. endif()
  32. endif()
  33. if(CMAKE_C_COMPILER_ID MATCHES "GNU")
  34. # These flags are GCC specific
  35. set_property(SOURCE ${cache_srcs} APPEND_STRING PROPERTY COMPILE_FLAGS
  36. " -fno-inline-small-functions -fno-inline-functions-called-once")
  37. endif()