This is how to build CMake from source.
./bootstrap --prefix=~/.local/cmake-dev --parallel=2 -- -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_USE_OPENSSL:BOOL=ON make -j -l2 make install
The OpenSSL flag is particularly important for CMake use connecting to the internet.
This puts the compiled CMake under ~/.local/cmake-dev, without disturbing the primary CMake install. Upon making any CMake code changes, simply recompile the minimum needed bits by:
make make install
Run the CMake self-tests by:
~/.local/cmake-dev/bin/ctest --parallel 2 --output-on-failure