CMake AMRCC +定制链接器 [英] CMake AMRCC + custom linker
问题描述
我试图在使用 armcc
编译的项目中使用 cmake
,但使用自定义链接器(不是 armlink
)。
I'm trying to use cmake
in a project which is compiled using armcc
, but use a custom proprietary linker (not armlink
).
toolchain.cmake
档案如下:
unset (CMAKE_LINKER CACHE)
set (CMAKE_LINKER "my_linker" CACHE STRING "" FORCE)
unset (CMAKE_ARMCC_LINKER CACHE)
set (CMAKE_ARMCC_LINKER "my_linker" CACHE STRING "" FORCE)
unset (CMAKE_EXE_LINKER_FLAGS CACHE )
set (CMAKE_EXE_LINKER_FLAGS "-flag1 -flag2" CACHE STRING "" FORCE)
unset (CMAKE_C_LINK_EXECUTABLE)
set (CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <CMAKE_EXE_LINKER_FLAGS> <OBJECTS> <LINK_LIBRARIES> -o <TARGET>")
unset (CMAKE_CXX_LINK_EXECUTABLE)
set (CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_LINKER> <CMAKE_EXE_LINKER_FLAGS> <OBJECTS> <LINK_LIBRARIES> -o <TARGET>")
> cmake 尝试检查我的编译器套件,它在链接步骤失败:
But when cmake
tries to check my compiler suite, it fails in the linking step:
-- Check for working C compiler: armcc.exe -- broken
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.6/Modules/CMakeTestCCompiler.cmake:61 (message):
The C compiler "armcc.exe" is not able to compile a simple test program.
... (compiling commands that worked hidden here)
Linking C executable cmTC_c08ef.elf
"C:\Program Files (x86)\CMake\bin\cmake.exe" -E cmake_link_script CMakeFiles\cmTC_c08ef.dir\link.txt --verbose=1
my_linker -flag1 -flag2 CMakeFiles/cmTC_c08ef.dir/testCCompiler.o -o cmTC_c08ef.elf --list cmTC_c08ef.map
问题是 - 列出cmTC_c08ef.map
在命令行结尾处( toolchain.cmake
文件中不存在)。
The problem is the --list cmTC_c08ef.map
at the end of command line (which does not exist in the toolchain.cmake
file).
为了使其工作,我需要更改文件< cmake_install_dir> \Modules\Compiler\ARMCC.cmake
如下:
In order to make it work, I need to change the file <cmake_install_dir>\Modules\Compiler\ARMCC.cmake
as following:
set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_LINKER> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> <OBJECTS> -o <TARGET> --list <TARGET_BASE>.map")
# set(CMAKE_${lang}_LINK_EXECUTABLE "<CMAKE_LINKER> <CMAKE_${lang}_LINK_FLAGS> <LINK_FLAGS> <LINK_LIBRARIES> <OBJECTS> -o <TARGET>")
有一个更好的方法来解决这个问题,只有方式吗?
There is a better approach to solve this issue or it is the only way?
编辑:显然这是在cmake的armcc支持中的一个错误,所以我会保留我的更改在ARMCC.cmake文件。
Apparently this is a bug in the cmake's armcc support, so I will keep my change in the ARMCC.cmake file.
推荐答案
显然,这是在CMake的的支持器armcc的错误,所以我会继续我的ARMCC.cmake文件更改。
Apparently this is a bug in the cmake's armcc support, so I will keep my change in the ARMCC.cmake file.
这篇关于CMake AMRCC +定制链接器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!