rahman
rahman

Reputation: 4948

error in cmake IF statement

I have a if statement in my .cmake file which reads like:

if( (NOT ${GCC_VERSION} GREATER some_version ) AND something EQUAL somethingelse)
    #todo ...
endif()

I need the NOT only for the first check of the statement.

I get the following error:

CMake Error: Error in cmake code at
/.../XXX.cmake:123:
Parse error.  Function missing ending ")".  Instead found left paren with text "(".

Appreciate your kind help.

Upvotes: 0

Views: 481

Answers (1)

Florian
Florian

Reputation: 42842

GCC_VERSION variable could be empty, resulting in an invalid if statement.

Put ${GCC_VERSION} in quotes (CMake only knows strings) or don't dereference the variable (which is an equivalent operation) to be on the safe side:

if( NOT "${GCC_VERSION}" GREATER some_version )

or

if( NOT GCC_VERSION GREATER some_version )

References

Upvotes: 2

Related Questions