Add a CMake file and mostly fix compilation on windows