CMake IF(something OR something else)

45,418
if (NOT (${TARGET_PLATFORM} STREQUAL "test" OR ${TARGET_PLATFORM} STREQUAL "my_board"))

or more simply

if (CONDITION1 OR CONDITION2)
Share:
45,418
joshua.kurland
Author by

joshua.kurland

Updated on September 14, 2020

Comments

  • joshua.kurland
    joshua.kurland over 3 years

    Does the CMake IF statement have an OR option as well? Something like: IF (NOT this OR that) ... ENDIF?

    I have the line if (NOT ${TARGET_PLATFORM} STREQUAL "test"), which removes certain build files from the project. I want to add a second Target platform option, "my_board", which needs to remove those same build files. I tried adding an elseif(NOT ${TARGET_PLATFORM} STREQUAL "my_board") following the first IF, but that was not successful.

    Is what I am trying to do possible with CMake, and if so, what is the proper syntax?

    Thanks