[CMake] Matching with two strngs

Nils Gladitz nilsgladitz at gmail.com
Thu Jun 5 05:01:37 EDT 2014


On 06/05/2014 10:46 AM, abid rahman wrote:
> For example, I want to check if a string is either "abc" or "xyz". How
> can I check it?
>
> IF(string1 MATCHES "abc\|xyz" doesn't work?

For the exact string (not substring):

   if(string1 MATCHES "^(abc|xyz)$")

Or without regex:

   if(string1 STREQUAL abc OR string1 STREQUAL xyz)

Nils


More information about the CMake mailing list