Install packages libpetsc3.1 and libpetsc3.1-dev. Newer version may be available. In Ubuntu 6.06 (Dapper) or newer, you can use the Synaptic package manager for that, or type:
sudo apt-get install libpetsc3.1 libpetsc3.1-dev
Now go to the directory with Hermes. Create the file CMake.vars with the following line (or append to the existing one):
rm CMakeCache.txt cmake . make
Find more about Using PETSC in Hermes.