windows 使用cmake 问题
- 1. C/C++编译器无法设置成功
- 2. 链接报unrecognized option '--major-image-version'错误
- 3 uses variable-size enums yet the output is to use 32-bit enums
1. C/C++编译器无法设置成功
在cmakelists.txt中设置的CMAKE_C_COMPILER 和 CMAKE_CXX_COMPILER,报编译信息使用系统自带的Building for: Visual Studio xx xx
原因:CMAKE在windows 下选择GCC需要使用-G命令
cmake -G "Unix Makefiles" ..
2. 链接报unrecognized option '–major-image-version’错误
在windows中gcc-arm链接报unrecognized option ‘–major-image-version’,原因:CMAKE 会识别系统,然后使用系统编译器
需要在CMAKE 中将系统设置为无系统模式
set(CMAKE_SYSTEM_NAME Generic)
3 uses variable-size enums yet the output is to use 32-bit enums
解决方案:不能直接加编译链接选项:-no-enum-size-warning
需要在链接的时候这样增加,才能解决
target_link_options(<target>-WL,-no-enum-size-warning
)