mirror of
https://github.com/threeal/cmake-action.git
synced 2025-04-22 11:31:21 +00:00
74 lines
2.2 KiB
YAML
74 lines
2.2 KiB
YAML
name: CMake Action
|
|
description: Configure and build CMake project
|
|
author: Alfi Maulana
|
|
branding:
|
|
color: gray-dark
|
|
icon: terminal
|
|
inputs:
|
|
source-dir:
|
|
description: The source directory of CMake project
|
|
required: false
|
|
default: .
|
|
build-dir:
|
|
description: The build directory of CMake project
|
|
required: false
|
|
default: build
|
|
targets:
|
|
description: List of build targets
|
|
required: false
|
|
generator:
|
|
description: The build system generator of the CMake project
|
|
required: false
|
|
c-compiler:
|
|
description: The preferred executable for compiling C language files
|
|
required: false
|
|
cxx-compiler:
|
|
description: The preferred executable for compiling CXX language files
|
|
required: false
|
|
args:
|
|
description: Additional arguments passed during CMake configuration
|
|
required: false
|
|
runs:
|
|
using: composite
|
|
steps:
|
|
- name: Process inputs
|
|
shell: bash
|
|
run: |
|
|
ARGS="${{ inputs.source-dir }} -B ${{ inputs.build-dir }}"
|
|
BUILD_ARGS="--build ${{ inputs.build-dir }}"
|
|
if [ -n '${{ inputs.targets }}' ]; then
|
|
BUILD_ARGS="$BUILD_ARGS --target ${{ inputs.targets }}"
|
|
fi
|
|
if [ -n '${{ inputs.generator }}' ]; then
|
|
ARGS="$ARGS -G ${{ inputs.generator }}"
|
|
fi
|
|
if [ -n '${{ inputs.c-compiler }}' ]; then
|
|
ARGS="$ARGS -D CMAKE_C_COMPILER=${{ inputs.c-compiler }}"
|
|
fi
|
|
if [ -n '${{ inputs.cxx-compiler }}' ]; then
|
|
ARGS="$ARGS -D CMAKE_CXX_COMPILER=${{ inputs.cxx-compiler }}"
|
|
fi
|
|
if [ -n '${{ inputs.args }}' ]; then
|
|
ARGS="$ARGS ${{ inputs.args }}"
|
|
fi
|
|
echo "CMAKE_ARGS=${ARGS//[$'\t\r\n']}" >> $GITHUB_ENV
|
|
echo "CMAKE_BUILD_ARGS=${BUILD_ARGS//[$'\t\r\n']}" >> $GITHUB_ENV
|
|
|
|
- name: Install Ninja
|
|
if: ${{ inputs.generator == 'Ninja' }}
|
|
shell: bash
|
|
run: |
|
|
case "$OSTYPE" in
|
|
darwin*) brew install ninja ;;
|
|
linux*) sudo apt install -y ninja-build ;;
|
|
*) choco install ninja ;;
|
|
esac
|
|
|
|
- name: Configure CMake
|
|
shell: bash
|
|
run: cmake ${{ env.CMAKE_ARGS }}
|
|
|
|
- name: Build targets
|
|
shell: bash
|
|
run: cmake ${{ env.CMAKE_BUILD_ARGS }}
|