Browse documentation

Build and package a C++ project

This tutorial builds a C++ project with CMake, publishes CTest results, and generates an installable package.

The project must register tests with CTest and generate CPackConfig.cmake. Omit the corresponding action when the source project does not provide that capability.

Pipeline graph

clone -> cmake_build -> cmake_test -> package

Configure the actions

Git Clone

Set the repository URL and use source as the target directory.

CMake Build

Set source directory to source, build directory to build, generator to Ninja, and build type to Release.

CMake Test

Set build directory to build and report file to build/test-results/ctest.xml.

CPack Package

Set configuration to build/CPackConfig.cmake and choose DEB, TGZ, or another supported generator.

ICE-1.0.0
codinamo >= 1.0.0

@pipeline {
    name: "cpp-build"
    description: "Build a CMake application"
    environment: "default"
    continueOnError: false

    @actions {
        clone: action.GIT_CLONE({
            params: {
                repositoryUrl: "https://example.com/team/application.git",
                targetDirectory: "source"
            }
        })
        cmake_build: action.CMAKE_BUILD({
            params: {
                buildDir: "build",
                buildType: "Release",
                generator: "Ninja",
                sourceDir: "source"
            }
        })
        cmake_test: action.CMAKE_TEST({
            params: {
                buildDir: "build",
                outputOnFailure: true,
                reportFile: "build/test-results/ctest.xml"
            }
        })
        package: action.CPACK_PACKAGE({
            params: {
                configFile: "build/CPackConfig.cmake",
                generator: "DEB",
                packageDirectory: "dist/packages"
            }
        })
    }

    @flow {
        clone -> cmake_build -> cmake_test -> package
    }
}

CMAKE_TEST sends its JUnit summary to the run page. CPACK_PACKAGE exports package_file, package_files, and package_directory, allowing a later S3 or Bunny Storage action to upload the generated artifact.