What does "modern CMake" mean in a C++ job ad?

What employers mean by "modern CMake": target-based builds, PUBLIC and PRIVATE dependencies, and presets, with short examples of each.

  • cmake
  • build systems
  • careers

When a C++ job ad asks for "modern CMake", it means you describe a build in terms of targets and their usage requirements, not global variables and compiler flags. In practice that is three skills: defining libraries with target_* commands, choosing between PUBLIC, PRIVATE and INTERFACE when linking, and sharing build configurations through CMakePresets.json.

Employers write it because they have felt the opposite. A build held together by include_directories(), link_libraries() and hand-edited CMAKE_CXX_FLAGS works until the project grows, then every change risks breaking a target on the other side of the tree. The examples below build one small library, geometry, the modern way.

What is a target-based CMake build?

A target is something CMake builds, such as a library or an executable, together with everything needed to compile and use it. Instead of setting include paths and flags for a whole directory, you attach them to the target that needs them:

CMakeLists.txt
cmake_minimum_required(VERSION 3.21)
project(geometry VERSION 1.0 LANGUAGES CXX)
 
add_library(geometry src/transform.cpp)
target_include_directories(geometry PUBLIC include)
target_compile_features(geometry PUBLIC cxx_std_20)
target_compile_options(geometry PRIVATE
  "$<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-Wall;-Wextra;-Wpedantic>"
  "$<$<CXX_COMPILER_ID:MSVC>:/W4>"
)
 
add_executable(viewer app/main.cpp)
target_link_libraries(viewer PRIVATE geometry)

Three details are what an interviewer looks for here:

  • target_compile_features(... cxx_std_20) asks for C++20 without hard-coding -std=c++20, so the same file works with GCC, Clang and MSVC.
  • The warning flags are wrapped in generator expressions, so each compiler only gets the flags it understands. They are PRIVATE because they concern how geometry itself is compiled, not the code that uses it.
  • viewer never mentions include/. Linking to geometry is enough, because the include directory and the C++20 requirement are PUBLIC and travel with the library.

What do PUBLIC, PRIVATE and INTERFACE mean in target_link_libraries?

This is the question that separates people who have used modern CMake from people who have read about it. The keyword says who needs a dependency:

  • PRIVATE: only the target's own source files use it.
  • PUBLIC: the target uses it, and so does any code that includes the target's headers.
  • INTERFACE: the target itself does not use it, but its consumers do. Header-only libraries are the usual case.

Suppose geometry uses Eigen for its matrix types and fmt to format text internally:

CMakeLists.txt (continued)
find_package(Eigen3 3.4 REQUIRED NO_MODULE)
find_package(fmt REQUIRED)
 
target_link_libraries(geometry
  PUBLIC Eigen3::Eigen # appears in geometry's public headers
  PRIVATE fmt::fmt     # used only inside src/transform.cpp
)

The reason Eigen is PUBLIC is visible in the library's header:

include/geometry/transform.hpp
#pragma once
 
#include <string>
 
#include <Eigen/Dense>
 
namespace geometry {
 
// Eigen types appear in this public header, so every file that includes it needs Eigen's
// include path as well. PUBLIC passes that requirement on to viewer.
Eigen::Matrix3d rotation_z(double radians);
 
// Implemented with fmt in transform.cpp. Callers only see std::string, so fmt stays PRIVATE.
std::string describe(const Eigen::Matrix3d& m);
 
}  // namespace geometry

Getting this wrong fails in both directions. Mark Eigen PRIVATE and viewer stops compiling as soon as it includes transform.hpp. Mark fmt PUBLIC and every consumer gets an include path and a link dependency it never asked for, which slows builds and leaks implementation details. On a large codebase, accurate visibility is what keeps incremental builds fast and dependency graphs honest.

Why do teams use CMake presets?

Before presets, every developer kept their own notes on how to configure the project: which generator, which build type, which cache variables. Continuous integration had its own copy, and the copies drifted. CMakePresets.json puts those configurations in the repository:

CMakePresets.json
{
  "version": 3,
  "configurePresets": [
    {
      "name": "dev",
      "displayName": "Debug build for development",
      "binaryDir": "${sourceDir}/build/dev",
      "cacheVariables": {
        "CMAKE_BUILD_TYPE": "Debug",
        "CMAKE_EXPORT_COMPILE_COMMANDS": "ON"
      }
    },
    {
      "name": "release",
      "displayName": "Optimised release build",
      "binaryDir": "${sourceDir}/build/release",
      "cacheVariables": {
        "CMAKE_BUILD_TYPE": "Release"
      }
    }
  ],
  "buildPresets": [
    { "name": "dev", "configurePreset": "dev" },
    { "name": "release", "configurePreset": "release" }
  ]
}

Now cmake --preset dev followed by cmake --build --preset dev gives every developer and every CI job the same build. IDEs such as Visual Studio, CLion and VS Code with the CMake Tools extension read the same file. CMAKE_EXPORT_COMPILE_COMMANDS writes the compile_commands.json that clangd and clang-tidy rely on, which is often the real reason a team adopted presets. Personal tweaks belong in CMakeUserPresets.json, which stays out of version control.

What else can "modern CMake" cover?

Depending on the team, the phrase can stretch further. Ask in the interview, but expect some of these:

  • Dependency management with find_package, FetchContent, or a package manager such as vcpkg or Conan.
  • Installing and exporting targets with install(EXPORT ...), so other projects can use your library through find_package and get its usage requirements for free.
  • Testing with enable_testing(), add_test() and CTest, often wired into presets as well.
  • Cross-compilation with toolchain files, which matters in embedded roles.

What employers rarely mean is memorising every command. They want someone who can open an unfamiliar CMakeLists.txt, see which target owns which requirement, and change it without breaking the rest of the build.

How do you show modern CMake skills to an employer?

The most convincing evidence is a project they can read. A small library on GitHub with a target-based build, correct visibility keywords, presets and a CI workflow says more than a line on a CV. In an interview, be ready to explain why a dependency is PUBLIC rather than PRIVATE; it is a short question with a revealing answer.

If build systems are the part of C++ you enjoy most, look at build and tooling roles on the board, or browse all C++ jobs and check each ad's requirements. To hear about new roles without checking back, set up a job alert.