set(LLVM_EXECUTABLE_REGEX [[^([^.]*|[^.]*\.lld)\.exe$]]) foreach(el "bugpoint.exe" "ld.lld.exe" "asdf.dll" "asdf") message(STATUS "Matching ${el}") if(el MATCHES "${LLVM_EXECUTABLE_REGEX}") message(STATUS "Matching ${el} - match (${CMAKE_MATCH_1}).") else() message(STATUS "Matching ${el} - no match.") endif() endforeach()