Is there a way to get a list of user-defined variables that have a specified prefix? For example:
set(vars_MyVar1 something)
set(vars_MyVar2 something)
getListOfVarsStartingWith(vars_)
?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The function
getListOfVarsStartingWithcan be written in the following way:The functions uses the CMake function
string(REGEX MATCHALLto compute all matched variable names without a loop. Here is a usage example:If the search should only return cache variables, use the following function:
This function queries the
CACHE_VARIABLESproperty and also makes sure that cache variables of typeSTATIC, which are used by CMake internally, are not returned.