Cmake: Fix build issues

Fixes the build issues discussed and detailed in [this comment](https://github.com/Homebrew/homebrew/issues/29988#issuecomment-57258985) in #29988.
Apparently not. It seems to occur most frequently when there's a new OS X release, but the linked discussion is about this issue on 10.9 on 2014-03-31 so it looks like we need the fix for every version, recent or otherwise.