CMake is shipped with broken PosgreSQL script in most distros. I had to copy this script and patch it to properly support new versions of PostgreSQL.