cmake: fix fragile code related to HAVE_FORK macro

* report from Richard Newton indicated previous solutions was not
  working on Windows
Merge pull request #936 from soundart/master

cmake: fix test_fork,  fix fragile code related to HAVE_FORK macro