0

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.

rahman
  • 4,820
  • 16
  • 52
  • 86
  • 1
    I cannot reproduce this locally. Which CMake version? Can you provide a stand-alone [mcve]? – Angew is no longer proud of SO Mar 07 '17 at 10:48
  • Possible duplicate of [CMake error near if: "if given arguments" followed by parantheses, "NOT", "EUQALS" and similar](http://stackoverflow.com/questions/39707772/cmake-error-near-if-if-given-arguments-followed-by-parantheses-not-euqal) – usr1234567 Mar 07 '17 at 21:19

1 Answers1

2

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

Community
  • 1
  • 1
Florian
  • 39,996
  • 9
  • 133
  • 149