Pack CMake - BredaUniversityGames/JenkinsLib GitHub Wiki
Packages build output using CPack. Supports both preset-based packaging (from CMakePresets.json) and manual CPack invocation using the build context.
With presets:
stages {
git.sync()
cmake.build()
cmake.pack()
// ...
}Standalone (configures and builds automatically if needed):
stages {
git.sync()
cmake.pack()
// ...
}Manual mode (no presets):
stages {
git.sync()
cmake.build()
cmake.pack()
// ...
}When CMakePresets.json contains packagePresets:
| Parameter | Default | Description |
|---|---|---|
CMAKE_PACKAGE_PRESET |
(first preset) | CPack preset (dropdown populated from CMakePresets.json) |
When no package presets are found:
| Parameter | Default | Description |
|---|---|---|
CMAKE_CPACK_GENERATOR |
ZIP |
CPack generator (ZIP, NSIS, WIX, NuGet, 7Z, TGZ) |
CMAKE_CPACK_ARGS |
(empty) | Additional CPack arguments |
Note: In manual mode,
cmake.pack()requirescmake.build()to run first so it can read the build directory and configuration from context.
- Looks up the package preset's
configurePresetinCMakePresets.json - If the package preset's configure preset differs from the build preset's configure preset (or no build was run), automatically runs configure + build
- Matches the package preset's
configurationslist (e.g.,["Release"]) against available build presets to build only the required configurations - Runs
cpack --preset <preset>
- Reads
ctx.cmakeBuildDirandctx.buildConfigfrom the build stage context - Runs
cpack -G <generator> -B <buildDir>/_packages -C <config>
When cmake.pack() is used without a preceding cmake.build(), the pack stage automatically configures and builds the project using the package preset's configurePreset. Only build presets matching the package preset's configurations are built, avoiding unnecessary work.
| Issue | Solution |
|---|---|
| "requires cmake.build() to run first" | In manual mode, add cmake.build() before cmake.pack()
|
| "CPack project name not specified" | The project was not configured before packing; ensure cmake.build() runs first or that your package preset has a valid configurePreset
|
| No package preset dropdown | Ensure your CMakePresets.json contains non-hidden packagePresets
|
| "has no configurePreset defined" | Add a configurePreset field to your package preset in CMakePresets.json
|
| "No build preset found for configure preset" | Ensure a buildPreset exists that references the same configurePreset and matches the required configurations
|