test: add a test for clearing regex results
cmMakefile: store the number of last matches in a CMake var

With PushScope and PopScope, keeping track of another bit of data for
each scope isn't easy. Instead, store it as another CMake variable so it
gets implicitly tracked along with everything else.

This works in a revert of commit
7d674b5f0b28a610333644d417c2e8cb796cc9e4.
Merge topic 'cached-regex-clear-fixed' into next

ae676e46 cmMakefile: store the number of last matches in a CMake var
789d893a test: add a test for clearing regex results