Fix quirks in CMake build on Mac and Windows