We often find such a platform-independent script handy for CI or for helping end users get a new-enough CMake. It can also be used to install older specific CMake versions for CI testing of minimum CMake versions.
We have a more elaborate and general script that handles older CMake versions at cmakeutils under scripts/install_cmake.cmake. This script here is intentionally very minimal and does little error checking.
cmake -Dversion=<cmake version to install> -P install_cmake.cmake