cmakepp_lang/types/list
- cmakepp_lang/types/list.cpp_is_list(result str2check)
Determines if a string is lexically convertible to a CMake list.
CMake lists are strings that contain semicolons. While CMake’s list command will treat a string without a semicolon as a list with one element, for the purposes of determining if a string is a list we require that the list has at least two elements (i.e., there must be a semicolon in it). This function determines if the provided string meets this definition of a list.
- Parameters:
result (desc) – Used as the name of the returned identifier.
str2check (str) – The string whose listy-ness is being questioned.
- Returns:
result
will be set toTRUE
ifstr2check
is a list andFALSE
otherwise.- Return type:
bool
Example Usage
The following snippet shows how to determine if a variable contains a list.
include(cmakepp_lang/types/list) set(a_list 1 2 3) cpp_is_list(result "${a_list}") message("Is a list: ${result}") # Will print TRUE
Error Checking
cpp_is_list
will assert that the caller has provided exactly two arguments. If the caller has provided a different number of arguments than an error will be raised.