CMake错误“如果给定参数”后跟括号,“NOT”,“EQUALS”和“EQUALS”。和类似的 [英] CMake error "if given arguments" followed by parenthesis, "NOT", "EQUALS" and similar

查看:4141
本文介绍了CMake错误“如果给定参数”后跟括号,“NOT”,“EQUALS”和“EQUALS”。和类似的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

CMake从以下行发出错误

CMake emits an error in from the following line

if(NOT ($ENV{TnCfg} STREQUAL Linux_Build_Speech))

错误是


CMakeLists.txt上的CMake错误:37(如果):

CMake Error at CMakeLists.txt:37 (if):

    如果给定参数:

    if given arguments:

"NOT" "(" "STREQUAL" "Linux_Build_Speech" ")"

指定未知参数

有什么问题?该行是有效代码。

What's the problem? The line is valid code.

推荐答案

您可能尝试检查空变量。问题是 $ ENV {TnCfg} 因为它是空的。 CMake用它们的值替换变量名的值,导致

Probably you try to check an empty variable. The problem is $ENV{TnCfg} because it is empty. CMake replaces the value of the variable names by their values, leading to

if (NOT (STREQUAL Linux_Build_Speech))

这是无效的,CMake想要一个 STREQUAL 的参数。

That's not valid and CMake wants an argument left of STREQUAL.

在变量周围加上引号

if(NOT ("$ENV{TnCfg}" STREQUAL Linux_Build_Speech))

解决问题,因为它被替换为 导致

fixes the problem, because it gets replaced by "" leading to

if(NOT ("" STREQUAL Linux_Build_Speech))

且空字符串是有效参数。

and the empty string is a valid argument.

这篇关于CMake错误“如果给定参数”后跟括号,“NOT”,“EQUALS”和“EQUALS”。和类似的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆