Installing VTK in Ubuntu 18.04

Tip for anyone out there who needs to build an older VTK version and get the error cc: error: ARGS: No such file or directory: This error seems to come from variable _gcc_version. You need to modify the REGEX MATCH above the _gcc_version line for each cmake file which raises the error. I did it by adding more digits to the regex, like so:
string(REGEX MATCH "[3456789]\\.[0-9]\\.[0-9]*"
I was able to compile VTK 6.2.0 on Ubuntu 20.04 this way.