CMake AMRCC + custom linker

后端 未结 2 1281
终归单人心
终归单人心 2021-01-14 04:09

I\'m trying to use cmake in a project which is compiled using armcc, but use a custom proprietary linker (not armlink).

相关标签:
2条回答
  • 2021-01-14 04:15

    That's exactly the use case of a relatively new (version 3.6) global CMake variable named CMAKE_TRY_COMPILE_TARGET_TYPE. So just add the following to your toolchain file:

    set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)
    

    Edit: If your custom linker also gives you trouble outside the compiler check, simply split your toolchain into 2 files (toolchain.cmake to be read before and makerules.cmake after the CMake's compiler detection):

    toolchain.cmake

    [...]
    set (CMAKE_USER_MAKE_RULES_OVERRIDE "${CMAKE_CURRENT_LIST_FILE}/makerules.cmake")
    

    makerules.cmake

    set (CMAKE_C_LINK_EXECUTABLE "<CMAKE_LINKER> <CMAKE_EXE_LINKER_FLAGS> <OBJECTS> <LINK_LIBRARIES> -o <TARGET>")
    set (CMAKE_CXX_LINK_EXECUTABLE "<CMAKE_LINKER> <CMAKE_EXE_LINKER_FLAGS> <OBJECTS> <LINK_LIBRARIES> -o <TARGET>")
    

    Refrences

    • CMAKE_USER_MAKE_RULES_OVERRIDE
    • Change default value of CMAKE_CXX_FLAGS_DEBUG and friends in CMake
    • CMake: In which Order are Files parsed (Cache, Toolchain, …)?
    0 讨论(0)
  • 2021-01-14 04:36

    Apparently this is a bug in the cmake's armcc support, so I will keep my change in the ARMCC.cmake file.

    0 讨论(0)
提交回复
热议问题