1. One issue I got is link flag was not know by linker ld.exe:
The solution is set CMAKE_SYSTEM_NAME to Generic on the top of CMakelist.txt as:
If you put line 3 after your project(xxx), it doesn't help you to fix this issue.
2. Use cross compiler on Windows
First attention point: In the environment variables, remove other toolchains, or put your cross-compiler toolchains on the top of variable 'PATH'.
Second attention point: Add cross-compiler gcc to environment variable 'CC'.
If the code folders like:
top
|----CMakeList.txt
|----main.c
|--