After a night -- literally a night's fight with the compiler, I finally got rid of CMake.
It all started a short time ago. When I first got this Macbook Pro, I decided to search for some "necessary complements". I found Homebrew. I played with it quite happily and it helped me a bit. At that time my only brew was "gcc-4.7", a replacement of the extremely old gcc-4.2 provided with Xcode.
Unfortunately later when I tried to gdb the code from my Data Structure course, I found it troublesome. I couldn't compile with gcc-4.7 then use default gdb. So, when I decided to go back to the default gcc, I thought, "as long as the default is enough, maybe homebrew is out of necessary."
The previous night has proved me wrong. Software managers should always be the first to be installed and the last to be removed.
The first issue was on libgit2. When I reinstalled Homebrew, ran brew doctor, Unexpected dylib came into my way. I didn't just remove the file warned; I knew I would change to homebrew version. But nothing online showed me how to uninstall it. So I opened an issue and luckily, @vmg helped me out (Thank you @vmg!). I had to find the list of installed files and remove them manually. They were in several folders and I removed them with ease.
Then I brewed MacVim. I was using the default vim but recently found a standalone editor more comfortable. Before the install really started, Homebrew automatically brewed CMake as it is a prerequisite, but failed to link it because I built one before. MacVim was still installed successfully.
"OK," I thought, "I'll uninstall CMake and change to homebrew version as well." This time I was really on my own. No document of CMake ever mentions uninstallation, no issue page in the github page of CMake, no local help.
Directly running cmake uninstall gave me error message about the file CMakeCache.txt. "Nonsense," I thought. make uninstall didn't work either. Noticing the existence of cmake_uninstall.cmake, I knew there's a uninstall target to use.
Upon scrutinizing the bootstrap script used to build the compiler, I was finally clear of confusion. "That's neat, " I said to myself silently, "compile a unlinked copy to run, then compile itself." To make a try, I reran the script. I met the cache error again. With the copy of tarball I reserved, I confirmed it was safe to delete CMakeCache.txt. Second try went smoothly, and with the bootstrapped CMake, I executed cmake uninstall.
Then I met Permission Denied. OK, add sudo to the beginning and run again.
brew link cmake succeeded later.