CMake error "if arguments are given" followed by parentheses, "NOT", "EQUALS" and similar

CMake emits an error from the next line

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

Mistake

CMake error in CMakeLists.txt: 37 (if):

if the given arguments are:

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

Unknown arguments

What is the problem? The string is valid.

0
if-statement cmake
Sep 26 '16 at 16:22
source share
1 answer

You are probably trying to check for an empty variable. The task is $ENV{TnCfg} because it is empty. CMake replaces the value of variable names with their values, which leads to

 if (NOT (STREQUAL Linux_Build_Speech)) 

This is not valid, and CMake wants to leave the argument from STREQUAL .

Putting quotes around a variable

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

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

 if(NOT ("" STREQUAL Linux_Build_Speech)) 

and an empty string is a valid argument.

+2
Sep 27 '16 at 19:48
source share



All Articles