Build CMake from dev sources
While CMake binaries can be downloaded for most platforms, there are certain cases where one wishes to build CMake from source. For example, when preparing a merge request to fix or enhance CMake. Usually the computer will have at least an older version of CMake that can be used. If so, we recommend using CMake to build the newer CMake, from the CMake source directory. We recommend using Ninja in general for faster build and rebuild for any CMake project.
cmake -B build -DBUILD_TESTING:BOOL=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_USE_OPENSSL:BOOL=ON --install-prefix=$HOME/cmake-dev
cmake --build build
cmake --install build
It’s easier to simply use the build_cmake.cmake script.
If an old CMake isn’t available on the computer, then use CMake bootstrap:
./bootstrap --prefix=$HOME/local/cmake-dev --parallel=4 -- -DBUILD_TESTING:BOOL=OFF -DCMAKE_BUILD_TYPE:STRING=Release -DCMAKE_USE_OPENSSL:BOOL=ON
make -j4
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 install