CMake AMRCC + custom linker

后端 未结 2 1283
终归单人心
终归单人心 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 "    -o ")
    set (CMAKE_CXX_LINK_EXECUTABLE "    -o ")
    

    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, …)?

提交回复
热议问题