windows cmake调试Google test 报错:VERSION keyword not followed by a value...

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 :

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。

  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值