The string() command
The string()
command is used to manipulate strings. It comes with a variety of modes that perform different actions on the string: search and replace, manipulation, comparison, hashing, generation, and JSON operations (the last one available since CMake 3.19).
Full details can be found in the online documentation: https://cmake.org/cmake/help/latest/command/string.html.
string()
modes that accept the <input>
argument will accept multiple <input>
values and concatenate them before the execution of the command:
string(PREPEND myVariable "a" "b" "c")
This is the equivalent of the following:
string(PREPEND myVariable "abc")
Let's explore all available string()
modes.
Search and replace
The following modes are available:
string(FIND <haystack> <pattern> <out> [REVERSE])
searches for<pattern>
in the<haystack>
string and writes the position found as...