CMakeLists.txt 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. "stdatomic.c"
  19. "time.c")
  20. set(include_dirs platform_include)
  21. if(CONFIG_SPIRAM_CACHE_WORKAROUND)
  22. set(ldfragments "esp32-spiram-rom-functions-c.lf")
  23. endif()
  24. list(APPEND ldfragments "newlib.lf" "system_libs.lf")
  25. idf_component_register(SRCS "${srcs}"
  26. INCLUDE_DIRS "${include_dirs}"
  27. PRIV_INCLUDE_DIRS priv_include
  28. PRIV_REQUIRES soc spi_flash
  29. LDFRAGMENTS "${ldfragments}")
  30. # Toolchain libraries require code defined in this component
  31. idf_component_get_property(newlib newlib COMPONENT_LIB)
  32. target_link_libraries(${COMPONENT_LIB} INTERFACE c m gcc "$<TARGET_FILE:${newlib}>")
  33. set_source_files_properties(heap.c PROPERTIES COMPILE_FLAGS -fno-builtin)
  34. # Forces the linker to include heap, syscall, pthread, assert, and retargetable locks from this component,
  35. # instead of the implementations provided by newlib.
  36. list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_heap_impl")
  37. list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_syscalls_impl")
  38. list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_pthread_impl")
  39. list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_assert_impl")
  40. target_link_libraries(${COMPONENT_LIB} INTERFACE "${EXTRA_LINK_FLAGS}")
  41. if(CONFIG_NEWLIB_NANO_FORMAT)
  42. target_link_libraries(${COMPONENT_LIB} INTERFACE "--specs=nano.specs")
  43. endif()
  44. add_subdirectory(port)