CMakeLists.txt 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. set(srcs
  2. "abort.c"
  3. "heap.c"
  4. "locks.c"
  5. "poll.c"
  6. "pthread.c"
  7. "random.c"
  8. "reent_init.c"
  9. "syscall_table.c"
  10. "syscalls.c"
  11. "termios.c"
  12. "time.c")
  13. set(include_dirs platform_include)
  14. if(CONFIG_SPIRAM_CACHE_WORKAROUND)
  15. set(ldfragments esp32-spiram-rom-functions-c.lf)
  16. endif()
  17. list(APPEND ldfragments newlib.lf)
  18. idf_component_register(SRCS "${srcs}"
  19. INCLUDE_DIRS "${include_dirs}"
  20. PRIV_REQUIRES soc esp_timer
  21. LDFRAGMENTS "${ldfragments}")
  22. # Toolchain libraries require code defined in this component
  23. idf_component_get_property(newlib newlib COMPONENT_LIB)
  24. target_link_libraries(${COMPONENT_LIB} INTERFACE c m gcc "$<TARGET_FILE:${newlib}>")
  25. set_source_files_properties(heap.c PROPERTIES COMPILE_FLAGS -fno-builtin)
  26. # Forces the linker to include locks, heap, and syscalls from this component,
  27. # instead of the implementations provided by newlib.
  28. set(EXTRA_LINK_FLAGS "-u newlib_include_locks_impl")
  29. list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_heap_impl")
  30. list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_syscalls_impl")
  31. list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_pthread_impl")
  32. target_link_libraries(${COMPONENT_LIB} INTERFACE "${EXTRA_LINK_FLAGS}")
  33. if(CONFIG_NEWLIB_NANO_FORMAT)
  34. target_link_libraries(${COMPONENT_LIB} INTERFACE "--specs=nano.specs")
  35. endif()