[CMake] comparing strings
cmake.cmake.narkive.com › 4jrIzJjL › comparing-stringsstring (COMPARE EQUAL "$ {build_system}" windows _cmp) if (_cmp) ... endif () It will make it ugly to create a nested if else block, but it'll work. You can do if ("$ {myvar}" MATCHES "somestring") or more strict if ("$ {myvar}" MATCHES "^somestring$") Alex Shaun Williams 9 years ago Thanks, I will be using this method:
if — CMake 3.23.0-rc3 Documentation
cmake.org › cmake › helpOn non-Windows hosts, any path that begins with a tilde ( ~ ) evaluates to true. Comparisons ¶ if (<variable|string> MATCHES regex) True if the given string or variable's value matches the given regular expression. See Regex Specification for regex format. New in version 3.9: () groups are captured in CMAKE_MATCH_<n> variables.