arm gcc newlib retargetable locking fails because of command line order

Link step fails with multiple definition error because cmake has created a link command of the form

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

I used message(STATUS “CMAKE_C_LINK_EXECUTABLE ${CMAKE_C_LINK_EXECUTABLE}”) to show the contents and the result was

This is obviously being overridden during the generation process

To answer my own problem
I added
BEFORE the project statement

p.s. OBJECTS should be in <> but must be some kind of formatting going on

Consider using target_link_libraries(myexe PRIVATE -lc -lm).
Then CMake handles them as libraries like any other, and not just as some non-library linker flag.

P.S. use preformatted text or a code block for posting code fragments. Either via editor symbols or markdown syntax.