这是我的第一个涉及交叉编译的CMake项目。
这是我的CMakeLists.txt文件:
CMAKE_MINIMUM_REQUIRED(VERSION 3.10)
INCLUDE(${CMAKE_CURRENT_SOURCE_DIR}/config.cmake)
PROJECT(proj1)
ENABLE_LANGUAGE(ASM)
SET(ASM_SOURCES "boot/start.s")
ADD_EXECUTABLE(${CMAKE_PROJECT_NAME} ${ASM_SOURCES})
,其中包括config.cmake文件:
SET(TOOLCHAIN_PREFIX "arm-rookieboard-eabi")
SET(TOOLCHAIN_PATH "${CMAKE_CURRENT_SOURCE_DIR}/utils/toolchain/${TOOLCHAIN_PREFIX}")
SET(TOOLCHAIN_BIN_PATH "${TOOLCHAIN_PATH}/bin")
SET(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
SET(CMAKE_ASM_COMPILER "${TOOLCHAIN_BIN_PATH}/${TOOLCHAIN_PREFIX}-as")
SET(CMAKE_C_COMPILER "${TOOLCHAIN_BIN_PATH}/${TOOLCHAIN_PREFIX}-gcc")
SET(CMAKE_CXX_COMPILER "${TOOLCHAIN_BIN_PATH}/${TOOLCHAIN_PREFIX}-g++")
SET(CMAKE_LINKER "${TOOLCHAIN_BIN_PATH}/${TOOLCHAIN_PREFIX}-ld" CACHE INTERNAL "" )
SET(CMAKE_OBJCOPY "${TOOLCHAIN_BIN_PATH}/${TOOLCHAIN_PREFIX}-objcopy")
SET(CMAKE_SIZE "${TOOLCHAIN_BIN_PATH}/${TOOLCHAIN_PREFIX}-size")
SET(CMAKE_C_LINK_EXECUTABLE ${CMAKE_LINKER})
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Map proj1.map -T proj1.ld")
“ start.s”文件编译成功(此文件包括平台的程序集启动代码),但无法链接。我对其进行了调查,发现在CMakeFiles目录下的“ link.txt”中存在下一行:
/home/root/proj1/utils/toolchain/arm-rookieboard-eabi/bin/arm-rookieboard-eabi-as CMakeFiles/proj1/boot/start.s.o -o proj1
为什么它再次调用AS,而不是LD? 我错过了什么吗?
非常感谢您。