最近一直在学习cmake,所以把相关错误放在一个专栏里。
第一个碰到的问题是:没有给出编译目标工程的最低的cmake版本
其实这是一个警告,在一些IDE会自动帮你添加的。但是还是建议添加上编译工程的最低cmake版本。
#务必安装的cmake版本高于给定的最低版本,否则终止构建
CMAKE_MINIMUM_REQUIRED(VERSION 3.2 FATAL_ERROR)
注意:有时候你会发现添加了这句代码,任旧报错No cmake_minimum_required command is present,这是因为这句代码务必放在根目录的CMakeLists.txt的第一行。就是PROJECT()的上面
补充
#查看cmake的版本
cmake --version