OS X compatibility fixes

Code fixes for compatibility with OS X, see https://github.com/minetest/minetest/issues/1242. I have tested this on OS X and Linux.
It already is the last "install" entry in CMakeLists.txt, so I'm not sure what you want me to change here. Or did you mean "if(NOT APPLE AND UNIX)" here?