Rewriting some cmake codes to add support for the ninja generator on windows