The cmake plugin

The cmake plugin is useful for building CMake-based parts. This plugin uses the common plugin keywords as well as those for sources. For more information, see Snapcraft parts metadata.

This plugin also supports options from the make plugin.

A cmake project will typically include a CMakeLists.txt file to drive the build, and the plugin requires that CMakeLists.txt exists within the root of the source tree.

Plugin-specific features and syntax are dependent on which base is being used, as outlined below:

For a simple example, see MOOS applications, or search GitHub for projects already using the plugin.

This is a snapcraft plugin. See Snapcraft plugins and Supported plugins for further details on how plugins are used.

base: core22

  • cmake-generator (string, default: Unix Makefiles) Determine what native build system is to be used. Can be either Ninja or Unix Makefiles (default).
  • cmake-parameters (list of strings) Configure flags to pass to the build using the common cmake semantics.

Note that Snapcraft does not specify cmake parameters by default. A common parameter for parts using the cmake plugin is CMAKE_INSTALL_PREFIX=/usr - this prevents installation to the default directory of /usr/local. For example:

parts:
  hello:
    plugin: cmake
    cmake-parameters:
      - -DCMAKE_INSTALL_PREFIX=/usr
    ....

Requires Snapcraft version 7.0+.

base: core20

  • cmake-generator (string, default: Unix Makefiles) Determine what native build system is to be used. Can be either Ninja or Unix Makefiles (default).
  • cmake-parameters (list of strings) Configure flags to pass to the build using the common cmake semantics.

Note that Snapcraft does not specify cmake parameters by default. A common parameter for parts using the cmake plugin is CMAKE_INSTALL_PREFIX=/usr - this prevents installation to the default directory of /usr/local. For example:

parts:
  hello:
    plugin: cmake
    cmake-parameters:
      - -DCMAKE_INSTALL_PREFIX=/usr
    ....

Requires Snapcraft version 4.0+.

base: core18 | core

  • configflags (list of strings) Configure flags to pass to the build using the common cmake semantics.

Requires Snapcraft version 3.0+.


Last updated a month ago.