Skip to content

Commit f1a0479

Browse files
authored
chore: merge pull request #48 from threeal/add-options-input
Add `options` Input
2 parents e774bd0 + ce8b638 commit f1a0479

File tree

3 files changed

+24
-17
lines changed

3 files changed

+24
-17
lines changed

.github/workflows/test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ jobs:
101101
source-dir: test
102102
c-flags: ${{ matrix.compiler == 'msvc' && '/w /WX-' || '-Wno-unused-variable' }}
103103
cxx-flags: ${{ matrix.compiler == 'msvc' && '/w /WX-' || '-Wno-unused-variable' }}
104-
args: -D CHECK_SURPASS_WARNING=ON
104+
options: CHECK_SURPASS_WARNING=ON
105105
run-build: true
106106
build-args: --target test_c --target test_cpp
107107
run-test: true
@@ -124,7 +124,7 @@ jobs:
124124
generator: Ninja
125125
c-compiler: clang
126126
cxx-compiler: clang++
127-
args: -D CHECK_USING_CLANG=ON
127+
options: CHECK_USING_CLANG=ON
128128
run-build: true
129129
build-args: --target test_c --target test_cpp
130130
run-test: true

README.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,21 @@ For more information, refer to [action.yml](./action.yml) and the [GitHub Action
2424
| --- | --- | --- |
2525
| `source-dir` | Path | The source directory of the CMake project. It defaults to the current directory. |
2626
| `build-dir` | Path | The build directory of the CMake project. It defaults to the `build` directory inside the source directory. |
27-
| `generator` | String | The build system generator for the CMake project. |
28-
| `c-compiler` | String | The preferred executable for compiling C language files. |
29-
| `cxx-compiler` | String | The preferred executable for compiling C++ language files. |
30-
| `c-flags` | Multiple strings | Additional flags to pass when compiling C language files. |
31-
| `cxx-flags` | Multiple strings | Additional flags to pass when compiling C++ language files. |
27+
| `generator` | String | The build system generator for the CMake project. It appends the CMake configuration arguments with `-G [val]`. |
28+
| `c-compiler` | String | The preferred executable for compiling C language files. It appends the CMake configuration arguments with `-D CMAKE_C_COMPILER=[val]`. |
29+
| `cxx-compiler` | String | The preferred executable for compiling C++ language files. It appends the CMake configuration arguments with `-D CMAKE_CXX_COMPILER=[val]`. |
30+
| `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]`. |
31+
| `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]`. |
32+
| `options` | Multiple strings | Additional options to pass during the CMake configuration. It appends the CMake configuration arguments with each of `-D [val]`. |
3233
| `args` | Multiple strings | Additional arguments to pass during the CMake configuration. |
33-
| `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`. |
34+
| `run-build` | `true` or `false` | If enabled, it builds the project using CMake. It defaults to `false`. |
3435
| `build-args` | Multiple strings | Additional arguments to pass during the CMake build. |
3536
| `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`. |
3637
| `test-args` | Multiple strings | Additional arguments to pass during the CTest run. |
3738

38-
> 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.
39+
> **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.
3940
40-
> Note: All inputs are optional.
41+
> **Note**: All inputs are optional.
4142
4243
### Examples
4344

@@ -50,10 +51,10 @@ jobs:
5051
runs-on: ubuntu-latest
5152
steps:
5253
- name: Checkout the repository
53-
uses: actions/checkout@v3.3.0
54+
uses: actions/checkout@v3.5.3
5455

5556
- name: Configure the project
56-
uses: threeal/cmake-action@latest
57+
uses: threeal/cmake-action@main
5758

5859
- name: Build the project
5960
runs: cmake --build build
@@ -62,13 +63,13 @@ jobs:
6263
runs: ctest --test-dir build
6364
```
6465
65-
> 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).
66+
> **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).
6667

6768
#### Specify the Source and Build Directories
6869

6970
```yaml
7071
- name: Configure the project
71-
uses: threeal/cmake-action@latest
72+
uses: threeal/cmake-action@main
7273
with:
7374
source-dir: submodules
7475
build-dir: submodules/out
@@ -78,9 +79,9 @@ jobs:
7879

7980
```yaml
8081
- name: Configure, build, and test the project
81-
uses: threeal/cmake-action@latest
82+
uses: threeal/cmake-action@main
8283
with:
83-
args: -DBUILD_TESTING=ON
84+
options: BUILD_TESTING=ON
8485
run-build: true
8586
run-test: true
8687
```
@@ -89,7 +90,7 @@ jobs:
8990

9091
```yaml
9192
- name: Configure and build the project
92-
uses: threeal/cmake-action@latest
93+
uses: threeal/cmake-action@main
9394
with:
9495
generator: Ninja
9596
c-compiler: clang

action.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ inputs:
2626
cxx-flags:
2727
description: Additional flags to pass when compiling C++ language files
2828
required: false
29+
options:
30+
description: Additional options to pass during the CMake configuration
31+
required: false
2932
args:
3033
description: Additional arguments to pass during the CMake configuration
3134
required: false
@@ -78,6 +81,9 @@ runs:
7881
if [ -n '${{ inputs.cxx-flags }}' ]; then
7982
ARGS="$ARGS -D CMAKE_CXX_FLAGS='${{ inputs.cxx-flags }}'"
8083
fi
84+
for OPT in ${{ inputs.options }}; do
85+
ARGS="$ARGS -D $OPT"
86+
done
8187
if [ -n '${{ inputs.args }}' ]; then
8288
ARGS="$ARGS ${{ inputs.args }}"
8389
fi

0 commit comments

Comments
 (0)