In cmake, how can I check if a token is included on another line?
In my case, I would like to know if the compiler name contains the string "Clang" (for example, "clang", "AppleClang", ...). All I could do so far:
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") ... elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "AppleClang") ...
I need a more flexible approach, like checking for substring.
This is what I can find in the documentation:
if (MATCHES regex) True if the given value of the string or variables matches the given regular expression. if (LESS) True if the given value of the string or variables is a valid number and less than the right.
if (BIG) True if the given value of the string or variables is a valid number and greater than the right.
if (EQUAL) True if the given value of the string or variables is a valid number and is equal to the value on the right.
if (STRLESS) True if the given value of the string or variables is lexicographically less than the string or variable on the right.
if (STRGREATER) True if the given value of the string or variables is lexicographically larger than the string or variable on the right.
if (STREQUAL) True if the given value of a string or variables is lexicographically equal to the string or variable on the right.
string cmake string-comparison
Pietro
source share