changed the minimum required cmake version to 2.8.12.

This revealed some more issues which are also fixed in this patch.