CMake puts linker flag wrong place
I added linker flag into my CMakeLists.txt and then generated make build scripts. But it did not compile. I've got so many undefined function error. It failed at the linking phase of the compilation process. When I looked at the link.txt file which is generated by the CMake, I saw that the cmake puts linker flag at the begin of the CC command.
like so; /usr/bin/cc -lpthread -lrt -ldl {COUPLE_OF_OBJECT_FILES} -o VMCORE_TEST -rdynamic ../out/library/libVMCORE.a
but the linker flag should be appended at the end. like so;
/usr/bin/cc {COUPLE_OF_OBJECT_FILES} -o VMCORE_TEST -rdynamic ../out/library/libVMCORE.a -lpthread -lrt -ldl
Edit: I almost forget. I'm setting linker flag using CMAKE_{TYPE}LINKER_FLAGS variable. not with the target_link_libraries. I expected that CMAKE{TYPE}_LINKER_FLAGS have to append my extra addition to the end of the command.