If value not equal in cmake 2.8

Short version: I have build options that only work on one platform. The autotools file I'm converting form has a check of the form if test "$platform_linux" != "yes". Can I do the same thing in my CMakeLists.txt (test if the value is NOT equal)?

Slightly longer version: I've got a test for various platforms following the advice found here:


IF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
    # Linux specific code
    SET(OperatingSystem "Linux")
ENDIF(${CMAKE_SYSTEM_NAME} MATCHES "Linux")

I'd like to do a test of the form IF(${CMAKE_SYSTEM_NAME} NOT MATCHES "Linux"). This doesn't appear to work, and the only documentation I can find is a mailing-list post from 2002, which suggests the NOT isn't valid for cmake prior to 1.2. [Link].

Is this still the case in later cmake versions, specifically 2.6 and/or 2.8?


Solution 1:

You're close! The correct syntax for IF is

IF(NOT <expression>)

So in your specific case, you want

IF(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Linux").