2021-06-17 16:32:18 -04:00
|
|
|
====================
|
|
|
|
Empty if [condition]
|
|
|
|
====================
|
2021-06-29 14:35:34 -04:00
|
|
|
if ( cond )
|
2021-06-17 16:32:18 -04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
(source_file
|
|
|
|
(if_condition
|
|
|
|
(if_command
|
|
|
|
(if)
|
2023-06-28 10:33:56 -04:00
|
|
|
(argument_list
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
)
|
2021-06-17 16:32:18 -04:00
|
|
|
)
|
2023-06-28 09:14:23 -04:00
|
|
|
(body)
|
2021-06-17 16:32:18 -04:00
|
|
|
(endif_command (endif))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
===========================
|
|
|
|
Empty if elseif [condition]
|
|
|
|
===========================
|
|
|
|
if(cond)
|
|
|
|
elseif(cond)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
(source_file
|
|
|
|
(if_condition
|
|
|
|
(if_command
|
|
|
|
(if)
|
2023-06-28 10:33:56 -04:00
|
|
|
(argument_list
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
)
|
2021-06-17 16:32:18 -04:00
|
|
|
)
|
2023-06-28 09:14:23 -04:00
|
|
|
(body)
|
2021-06-17 16:32:18 -04:00
|
|
|
(elseif_command
|
|
|
|
(elseif)
|
2023-06-28 10:33:56 -04:00
|
|
|
(argument_list
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
)
|
2021-06-17 16:32:18 -04:00
|
|
|
)
|
2023-06-28 09:14:23 -04:00
|
|
|
(body)
|
2021-06-17 16:32:18 -04:00
|
|
|
(endif_command (endif))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
================================
|
|
|
|
Empty if elseif else [condition]
|
|
|
|
================================
|
|
|
|
if(cond)
|
|
|
|
elseif(cond)
|
|
|
|
else()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
(source_file
|
|
|
|
(if_condition
|
|
|
|
(if_command
|
|
|
|
(if)
|
2023-06-28 10:33:56 -04:00
|
|
|
(argument_list
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
)
|
2021-06-17 16:32:18 -04:00
|
|
|
)
|
2023-06-28 09:14:23 -04:00
|
|
|
(body)
|
2021-06-17 16:32:18 -04:00
|
|
|
(elseif_command
|
|
|
|
(elseif)
|
2023-06-28 10:33:56 -04:00
|
|
|
(argument_list
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
)
|
2021-06-17 16:32:18 -04:00
|
|
|
)
|
2023-06-28 09:14:23 -04:00
|
|
|
(body)
|
2021-06-17 16:32:18 -04:00
|
|
|
(else_command (else))
|
2023-06-28 09:14:23 -04:00
|
|
|
(body)
|
2021-06-17 16:32:18 -04:00
|
|
|
(endif_command (endif))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
2023-06-28 09:14:23 -04:00
|
|
|
============================================
|
|
|
|
If with many command invocations [condition]
|
|
|
|
============================================
|
2021-06-17 16:32:18 -04:00
|
|
|
if(cond)
|
|
|
|
message(STATUS)
|
2023-06-28 09:14:23 -04:00
|
|
|
message(STATUS)
|
2021-06-17 16:32:18 -04:00
|
|
|
endif()
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
(source_file
|
2023-06-28 10:33:56 -04:00
|
|
|
(if_condition
|
|
|
|
(if_command
|
|
|
|
(if)
|
|
|
|
(argument_list
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
)
|
2023-06-28 09:14:23 -04:00
|
|
|
)
|
2023-06-28 10:33:56 -04:00
|
|
|
(body
|
|
|
|
(normal_command
|
|
|
|
(identifier)
|
|
|
|
(argument_list
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
(normal_command
|
|
|
|
(identifier)
|
|
|
|
(argument_list
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
)
|
|
|
|
)
|
2023-06-28 09:14:23 -04:00
|
|
|
)
|
2023-06-28 10:33:56 -04:00
|
|
|
(endif_command (endif))
|
2023-06-28 09:14:23 -04:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
==============================================================
|
|
|
|
If, elseof, and else with many command invocations [condition]
|
|
|
|
==============================================================
|
|
|
|
if(cond)
|
|
|
|
message(STATUS)
|
|
|
|
message(STATUS)
|
|
|
|
elseif(cond)
|
|
|
|
message(STATUS)
|
|
|
|
message(STATUS)
|
|
|
|
else(cond)
|
|
|
|
message(STATUS)
|
|
|
|
message(STATUS)
|
|
|
|
endif()
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
(source_file
|
2023-06-28 10:33:56 -04:00
|
|
|
(if_condition
|
|
|
|
(if_command
|
|
|
|
(if)
|
|
|
|
(argument_list
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
)
|
2023-06-28 09:14:23 -04:00
|
|
|
)
|
2023-06-28 10:33:56 -04:00
|
|
|
(body
|
|
|
|
(normal_command
|
|
|
|
(identifier)
|
|
|
|
(argument_list
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
(normal_command
|
|
|
|
(identifier)
|
|
|
|
(argument_list
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
)
|
|
|
|
)
|
2023-06-28 09:14:23 -04:00
|
|
|
)
|
2023-06-28 10:33:56 -04:00
|
|
|
(elseif_command
|
|
|
|
(elseif)
|
|
|
|
(argument_list
|
2023-06-28 09:14:23 -04:00
|
|
|
(argument (unquoted_argument))
|
|
|
|
)
|
|
|
|
)
|
2023-06-28 10:33:56 -04:00
|
|
|
(body
|
|
|
|
(normal_command
|
|
|
|
(identifier)
|
|
|
|
(argument_list
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
(normal_command
|
|
|
|
(identifier)
|
|
|
|
(argument_list
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
)
|
|
|
|
)
|
2023-06-28 09:14:23 -04:00
|
|
|
)
|
2023-06-28 10:33:56 -04:00
|
|
|
(else_command
|
|
|
|
(else)
|
|
|
|
(argument_list
|
2023-06-28 09:14:23 -04:00
|
|
|
(argument (unquoted_argument))
|
|
|
|
)
|
2023-06-28 10:33:56 -04:00
|
|
|
)
|
|
|
|
(body
|
|
|
|
(normal_command
|
|
|
|
(identifier)
|
|
|
|
(argument_list
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
(normal_command
|
|
|
|
(identifier)
|
|
|
|
(argument_list
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
(endif_command (endif))
|
2023-06-28 09:14:23 -04:00
|
|
|
)
|
2021-06-17 16:32:18 -04:00
|
|
|
)
|
2021-07-02 03:26:41 -04:00
|
|
|
|
2023-06-28 09:14:23 -04:00
|
|
|
|
2021-07-02 03:26:41 -04:00
|
|
|
======================================
|
|
|
|
Condition with parentheses [condition]
|
|
|
|
======================================
|
|
|
|
if((A AND B) OR C)
|
|
|
|
endif()
|
|
|
|
---
|
|
|
|
(source_file
|
|
|
|
(if_condition
|
|
|
|
(if_command
|
|
|
|
(if)
|
2023-06-28 10:33:56 -04:00
|
|
|
(argument_list
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
)
|
2021-07-02 03:26:41 -04:00
|
|
|
)
|
2023-06-28 09:14:23 -04:00
|
|
|
(body)
|
2021-07-02 03:26:41 -04:00
|
|
|
(endif_command (endif))
|
|
|
|
)
|
|
|
|
)
|
2022-07-08 01:04:54 -04:00
|
|
|
|
|
|
|
==============================================
|
|
|
|
Condition with not and parentheses [condition]
|
|
|
|
==============================================
|
|
|
|
if(NOT (A AND B) OR C)
|
|
|
|
else(NOT (A AND B) OR C)
|
|
|
|
endif(NOT (A AND B) OR C)
|
|
|
|
---
|
|
|
|
(source_file
|
2023-06-28 10:33:56 -04:00
|
|
|
(if_condition
|
|
|
|
(if_command
|
|
|
|
(if)
|
|
|
|
(argument_list
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
(body)
|
|
|
|
(else_command
|
|
|
|
(else)
|
|
|
|
(argument_list
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
(body)
|
|
|
|
(endif_command
|
|
|
|
(endif)
|
|
|
|
(argument_list
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
)
|
|
|
|
)
|
2022-07-08 01:04:54 -04:00
|
|
|
)
|
|
|
|
)
|
2023-06-28 09:14:23 -04:00
|
|
|
|
|
|
|
============================
|
|
|
|
Nested condition [condition]
|
|
|
|
============================
|
|
|
|
if(A)
|
|
|
|
if(A)
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
(source_file
|
|
|
|
(if_condition
|
|
|
|
(if_command
|
|
|
|
(if)
|
2023-06-28 10:33:56 -04:00
|
|
|
(argument_list
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
)
|
2023-06-28 09:14:23 -04:00
|
|
|
)
|
|
|
|
(body
|
|
|
|
(if_condition
|
|
|
|
(if_command
|
|
|
|
(if)
|
2023-06-28 10:33:56 -04:00
|
|
|
(argument_list
|
|
|
|
(argument (unquoted_argument))
|
|
|
|
)
|
2023-06-28 09:14:23 -04:00
|
|
|
)
|
|
|
|
(body)
|
|
|
|
(endif_command (endif))
|
|
|
|
)
|
|
|
|
)
|
|
|
|
(endif_command (endif))
|
|
|
|
)
|
|
|
|
)
|