chore: Merge pull request #46 from threeal/misc-chores

Miscellaneous Chores
This commit is contained in:
Alfi Maulana 2023-06-29 14:30:43 +07:00 committed by GitHub
commit 39b214d589
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 24 deletions

View File

@ -1,50 +1,46 @@
# CMake Action # CMake Action
[![latest version](https://img.shields.io/github/v/release/threeal/cmake-action)](https://github.com/threeal/cmake-action/releases/) [![Latest Version](https://img.shields.io/github/v/release/threeal/cmake-action)](https://github.com/threeal/cmake-action/releases/)
[![license](https://img.shields.io/github/license/threeal/cmake-action)](./LICENSE) [![License](https://img.shields.io/github/license/threeal/cmake-action)](./LICENSE)
[![test status](https://img.shields.io/github/actions/workflow/status/threeal/cmake-action/test.yml?label=test&branch=main)](https://github.com/threeal/cmake-action/actions/workflows/test.yml) [![Test Status](https://img.shields.io/github/actions/workflow/status/threeal/cmake-action/test.yml?label=test&branch=main)](https://github.com/threeal/cmake-action/actions/workflows/test.yml)
Configure, build, and test a [CMake](https://cmake.org/) project on [GitHub Actions](https://github.com/features/actions). Configure, build, and test your [CMake](https://cmake.org/) project using [GitHub Actions](https://github.com/features/actions). This action simplifies the workflow for your CMake project. It configures the build environment using the `cmake` command, builds the project using the `cmake --build` command, and optionally tests the project using the `ctest` command.
Use this action to simplify the workflow run of your CMake project.
This action will configure a build environment for your project using the `cmake` command,
then it will build your project by running a `cmake --build` command,
and last it could test your project using the `ctest` command.
## Features ## Features
- Configure and build a project using the [cmake](https://cmake.org/cmake/help/latest/manual/cmake.1.html) command. - Configures and builds a project using the [cmake](https://cmake.org/cmake/help/latest/manual/cmake.1.html) command.
- Optionally test a project using the [ctest](https://cmake.org/cmake/help/latest/manual/ctest.1.html) command. - Option to test a project using the [ctest](https://cmake.org/cmake/help/latest/manual/ctest.1.html) command.
- Auto-detect and install required dependencies. - Auto-detects and installs required dependencies.
- Specify multiple CMake options directly from the Action inputs. - Supports specifying multiple CMake options directly from the Action inputs.
## Usage ## Usage
For more information, see [action.yml](./action.yml) and [GitHub Actions guide](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions). For more information, refer to [action.yml](./action.yml) and the [GitHub Actions guide](https://docs.github.com/en/actions/learn-github-actions/understanding-github-actions).
### Inputs ### Inputs
| Name | Value Type | Description | | Name | Value Type | Description |
| --- | --- | --- | | --- | --- | --- |
| `source-dir` | Path | Source directory of the CMake project. Defaults to current directory. | | `source-dir` | Path | Source directory of the CMake project. Defaults to the current directory. |
| `build-dir` | Path | Build directory of the CMake project. Defaults to `build` directory inside the source directory. | | `build-dir` | Path | Build directory of the CMake project. Defaults to the `build` directory inside the source directory. |
| `targets` | Multiple strings | List of build targets. | | `targets` | Multiple strings | List of build targets. |
| `run-test` | `true` or `false` | If enabled, run testing using [CTest](https://cmake.org/cmake/help/latest/manual/ctest.1.html). Defaults to `false`. | | `run-test` | `true` or `false` | If enabled, runs testing using [CTest](https://cmake.org/cmake/help/latest/manual/ctest.1.html). Defaults to `false`. |
| `generator` | String | Build system generator of the CMake project. | | `generator` | String | Build system generator for the CMake project. |
| `c-compiler` | String | Preferred executable for compiling C language files. | | `c-compiler` | String | Preferred executable for compiling C language files. |
| `cxx-compiler` | String | Preferred executable for compiling C++ language files. | | `cxx-compiler` | String | Preferred executable for compiling C++ language files. |
| `c-flags` | Multiple strings | Additional flags passed when compiling C language files. | | `c-flags` | Multiple strings | Additional flags passed when compiling C language files. |
| `cxx-flags` | Multiple strings | Additional flags passed when compiling C++ language files. | | `cxx-flags` | Multiple strings | Additional flags passed when compiling C++ language files. |
| `args` | Multiple strings | Additional arguments passed during the CMake configuration. | | `args` | Multiple strings | Additional arguments passed during CMake configuration. |
| `test-args` | Multiple strings | Additional arguments passed during the CTest run. | | `test-args` | Multiple strings | Additional arguments passed during the CTest run. |
> Note: Multiple strings mean that the input could be specified with more than one value. Separate each value with a space or a new line. > Note: Multiple strings mean that the input can be specified with more than one value. Separate each value with a space or a new line.
> Note: All inputs are optional. > Note: All inputs are optional.
### Examples ### Examples
```yaml ```yaml
name: build name: Build
on: on:
push: push:
jobs: jobs:
@ -58,9 +54,9 @@ jobs:
uses: threeal/cmake-action@latest uses: threeal/cmake-action@latest
``` ```
> Note: You can replace `@latest` with any version you like. See [this](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsuses). > Note: You can replace `@latest` with any version you prefer. See [this](https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsuses).
#### Specify the Source and the Build Directories #### Specify the Source and Build Directories
```yaml ```yaml
- name: Configure and build this project - name: Configure and build this project

View File

@ -1,8 +1,8 @@
cmake_minimum_required(VERSION 3.0) cmake_minimum_required(VERSION 3.0)
project(test) project(test)
option(CHECK_USING_CLANG "check if target is compiled using Clang" OFF) option(CHECK_USING_CLANG "Check if the target is compiled using Clang" OFF)
option(CHECK_SURPASS_WARNING "check if target could surpass a compiler warning" OFF) option(CHECK_SURPASS_WARNING "Check if the target could surpass a compiler warning" OFF)
if(CHECK_SURPASS_WARNING) if(CHECK_SURPASS_WARNING)
if(MSVC) if(MSVC)