Exported CMake toolchain file is broken when the target is linked against NuttX and another library that shall also be linked against NuttX too.

Fix: ensure that NuttX libraries are linked at the end as they are the root of linkage dependency tree.
This commit is contained in:
Philippe Leduc
2024-03-01 09:24:27 +01:00
committed by Xiang Xiao
parent 9489953230
commit 8de922186e
+5 -6
View File
@@ -21,13 +21,12 @@ set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES
add_compile_options(-nostdlib)
add_compile_options(-ffunction-sections -fdata-sections)
link_libraries(
"-L${NUTTX_PATH}/libs -Wl,--start-group ${LDLIBS} ${EXTRA_LIBS} -Wl,--end-group"
set(CMAKE_C_LINK_EXECUTABLE
"<CMAKE_LINKER> ${LDFLAGS} --entry=__start -T${LINKER_SCRIPT} <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -L${NUTTX_PATH}/libs --start-group ${LDLIBS} ${EXTRA_LIBS} --end-group"
)
set(CMAKE_CXX_LINK_EXECUTABLE
"<CMAKE_LINKER> ${LDFLAGS} --entry=__start -T${LINKER_SCRIPT} <OBJECTS> -o <TARGET> <LINK_LIBRARIES> -L${NUTTX_PATH}/libs --start-group ${LDLIBS} ${EXTRA_LIBS} --end-group"
)
add_link_options(-Wl,--entry=__start)
add_link_options(-nostdlib)
add_link_options(-Wl,--gc-sections)
add_link_options(-T${LINKER_SCRIPT})
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)