Conditional Blocks
Let's learn about logical operators, conditional blocks, and control structures.
The CMake Language wouldn't be complete without control structures! Like everything else, they are provided in the form of a command, and they come in three categories:
Conditional blocks
Loops
Command definitions
Control structures are executed in scripts and during buildsystem generation for projects.
if()
conditional block
The only conditional block supported in CMake is the humble if()
command. All conditional blocks have to be closed with an endif()
command, and they may have any number of elseif()
commands and one optional else()
command in this order:
Get hands-on with 1400+ tech skills courses.