esp-idf/components/newlib/CMakeLists.txt

45 lines
1.4 KiB
CMake
Raw Normal View History

set(srcs
"heap.c"
"locks.c"
"poll.c"
"pread.c"
"pwrite.c"
"pthread.c"
"random.c"
"reent_init.c"
"select.c"
"syscall_table.c"
"syscalls.c"
"termios.c"
"time.c"
"utime.c")
set(include_dirs platform_include)
2019-11-05 06:20:26 -05:00
if(CONFIG_SPIRAM_CACHE_WORKAROUND)
set(ldfragments esp32-spiram-rom-functions-c.lf)
endif()
list(APPEND ldfragments newlib.lf)
idf_component_register(SRCS "${srcs}"
INCLUDE_DIRS "${include_dirs}"
REQUIRES vfs
PRIV_REQUIRES soc
LDFRAGMENTS "${ldfragments}")
2019-11-05 06:20:26 -05:00
# Toolchain libraries require code defined in this component
add_library(extra INTERFACE)
idf_component_get_property(newlib newlib COMPONENT_LIB)
target_link_libraries(extra INTERFACE ${LIBC} ${LIBM} gcc "$<TARGET_FILE:${newlib}>")
target_link_libraries(${COMPONENT_LIB} PUBLIC extra)
set_source_files_properties(heap.c PROPERTIES COMPILE_FLAGS -fno-builtin)
2019-11-05 06:20:26 -05:00
# Forces the linker to include locks, heap, and syscalls from this component,
# instead of the implementations provided by newlib.
set(EXTRA_LINK_FLAGS "-u newlib_include_locks_impl")
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")
target_link_libraries(${COMPONENT_LIB} INTERFACE "${EXTRA_LINK_FLAGS}")