Fix Cmake, modify behavior depending on platform