if()True if the constant is 1, ON, YES, TRUE, Y,
or a non-zero number. False if the constant is 0, OFF,
NO, FALSE, N, IGNORE, NOTFOUND, the empty string,
or ends in the suffix -NOTFOUND. Named boolean constants are
case-insensitive. If the argument is not one of these constants, it
is treated as a variable.
if()True if the variable is defined to a value that is not a false
constant. False otherwise. (Note macro arguments are not variables.)
if(NOT )True if the expression is not true.
if( AND )True if both expressions would be considered true individually.
if( OR )True if either expression would be considered true individually.
if(COMMAND command-name)True if the given name is a command, macro or function that can be
invoked.
if(POLICY policy-id)True if the given name is an existing policy (of the form CMP).
if(TARGET target-name)True if the given name is an existing logical target name such as those
created by the add_executable(), add_library(), or
add_custom_target() commands.
if(EXISTS path-to-file-or-directory)True if the named file or directory exists. Behavior is well-defined
only for full paths.
if(file1 IS_NEWER_THAN file2)True if file1 is newer than file2 or if one of the two files doesn’t
exist. Behavior is well-defined only for full paths. If the file
time stamps are exactly the same, an IS_NEWER_THAN comparison returns
true, so that any dependent build operations will occur in the event
of a tie. This includes the case of passing the same file name for
both file1 and file2.
if(IS_DIRECTORY path-to-directory)True if the given name is a directory. Behavior is well-defined only
for full paths.
if(IS_SYMLINK file-name)True if the given name is a symbolic link. Behavior is well-defined
only for full paths.
if(IS_ABSOLUTE path)True if the given path is an absolute path.
if( MATCHES regex)True if the given string or variable’s value matches the given regular
expression.
if( LESS )True if the given string or variable’s value is a valid number and less
than that on the right.
if( GREATER )True if the given string or variable’s value is a valid number and greater
than that on the right.
if( EQUAL )True if the given string or variable’s value is a valid number and equal
to that on the right.
if( STRLESS )True if the given string or variable’s value is lexicographically less
than the string or variable on the right.
if( STRGREATER )True if the given string or variable’s value is lexicographically greater
than the string or variable on the right.
if( STREQUAL )True if the given string or variable’s value is lexicographically equal
to the string or variable on the right.
if( VERSION_LESS )Component-wise integer version number comparison (version format is
major[.minor[.patch[.tweak]]]).
if( VERSION_EQUAL )Component-wise integer version number comparison (version format is
major[.minor[.patch[.tweak]]]).
if( VERSION_GREATER )Component-wise integer version number comparison (version format is
major[.minor[.patch[.tweak]]]).
if(DEFINED )True if the given variable is defined. It does not matter if the
variable is true or false just if it has been set. (Note macro
arguments are not variables.)
if((expression) AND (expression OR (expression)))The expressions inside the parenthesis are evaluated first and then
the remaining expression is evaluated as in the previous examples.
Where there are nested parenthesis the innermost are evaluated as part
of evaluating the expression that contains them.