Fix conflicts in CMAKE_GENERATOR and generator (#30971)
Summary:
...specified in -G
https://cmake.org/cmake/help/latest/variable/CMAKE_GENERATOR.html
According to the document, the generator could be determined through two methods:
1. Specify in `-G`
2. Read from `CMAKE_GENERATOR`
We should avoid conflicts in these two methods. This fixes https://github.com/pytorch/pytorch/issues/30910.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/30971
Differential Revision: D18927529
Pulled By: mingbowan
fbshipit-source-id: e9a179ceb32d6fbabfaeac6cfe9e6170ca170b20