DEV Community

Cover image for CMake Architecture
Kaa Mi
Kaa Mi

Posted on

3

CMake Architecture

INTRODUCTION

Project CMake started in 1999 with a goal to replace autoconf/libtool as a build system for C/C++ projects. It evolved into an extensive toolkit with the following use case:

  • CMake: build tool
  • CTest: test driver tool for running regression tests
  • CPack: packaging tool to create platform-specific installers
  • CDash: web app for displaying testing results

CMake can generate Makefiles for UNIX-based systems and VSStudio Project Files for Windows etc. The only dependency for CMake is C/C++ compiler. It can generate static libraries, shared libraries, executables, and plugins.

Key Features:
  • Build tree is kept separate from the source tree.
  • Focus is shifted to program to system features and not to the system itself.
  • From a user's perspective, there are two steps:
    User View

    • configure: create internal representation of build
    • generate: actual build files are created

To avoid setting up the ENVIRONMENT VARIABLES every time, CMakeCache.txt is generated for all persistent variables. Additional CMakeLists.txt can be parsed by using include and add_subdirectory pattern and having CMakeLists.txt in them. One can have custom targets.

  • Parser for CMakeLists.txt calls yacc/lex for CMake language. yacc/lex files are kept in source under version control to build CMake.
  • From architecture perspective, CMake is a Object Oriented System with following class hierarchy.

Code Architecture

REFERENCES:

  1. CMake: Architecture of Open Source Applications, Bill Hoffman and Kenneth Martin, https://www.aosabook.org/en/cmake.html
  2. Header Image: https://www.pexels.com/photo/arch-architecture-art-building-415574/

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs