Skip to content
川流不息
Go back

CMake History and Architecture (Chinese Translation Notes)

The Chinese version of this post is my translation of the CMake chapter by Bill Hoffman and Kenneth Martin in The Architecture of Open Source Applications. English readers should read the original chapter, CMake, directly. This page summarizes what it covers.

What the Chapter Covers

History and goals. In 1999 the US National Library of Medicine hired Kitware to build a better way to configure, build and deploy complex software across platforms, as part of the Insight Segmentation and Registration Toolkit (ITK). Projects at the time kept a configure script and Makefiles for Unix alongside Visual Studio project files for Windows. The authors’ earlier attempts at a unified system (VTK’s pcmaker, TargetJr’s gmake-based system) forced Windows developers onto the command line. CMake was designed around a few constraints:

How it works. CMake runs in two phases. The configure step reads CMakeCache.txt and executes the project’s CMakeLists.txt files, building an in-memory model of targets (cmTarget objects held in a tree of cmMakefile objects). The generate step turns that model into build files for the chosen tool, either IDE projects or Makefiles. Every language command is a cmCommand subclass that carries its own documentation. For Makefile builds, CMake tracks dependencies itself in depend.make, flags.make, build.make and DependInfo.cmake.

The wider toolset. CTest runs regression tests and reports results to CDash. CPack drives native packagers (NSIS, RPM, .deb, tarballs). Qt and curses GUIs edit the cache. CMake itself is developed with continuous integration built on the same tools.

Lessons learned. Backward compatibility is sacred, which led to the policy system in CMake 2.6. In hindsight, an existing embedded language such as Lua would have been better than a home-grown one. C plugins proved hard to keep compatible. Keeping the exposed API small avoids long-term maintenance costs.

For the full text, see the original chapter. The Chinese translation is on this blog.


Share this post:

Previous Post
A Road Trip Through Tibet, 2023
Next Post
Dual-Stack Access to a Home Network