I am trying to set up my CMakeLists.txt for a C++ project using a cross-compile toolchain (e.g. TI Code Composer Studio). I almost have it, but am stuck when it comes to adding a library to a link command. Boiling it down to basics, the tools want a command of this form:
armcl $(LINK_FLAGS) $(OBJS) $(LIBRARIES)
where the libraries are specified after all object files. If libraries are not after the object files, the linker doesn't recognize them.
However, I keep generating a command like:
armcl $(LINKER_OPTIONS) $(LIBRARIES) $(OBJS)
I use CMAKE_CXX_LINK_FLAGS to get the $(LINK_FLAGS), and use target_link_libraries() to specify the libraries.
set(CMAKE_CXX_LINK_FLAGS "${CMAKE_CXX_LINK_FLAGS} --heap_size=18000")
target_link_libraries(mtrs PRIVATE -llibc.a driverlib.lib)
How can I force CMake to generate link commands with libraries at the end?