[cmake] Fixes headercheck for modules in a directory path with special characters.

Using variables as part of regex does not work with special characters.
Therefore previously the headercheck failed during configure if e.g.
the modules were located in $HOME/C++/. This patch fixes this by not
using regex to strip the location of the modules from the path any more.

This log message was amended by the pusher.