8.29. CMake 4.3.2
Bootstrap and install CMake in the final target environment without requiring an existing target CMake.
Input assumption: cmake-4.3.2.tar.gz is already present in /sources from the chapter 4 source staging step.
Source URL: https://github.com/Kitware/CMake/releases/download/v4.3.2/cmake-4.3.2.tar.gz
Upstream build note: upstream documents the Unix source build as ./bootstrap, make, and make install. The bootstrap script creates a temporary CMake first, so this section does not require an existing target cmake.
License note: the CMake source tree is BSD-3-Clause. The tarball also contains bundled third-party code and license texts; this section disables the Qt GUI and uses the already installed system curl, zlib, liblzma, and libarchive libraries to avoid building the bundled copies of those components.
Licenses:
- BSD-3-Clause
Dependencies:
- musl (libc)
- samurai (ninja)
- C++ compiler
- ncurses
- curl
- zlib-ng
- xz
- libarchive
CMake is a cross-platform build-system generator and project configuration tool. we need it to provide the final target cmake, ccmake, ctest, and cpack commands for packages that use CMake build definitions.
Extract and Enter the Source Tree
cd /sources
rm -rf cmake-4.3.2
tar -xf cmake-4.3.2.tar.gz
cd cmake-4.3.2
Bootstrap CMake
CC=/system/binaries/cc CXX=/system/binaries/c++ ./bootstrap \
--prefix=/system \
--bindir=binaries \
--datadir=share/cmake-4.3 \
--docdir=documentation/cmake \
--mandir=documentation/man-pages \
--parallel="$LWI_MAKE_JOBS" \
--no-qt-gui \
--no-system-libs \
--system-curl \
--system-zlib \
--system-liblzma \
--system-libarchive \
--generator=Ninja \
-- \
-DCMAKE_BUILD_TYPE=Release \
-DBUILD_TESTING=OFF
Build CMake
ninja $LWI_MAKE_FLAGS
Install CMake
ninja install
Verify CMake
cmake --version
ccmake --version
ctest --version
cpack --version
/sources if you do not plan to rebuild CMake again.
Command Explanations
rm -rf cmake-...andtar -xf: Recreate a clean CMake source tree.CC=/system/binaries/cc CXX=/system/binaries/c++ ./bootstrap: Bootstraps CMake with the target C and C++ compilers.--prefix=/systemand directory options: Install CMake into the book's layout.--parallel="$LWI_MAKE_JOBS": Uses the configured job count during bootstrap.--no-qt-gui: Skips the Qt GUI frontend.--system-curland related system options: Prefer already installed target libraries where selected by the page.ninja $LWI_MAKE_FLAGSandninja install: Build and install CMake with Ninja.cmake --version,ccmake --version,ctest --version, andcpack --version: Verify the installed CMake tool suite.