cmake 生成makefile 这一步时,报错:
C:\Users\-----\googletest-main\googletest\mybuild>cmake -G "MinGW Makefiles" ../
CMake Warning at CMakeLists.txt:51 (project):
VERSION keyword not followed by a value or was followed by a value that
expanded to nothing.
分析:报错发生在Cmakelists.txt 的第51行,找到51行:看到${GOOGLETEST_VERSION}, 应该是这里报错了. 这里涉及到cmake的一个语法
Variable References :
A variable reference has the form ${<variable>}
and is evaluated inside a Quoted Argument or an Unquoted Argument. A variable reference is replaced by the value of the variable, or by the empty string if the variable is not set. Variable references can nest and are evaluated from the inside out, e.g. ${outer_${inner_variable}_variable}
.
也就是说,如果${GOOGLETEST_VERSION}之前没有set 语句,这里将用一个空值代替,也就出现了这个报错。
解决方法,在这条语句前加上:
set(GOOGLETEST_VERSION 1.11.0)
参考文档:
1.https://blog.csdn.net/qq_42769920/article/details/121198844
2.cmake help文件,本地打开cmake, help里有个Cmake reference manual。