Search⌘ K
AI Features

The list() Command

Explore the CMake list command to understand how to read, search, modify, and order lists for efficient project management. This lesson helps you apply mutations carefully and use a wide range of list operations crucial for handling build variables in C++ projects.

This command provides basic operations on lists:

  • Reading

  • Searching

  • Modification

  • Ordering

Some modes will change the list (mutate the original value). Be sure to copy the original value if we'll need it later. Full details can be found in the online documentation.

Reading

The following modes are available:

  • list(LENGTH <list> <out>) counts the elements in the <list> variable and stores the result in the <out> variable.

  • list(GET <list> <index>... <out>) copies the <list> elements specified with the list of <index> indexes to the <out> variable. ...