esp-idf/components/newlib/CMakeLists.txt

54 lines
1.7 KiB
CMake
Raw Normal View History

if(BOOTLOADER_BUILD)
# Bootloader builds need the platform_include directory (for assert.h), but nothing else
idf_component_register(INCLUDE_DIRS platform_include)
return()
endif()
set(srcs
2020-02-02 10:18:29 -05:00
"abort.c"
"assert.c"
"heap.c"
"locks.c"
"poll.c"
"pthread.c"
"random.c"
"reent_init.c"
"newlib_init.c"
"syscalls.c"
"termios.c"
2021-02-19 08:41:26 -05:00
"stdatomic.c"
"time.c")
set(include_dirs platform_include)
2019-11-05 06:20:26 -05:00
if(CONFIG_SPIRAM_CACHE_WORKAROUND)
2021-03-10 06:44:58 -05:00
set(ldfragments "esp32-spiram-rom-functions-c.lf")
endif()
2021-03-10 06:44:58 -05:00
list(APPEND ldfragments "newlib.lf" "system_libs.lf")
idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "${include_dirs}"
PRIV_INCLUDE_DIRS priv_include
PRIV_REQUIRES soc spi_flash
LDFRAGMENTS "${ldfragments}")
2019-11-05 06:20:26 -05:00
# Toolchain libraries require code defined in this component
idf_component_get_property(newlib newlib COMPONENT_LIB)
target_link_libraries(${COMPONENT_LIB} INTERFACE c m gcc "$<TARGET_FILE:${newlib}>")
set_source_files_properties(heap.c PROPERTIES COMPILE_FLAGS -fno-builtin)
# Forces the linker to include heap, syscall, pthread, assert, and retargetable locks from this component,
2019-11-05 06:20:26 -05:00
# instead of the implementations provided by newlib.
list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_heap_impl")
list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_syscalls_impl")
list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_pthread_impl")
list(APPEND EXTRA_LINK_FLAGS "-u newlib_include_assert_impl")
2019-11-05 06:20:26 -05:00
target_link_libraries(${COMPONENT_LIB} INTERFACE "${EXTRA_LINK_FLAGS}")
if(CONFIG_NEWLIB_NANO_FORMAT)
target_link_libraries(${COMPONENT_LIB} INTERFACE "--specs=nano.specs")
endif()
add_subdirectory(port)