Replace regex implementation using C++11
CMake's current regex infrastructure is based on an ancient third-party implementation and has some limitations:
- Capture groups limited to about 10.
- Slow, as discussed on the dev list in Nov 2011: slow regex implementation in RegularExpression.
- Matching needs a lot of stack space (#17659 (closed), #17924).
- Only recently made thread-safe by utils/kwsys!72 (merged).
Fortunately we now use C++11 which provides the <regex>
feature. We should investigate using it as a replacement.
The main challenge is compatibility. I'm not sure whether any of the standard regex syntax modes exactly matches CMake's regex syntax. Since it is public-facing, the regex syntax must be preserved. Therefore we must choose one of the standard regex syntax modes along with an input expression transformation to make the semantics exactly match.