Skip to content

CMake Build

This Composite Action installs then builds a CMake project.

CMake Run and Build Composite Action

- uses: Yellow-Dog-Man/composite-actions-templates/.github/actions/cmake-build@main
  with:
    outdir: (1)
    working-dir: (2)
  1. Output directory of the build

  2. Working directory for the build

Will install CMake then build the current project with it.

Inputs: ยค

Name Description Default
outdir

Output directory of the build

cmake-version

Version of CMake to install and use

latest
working-dir

Working directory for the build

cmake-args

Additional arguments to pass to cmake

build-cores

How many cores to use during compilation

4
Source of Yellow-Dog-Man/composite-actions-templates/.github/actions/cmake-build@main
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
name: 'CMake Run and Build Composite Action'
description: 'Will install CMake then build the current project with it.'

inputs:
  outdir:
    description: 'Output directory of the build'
    required: true
  cmake-version:
    description: 'Version of CMake to install and use'
    required: false
    default: 'latest'
  working-dir:
    description: 'Working directory for the build'
    required: true
  cmake-args:
    description: 'Additional arguments to pass to cmake'
    default: ''
    required: false
  build-cores:
    description: 'How many cores to use during compilation'
    # Only change this value on self-managed runners
    # Default GitHub runners only 4 cores
    default: '4'
    required: false

runs:
  using: composite
  steps:
    - name: 'Install CMake'
      uses: lukka/get-cmake@latest
      with:
        cmakeVersion: ${{ inputs.cmake-version }}

    - name: 'Make working directory'
      shell: bash
      run: mkdir ${{ inputs.working-dir }}

    - name: 'Run CMake build'
      working-directory: ${{ inputs.working-dir }}
      shell: bash
      run: cmake ${{ inputs.cmake-args }} ..

    - name: 'Build solution via CMake'
      working-directory: ${{ inputs.working-dir }}
      shell: bash
      run: make -j${{ inputs.build-cores }}