Detect fmemopen() availability with cmake

This helps a lot on e.g. FreeBSD where fmemopen() was introduced this year and some FreeBSD branches support it and others do not.