CMake plugin¶
The CMake plugin configures projects using CMake and builds them either using GNU Make or Ninja.
After a successful build, this plugin will install the generated binaries in
$CRAFT_PART_INSTALL.
Keys¶
This plugin provides the following unique keys.
cmake-parameters¶
Type: list of strings
Parameters to configure the project using common CMake semantics.
cmake-generator¶
Type: string
Default: “Unix Makefiles”
Determine the tool to use to build. Can be either set to Ninja or Unix
Makefiles.
Environment variables¶
The plugin sets the CMAKE_PREFIX_PATH to the stage directory.
Dependencies¶
The CMake plugin needs the cmake executable to configure, and make or ninja
executable to build. make and ninja are dependent on the selected
cmake-generator. These dependencies are provided by the plugin as a
build-packages entry.
The plugin also sets up gcc. Other compiler or library dependencies the source
requires to build are to be provided.
How it works¶
During the build step the plugin performs the following actions:
Run
cmakein the build directory referring to the pulled source directory (this plugin runs an out of tree build). The preferred generator is set at this stage, and the project is configured with anycmake-parametersthat might have been set.cmake --buildis run to build the source,cmakeitself takes care of callingmakeorninja.cmakecalls theinstalltarget withDESTDIRset to$CRAFT_PART_INSTALL.
Example¶
The following snippet declares a part using the cmake plugin. It sets the
CMAKE_BUILD_TYPE to RelWithDebInfo to generate debug symbols from the build:
parts:
hello:
source: .
plugin: cmake
cmake-parameters:
- -DCMAKE_BUILD_TYPE=RelWithDebInfo