CMakeLists.txt 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. if(BOOTLOADER_BUILD)
  2. # Bootloader builds need the platform_include directory (for assert.h), but nothing else
  3. idf_component_register(INCLUDE_DIRS platform_include)
  4. return()
  5. endif()
  6. set(srcs
  7. "abort.c"
  8. "assert.c"
  9. "heap.c"
  10. "locks.c"
  11. "poll.c"
  12. "pthread.c"
  13. "random.c"
  14. "reent_init.c"
  15. "newlib_init.c"
  16. "syscalls.c"
  17. "termios.c"
  18. "time.c")
  19. set(include_dirs platform_include)
  20. if(CONFIG_SPIRAM_CACHE_WORKAROUND)
  21. set(ldfragments esp32-spiram-rom-functions-c.lf)
  22. endif()
  23. list(APPEND ldfragments newlib.lf)
  24. idf_component_register(SRCS "${srcs}"
  25. INCLUDE_DIRS "${include_dirs}"
  26. PRIV_INCLUDE_DIRS priv_include
  27. PRIV_REQUIRES soc spi_flash
  28. LDFRAGMENTS "${ldfragments}")
  29. # Toolchain libraries require code defined in this component
  30. idf_component_get_property(newlib newlib COMPONENT_LIB)
  31. target_link_libraries(${COMPONENT_LIB} INTERFACE c m gcc "$<TARGET_FILE:${newlib}>")
  32. set_source_files_properties(heap.c PROPERTIES COMPILE_FLAGS -fno-builtin)
  33. # Forces the linker to include heap, syscall, pthread, assert, and retargetable locks from this component,
  34. # instead of the implementations provided by newlib.
  35. list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_heap_impl")
  36. list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_syscalls_impl")
  37. list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_pthread_impl")
  38. list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_assert_impl")
  39. target_link_libraries(${COMPONENT_LIB} INTERFACE "${EXTRA_LINK_FLAGS}")
  40. if(CONFIG_NEWLIB_NANO_FORMAT)
  41. target_link_libraries(${COMPONENT_LIB} INTERFACE "--specs=nano.specs")
  42. endif()
  43. add_subdirectory(port)