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
.
Keywords¶
In addition to the common plugin and sources keywords, this plugin provides the following plugin-specific keywords:
cmake-parameters¶
Type: list of strings Default: []
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
dependant 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
cmake
in 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-parameters
that might have been set.cmake --build
is run to build the source,cmake
itself takes care of callingmake
orninja
;cmake
calls theinstall
target withDESTDIR
set to$CRAFT_PART_INSTALL
.
Examples¶
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