!4452 used setting LINK_LIBRARIES and INTERFACE_LINK_LIBRARIES to link components built under ESP-IDF build system. However, LINK_LIBRARIES does not produce behavior same as linking PRIVATE. This MR uses the new signature for target_link_libraries directly instead. This also moves setting dependencies during component registration rather than after all components have been processed. The consequence is that internally, components have to use the new signature form as well. This does not affect linking the components to external targets, such as with idf_as_lib example. This only affects linking additional libraries to ESP-IDF libraries outside component processing (after idf_build_process), which is not even possible for CMake<v3.13 as target_link_libraries is not valid for targets not created in current directory. See https://cmake.org/cmake/help/v3.13/policy/CMP0079.html#policy:CMP0079
63 lines
2.2 KiB
CMake
63 lines
2.2 KiB
CMake
set(COMPONENT_SRCS "heap.c"
|
|
"locks.c"
|
|
"poll.c"
|
|
"pthread.c"
|
|
"random.c"
|
|
"reent_init.c"
|
|
"select.c"
|
|
"syscall_table.c"
|
|
"syscalls.c"
|
|
"termios.c"
|
|
"time.c"
|
|
"utime.c")
|
|
set(COMPONENT_ADD_INCLUDEDIRS platform_include)
|
|
|
|
if(GCC_NOT_5_2_0)
|
|
if(CONFIG_SPIRAM_CACHE_WORKAROUND)
|
|
set(COMPONENT_ADD_LDFRAGMENTS esp32-spiram-rom-functions-c.lf)
|
|
endif()
|
|
|
|
# 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")
|
|
else()
|
|
# Remove this section when GCC 5.2.0 is no longer supported
|
|
# 'include' and 'lib' directories should also be removed.
|
|
# An if statement about LIB_PATH below should also be removed.
|
|
list(APPEND COMPONENT_ADD_INCLUDEDIRS include)
|
|
set(LIB_PATH ${CMAKE_CURRENT_SOURCE_DIR}/lib)
|
|
|
|
if(CONFIG_SPIRAM_CACHE_WORKAROUND)
|
|
set(COMPONENT_ADD_LDFRAGMENTS esp32-spiram-rom-functions-psram-workaround.lf)
|
|
endif()
|
|
endif()
|
|
|
|
set(COMPONENT_REQUIRES vfs) # for sys/ioctl.h
|
|
set(COMPONENT_PRIV_REQUIRES soc)
|
|
|
|
list(APPEND COMPONENT_ADD_LDFRAGMENTS newlib.lf)
|
|
|
|
register_component()
|
|
|
|
if(LIB_PATH)
|
|
target_link_libraries(${COMPONENT_LIB} INTERFACE "-L ${LIB_PATH}")
|
|
endif()
|
|
|
|
if(GCC_NOT_5_2_0)
|
|
# 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)
|
|
else()
|
|
target_link_libraries(${COMPONENT_LIB} PUBLIC ${LIBC} ${LIBM} gcc)
|
|
endif()
|
|
|
|
set_source_files_properties(heap.c PROPERTIES COMPILE_FLAGS -fno-builtin)
|
|
|
|
if(EXTRA_LINK_FLAGS)
|
|
target_link_libraries(${COMPONENT_LIB} INTERFACE "${EXTRA_LINK_FLAGS}")
|
|
endif()
|