Reduce CMake requirement to 2.8.7.

Copy some macros from the 2.8.8 tag of cmake if using 2.8.7.