Use custom CMake scripts for checking compiler flags.
These scripts were copied from CMake 2.8.10.2 and the "normalizing
locale" patch was applied. This allows us to keep the CMake minimum
version while fixing a couple of bugs related to old CMake scripts.