mirror of
https://github.com/threeal/cmake-action.git
synced 2025-06-09 18:51:21 +00:00
chore: merge pull request #48 from threeal/add-options-input
Add `options` Input
This commit is contained in:
commit
f1a04790c4
4
.github/workflows/test.yml
vendored
4
.github/workflows/test.yml
vendored
@ -101,7 +101,7 @@ jobs:
|
|||||||
source-dir: test
|
source-dir: test
|
||||||
c-flags: ${{ matrix.compiler == 'msvc' && '/w /WX-' || '-Wno-unused-variable' }}
|
c-flags: ${{ matrix.compiler == 'msvc' && '/w /WX-' || '-Wno-unused-variable' }}
|
||||||
cxx-flags: ${{ matrix.compiler == 'msvc' && '/w /WX-' || '-Wno-unused-variable' }}
|
cxx-flags: ${{ matrix.compiler == 'msvc' && '/w /WX-' || '-Wno-unused-variable' }}
|
||||||
args: -D CHECK_SURPASS_WARNING=ON
|
options: CHECK_SURPASS_WARNING=ON
|
||||||
run-build: true
|
run-build: true
|
||||||
build-args: --target test_c --target test_cpp
|
build-args: --target test_c --target test_cpp
|
||||||
run-test: true
|
run-test: true
|
||||||
@ -124,7 +124,7 @@ jobs:
|
|||||||
generator: Ninja
|
generator: Ninja
|
||||||
c-compiler: clang
|
c-compiler: clang
|
||||||
cxx-compiler: clang++
|
cxx-compiler: clang++
|
||||||
args: -D CHECK_USING_CLANG=ON
|
options: CHECK_USING_CLANG=ON
|
||||||
run-build: true
|
run-build: true
|
||||||
build-args: --target test_c --target test_cpp
|
build-args: --target test_c --target test_cpp
|
||||||
run-test: true
|
run-test: true
|
||||||
|
31
README.md
31
README.md
@ -24,20 +24,21 @@ For more information, refer to [action.yml](./action.yml) and the [GitHub Action
|
|||||||
| --- | --- | --- |
|
| --- | --- | --- |
|
||||||
| `source-dir` | Path | The source directory of the CMake project. It defaults to the current directory. |
|
| `source-dir` | Path | The source directory of the CMake project. It defaults to the current directory. |
|
||||||
| `build-dir` | Path | The build directory of the CMake project. It defaults to the `build` directory inside the source directory. |
|
| `build-dir` | Path | The build directory of the CMake project. It defaults to the `build` directory inside the source directory. |
|
||||||
| `generator` | String | The build system generator for the CMake project. |
|
| `generator` | String | The build system generator for the CMake project. It appends the CMake configuration arguments with `-G [val]`. |
|
||||||
| `c-compiler` | String | The preferred executable for compiling C language files. |
|
| `c-compiler` | String | The preferred executable for compiling C language files. It appends the CMake configuration arguments with `-D CMAKE_C_COMPILER=[val]`. |
|
||||||
| `cxx-compiler` | String | The preferred executable for compiling C++ language files. |
|
| `cxx-compiler` | String | The preferred executable for compiling C++ language files. It appends the CMake configuration arguments with `-D CMAKE_CXX_COMPILER=[val]`. |
|
||||||
| `c-flags` | Multiple strings | Additional flags to pass when compiling C language files. |
|
| `c-flags` | Multiple strings | Additional flags to pass when compiling C language files. It appends the CMake configuration arguments with `-D CMAKE_C_FLAGS=[vals]`. |
|
||||||
| `cxx-flags` | Multiple strings | Additional flags to pass when compiling C++ language files. |
|
| `cxx-flags` | Multiple strings | Additional flags to pass when compiling C++ language files. It appends the CMake configuration arguments with `-D CMAKE_CXX_FLAGS=[vals]`. |
|
||||||
|
| `options` | Multiple strings | Additional options to pass during the CMake configuration. It appends the CMake configuration arguments with each of `-D [val]`. |
|
||||||
| `args` | Multiple strings | Additional arguments to pass during the CMake configuration. |
|
| `args` | Multiple strings | Additional arguments to pass during the CMake configuration. |
|
||||||
| `run-build` | `true` or `false` | If enabled, it builds the project using [CTest](https://cmake.org/cmake/help/latest/manual/ctest.1.html). It defaults to `false`. |
|
| `run-build` | `true` or `false` | If enabled, it builds the project using CMake. It defaults to `false`. |
|
||||||
| `build-args` | Multiple strings | Additional arguments to pass during the CMake build. |
|
| `build-args` | Multiple strings | Additional arguments to pass during the CMake build. |
|
||||||
| `run-test` | `true` or `false` | If enabled, it runs testing using [CTest](https://cmake.org/cmake/help/latest/manual/ctest.1.html). It defaults to `false`. |
|
| `run-test` | `true` or `false` | If enabled, it runs testing using [CTest](https://cmake.org/cmake/help/latest/manual/ctest.1.html). It defaults to `false`. |
|
||||||
| `test-args` | Multiple strings | Additional arguments to pass during the CTest run. |
|
| `test-args` | Multiple strings | Additional arguments to pass during the CTest run. |
|
||||||
|
|
||||||
> 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**: 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
|
||||||
|
|
||||||
@ -50,10 +51,10 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout the repository
|
- name: Checkout the repository
|
||||||
uses: actions/checkout@v3.3.0
|
uses: actions/checkout@v3.5.3
|
||||||
|
|
||||||
- name: Configure the project
|
- name: Configure the project
|
||||||
uses: threeal/cmake-action@latest
|
uses: threeal/cmake-action@main
|
||||||
|
|
||||||
- name: Build the project
|
- name: Build the project
|
||||||
runs: cmake --build build
|
runs: cmake --build build
|
||||||
@ -62,13 +63,13 @@ jobs:
|
|||||||
runs: ctest --test-dir build
|
runs: ctest --test-dir build
|
||||||
```
|
```
|
||||||
|
|
||||||
> 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).
|
> **Note**: You can replace `@main` 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 Build Directories
|
#### Specify the Source and Build Directories
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Configure the project
|
- name: Configure the project
|
||||||
uses: threeal/cmake-action@latest
|
uses: threeal/cmake-action@main
|
||||||
with:
|
with:
|
||||||
source-dir: submodules
|
source-dir: submodules
|
||||||
build-dir: submodules/out
|
build-dir: submodules/out
|
||||||
@ -78,9 +79,9 @@ jobs:
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Configure, build, and test the project
|
- name: Configure, build, and test the project
|
||||||
uses: threeal/cmake-action@latest
|
uses: threeal/cmake-action@main
|
||||||
with:
|
with:
|
||||||
args: -DBUILD_TESTING=ON
|
options: BUILD_TESTING=ON
|
||||||
run-build: true
|
run-build: true
|
||||||
run-test: true
|
run-test: true
|
||||||
```
|
```
|
||||||
@ -89,7 +90,7 @@ jobs:
|
|||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
- name: Configure and build the project
|
- name: Configure and build the project
|
||||||
uses: threeal/cmake-action@latest
|
uses: threeal/cmake-action@main
|
||||||
with:
|
with:
|
||||||
generator: Ninja
|
generator: Ninja
|
||||||
c-compiler: clang
|
c-compiler: clang
|
||||||
|
@ -26,6 +26,9 @@ inputs:
|
|||||||
cxx-flags:
|
cxx-flags:
|
||||||
description: Additional flags to pass when compiling C++ language files
|
description: Additional flags to pass when compiling C++ language files
|
||||||
required: false
|
required: false
|
||||||
|
options:
|
||||||
|
description: Additional options to pass during the CMake configuration
|
||||||
|
required: false
|
||||||
args:
|
args:
|
||||||
description: Additional arguments to pass during the CMake configuration
|
description: Additional arguments to pass during the CMake configuration
|
||||||
required: false
|
required: false
|
||||||
@ -78,6 +81,9 @@ runs:
|
|||||||
if [ -n '${{ inputs.cxx-flags }}' ]; then
|
if [ -n '${{ inputs.cxx-flags }}' ]; then
|
||||||
ARGS="$ARGS -D CMAKE_CXX_FLAGS='${{ inputs.cxx-flags }}'"
|
ARGS="$ARGS -D CMAKE_CXX_FLAGS='${{ inputs.cxx-flags }}'"
|
||||||
fi
|
fi
|
||||||
|
for OPT in ${{ inputs.options }}; do
|
||||||
|
ARGS="$ARGS -D $OPT"
|
||||||
|
done
|
||||||
if [ -n '${{ inputs.args }}' ]; then
|
if [ -n '${{ inputs.args }}' ]; then
|
||||||
ARGS="$ARGS ${{ inputs.args }}"
|
ARGS="$ARGS ${{ inputs.args }}"
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user