Link step fails with multiple definition error because cmake has created a link command of the form
<CMAKE_C_COMPILER> $FLAGS $LINK_FLAGS @RSP_FILE -o $TARGET_FILE.
The $LINK_FLAGS contain -lc -lm. The problem is that this causes the dummy retargetable locks from newlib to be selected and then the objects list (RSP_FILE) causing multiple definitions.
I need the command to be of the form
<CMAKE_C_COMPILER> $FLAGS @RSP_FILE $LINK_FLAGS .-o $TARGET_FILE
I used message(STATUS “CMAKE_C_LINK_EXECUTABLE ${CMAKE_C_LINK_EXECUTABLE}”) to show the contents and the result was
CMAKE_C_LINK_EXECUTABLE <CMAKE_C_COMPILER> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> -o <LINK_LIBRARIES>
This is obviously being overridden during the generation process