Use CMake as build orchestrator
03:46 15 Jan 2026

I want to build a Yocto build and use CMake as build orchestrator.

That means, CMake is supposed to:

  • Take a preset and other variables via command line

  • Write the configuration files (with configure_file)

  • Trigger the build(s) with 'add_custom_target'

All of that works.

My primary issue at this juncture is, that CMake requires a toolchain to perform its configuration.Yocto, on the other hand, builds its own toolchain, which CMake doesn't, and shouldn't, know about.

The way I see it, these are my options:

  • Do not use CMake, but a different trigger like bash or python

    • Advantages:

      • No toolchain required
    • Disadavantages:

      • Preset information needs to be parsed manually.

      • Second source for build information.

  • Use CMake in script mode

    • Advantages:

      • All required information are in cmake
    • Disadvantages

      • Presets probably don't work either.
  • Use the 'system toolchain' for configuration only.

    • Advantages:

      • Regular cmake project

      • Presets are available and parsed readily.

      • Build can be triggered with --target

    • Disadvantages:

      • If, for whatever reason, a different target was executed, it would be built with the wrong toolchain.

I would really like to use CMake as 'single source of truth' for all build information, but the necessity of having a toolchain ready worries me a little.

Are there any best practices or even just opinions regarding my problem?

cmake build