Reorganize cmakelists and fix windows build