Skip to content

Commit ced2a09

Browse files
committed
refactor(cmake-workflow): split setup step
1 parent cba0512 commit ced2a09

File tree

5 files changed

+427
-183
lines changed

5 files changed

+427
-183
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ jobs:
109109
- name: CMake Workflow
110110
uses: ./cmake-workflow
111111
with:
112+
cmake-version: '>=3.8'
113+
cmake-min-version: ${{ matrix.container && '3.8' }}
112114
source-dir: tests
113115
generator: ${{ matrix.generator }}
114116
toolchain: ${{ steps.package-install.outputs.vcpkg-toolchain }}
@@ -119,7 +121,6 @@ jobs:
119121
cxx: ${{ matrix.cxx }}
120122
cxxflags: ${{ matrix.cxxflags }}
121123
cc: ${{ matrix.cc }}
122-
cmake-min-version: 3.15
123124
extra-args: -D BOOST_SRC_DIR=$GITHUB_WORKSPACE/boost-root
124125
ref-source-dir: .
125126

README.adoc

Lines changed: 50 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,45 +139,67 @@ steps:
139139
- name: CMake Workflow
140140
uses: alandefreitas/cpp-actions/cmake-workflow@master
141141
with:
142+
cmake-version: '>=3.8'
142143
source-dir: tests
143144
toolchain: ${{ steps.package-install.outputs.vcpkg-toolchain }}
144145
run-tests: 'true'
145146
install-prefix: $GITHUB_WORKSPACE/.local
146147
cxxstd: 17,20
147148
cxx: g++-11
148149
cc: gcc-11
149-
cmake-min-version: 3.15
150150
extra-args: -D BOOST_SRC_DIR=$GITHUB_WORKSPACE/boost-root
151151
ref-source-dir: .
152152
----
153153

154-
Example 2 (`build-type`, `generator`):
154+
Example 2 (`cmake-min-version`):
155155

156156
[source,yml]
157157
----
158158
steps:
159159
- name: CMake Workflow
160160
uses: alandefreitas/cpp-actions/cmake-workflow@master
161161
with:
162+
cmake-version: '>=3.8'
163+
cmake-min-version: '3.8'
164+
source-dir: tests
165+
toolchain: ${{ steps.package-install.outputs.vcpkg-toolchain }}
166+
run-tests: 'true'
167+
install-prefix: $GITHUB_WORKSPACE/.local
168+
cxxstd: '11'
169+
cxx: g++-4.8
170+
cc: gcc-4.8
171+
extra-args: -D BOOST_SRC_DIR=$GITHUB_WORKSPACE/boost-root
172+
ref-source-dir: .
173+
----
174+
175+
Example 3 (`build-type`, `generator`):
176+
177+
[source,yml]
178+
----
179+
steps:
180+
- name: CMake Workflow
181+
uses: alandefreitas/cpp-actions/cmake-workflow@master
182+
with:
183+
cmake-version: '>=3.8'
162184
source-dir: tests
163185
generator: Unix Makefiles
164186
toolchain: ${{ steps.package-install.outputs.vcpkg-toolchain }}
165187
build-type: Debug
166188
run-tests: 'true'
167189
install-prefix: $GITHUB_WORKSPACE/.local
168-
cmake-min-version: 3.15
169190
extra-args: -D BOOST_SRC_DIR=$GITHUB_WORKSPACE/boost-root
170191
ref-source-dir: .
171192
----
172193

173-
Example 3 (`cxxflags`):
194+
Example 4 (`cxxflags`):
174195

175196
[source,yml]
176197
----
177198
steps:
178199
- name: CMake Workflow
179200
uses: alandefreitas/cpp-actions/cmake-workflow@master
180201
with:
202+
cmake-version: '>=3.8'
181203
source-dir: tests
182204
toolchain: ${{ steps.package-install.outputs.vcpkg-toolchain }}
183205
run-tests: 'true'
@@ -186,7 +208,6 @@ steps:
186208
cxx: clang++-12
187209
cxxflags: -stdlib=libc++
188210
cc: clang-12
189-
cmake-min-version: 3.15
190211
extra-args: -D BOOST_SRC_DIR=$GITHUB_WORKSPACE/boost-root
191212
ref-source-dir: .
192213
----
@@ -195,10 +216,31 @@ steps:
195216

196217
|===
197218
|Parameter |Description |Default
219+
|`cmake-exec` |The cmake executable. |`cmake`
220+
|`cmake-version` |A semver range string with the cmake versions supported by this workflow.
221+
222+
If the existing version in the environment does not satisfy this requirement, the action attempts
223+
to install or update CMake using cmake-min-version.
224+
225+
If this input is undefined, the version ">= cmake-min-version" is considered.
226+
227+
This should usually match the `cmake_minimum_required` defined in your CMakeLists.txt file.
228+
. |
229+
|`cmake-min-version` |Set the minimum cmake version for this workflow when the cmake-version requirement is not satisfied.
230+
231+
If the existing version in the environment does not satisfy this cmake-version requirement,
232+
the action attempts to install or update CMake using this cmake-min-version.
233+
234+
If cmake-version is not set, this option overrides the `cmake-version` input as `>= cmake-min-version`.
235+
236+
If cmake-min-version is not defined, the action attempts to extract the cmake-min-version
237+
from CMakeLists.txt.
238+
239+
If a minimum version cannot be found in CMakeLists.txt, the lastest CMake version is considered
240+
the minimum version.
241+
. |
198242
|`source-dir` |Directory for the source files. |`.`
199243
|`build-dir` |Directory for the binaries relative to the source directory. |`build`
200-
|`cmake-exec` |The cmake executable. |`cmake`
201-
|`cmake-min-version` |The minimum cmake version for this workflow. If the existing version is below that, the action attempts to update CMake. |`3.5`
202244
|`cc` |Path to C compiler. |
203245
|`cxx` |Path to C++ compiler. |
204246
|`cxxstd` |List of standards with which cmake will build and test the program. |
@@ -208,14 +250,14 @@ steps:
208250
|`build-type` |Build type. |`Release`
209251
|`build-target` |Targets to build instead of the default target. |
210252
|`install-prefix` |Path where the library should be installed. |`.local/usr`
253+
|`extra-args` |Extra arguments to cmake configure command. |
211254
|`run-tests` |Whether we should run tests. |`true`
212255
|`install` |Whether we should install the library.
213256

214257
The library is only installed once in the `install-prefix`.
215258

216259
The latest std version described in `cxxstd` is used for the installed version.
217260
. |`true`
218-
|`extra-args` |Extra arguments to cmake configure command. |
219261
|`create-annotations` |Create github annotations on errors. |`true`
220262
|`ref-source-dir` |A reference source directory for annotations. Any annotation filename will be relative to this directory.
221263

@@ -225,7 +267,6 @@ we need to make annotations relative to some other directory.
225267
In most cases, the default option should be enough.
226268
. |`.`
227269
|`trace-commands` |Trace commands executed by the workflow. |`false`
228-
|`cpack-generators` |Run cpack with the specified generators after the install step. |
229270
|===
230271

231272
=== Boost Clone [[boost-clone]]

0 commit comments

Comments
 (0)