nuttx/tools/toolchain.cmake.export
Philippe Leduc 8de922186e 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.
2024-03-04 20:38:37 +08:00

35 lines
1.3 KiB
Plaintext

set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_VERSION 1)
set(NUTTX 1)
set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
set(NUTTX_PATH ${CMAKE_CURRENT_LIST_DIR}/..)
include(${NUTTX_PATH}/scripts/target.cmake)
set(LINKER_SCRIPT ${NUTTX_PATH}/scripts/${LDNAME})
set(CMAKE_C_FLAGS "${ARCHCPUFLAGS} ${ARCHCFLAGS} -D__NuttX__")
set(CMAKE_CXX_FLAGS "${ARCHCPUFLAGS} ${ARCHCXXFLAGS} -D__NuttX__")
set(CMAKE_C_STANDARD_INCLUDE_DIRECTORIES ${NUTTX_PATH}/include
${NUTTX_PATH}/arch/chip)
set(CMAKE_CXX_STANDARD_INCLUDE_DIRECTORIES
${NUTTX_PATH}/include/libcxx ${NUTTX_PATH}/include ${NUTTX_PATH}/arch/chip)
add_compile_options(-nostdlib)
add_compile_options(-ffunction-sections -fdata-sections)
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"
)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)