Skip to content

Commit 6a1cb40

Browse files
authored
Merge pull request #8 from sodgeit/ci/more-cmake-versions-under-test
ci: testing more CMake versions The CMake versions under test, are the versions available in the supported lts versions of Ubuntu, and the latest version. Once support for a ubuntu version is dropped, the minimum cmake version of this project will be updated.
2 parents 11887a8 + de5cb2f commit 6a1cb40

File tree

4 files changed

+31
-41
lines changed

4 files changed

+31
-41
lines changed
+24-31
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
22
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
3-
name: CMake on multiple platforms
3+
name: test
44

55
on:
66
push:
@@ -16,33 +16,20 @@ jobs:
1616
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
1717
fail-fast: false
1818

19-
# Set up a matrix to run the following 3 configurations:
20-
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
21-
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
22-
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
23-
#
24-
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
19+
# CMake versions under test are the versions available int the supported
20+
# lts versions of Ubuntu, and the latest version.
21+
# Once support for a ubuntu version is dropped, the minimum cmake version of this
22+
# project will be updated.
2523
matrix:
2624
os: [ubuntu-latest, windows-latest]
27-
build_type: [Release]
28-
c_compiler: [gcc, clang, cl]
29-
include:
30-
- os: windows-latest
31-
c_compiler: cl
32-
cpp_compiler: cl
33-
- os: ubuntu-latest
34-
c_compiler: gcc
35-
cpp_compiler: g++
36-
- os: ubuntu-latest
37-
c_compiler: clang
38-
cpp_compiler: clang++
25+
build_type: [Release, Debug]
26+
cmake_version: ['3.16.3', # 20.04 LTS
27+
'3.22.1', # 22.04 LTS
28+
'3.28.3', # 24.04 LTS
29+
'3.30']
3930
exclude:
4031
- os: windows-latest
41-
c_compiler: gcc
42-
- os: windows-latest
43-
c_compiler: clang
44-
- os: ubuntu-latest
45-
c_compiler: cl
32+
cmake_version: '3.16.3' # there seems to be a bug with compiler detection
4633

4734
steps:
4835
- uses: actions/checkout@v4
@@ -54,18 +41,24 @@ jobs:
5441
run: |
5542
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
5643
44+
- name: Setup cmake
45+
uses: jwlawson/[email protected]
46+
with:
47+
cmake-version: ${{ matrix.cmake_version }}
48+
49+
# print the cmake version
50+
- name: Print CMake version
51+
run: cmake --version
52+
5753
- name: Configure CMake
58-
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
59-
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
6054
run: >
6155
cmake -B ${{ steps.strings.outputs.build-output-dir }}
62-
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
63-
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
6456
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
6557
-S ${{ github.workspace }}
66-
67-
#- name: Build
68-
# run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
58+
env:
59+
CMAKE_VERSION: ${{ matrix.cmake_version }}
6960

7061
- name: Install
7162
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --target install
63+
env:
64+
CMAKE_VERSION: ${{ matrix.cmake_version }}

CMakeLists.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# This file only performs a few sanity checks on the repo. No building is required to use the
66
# cmake/*.cmake files.
77

8-
cmake_minimum_required(VERSION 3.14)
8+
cmake_minimum_required(VERSION 3.16)
99

1010
project(cmake-sbom)
1111

cmake/sbom.cmake

+5-7
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.14 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.16 FATAL_ERROR)
22

33
# catch and stop second call to this function
44
if(COMMAND sbom_generate)
@@ -599,13 +599,14 @@ function(_sbom_verify_filetype FILETYPE)
599599
# https://spdx.github.io/spdx-spec/v2.3/file-information/#83-file-type-field
600600
set(valid_entries "SOURCE" "BINARY" "ARCHIVE" "APPLICATION" "AUDIO" "IMAGE" "TEXT" "VIDEO" "DOCUMENTATION" "SPDX" "OTHER")
601601
list(FIND valid_entries "${FILETYPE}" _index)
602+
602603
if(${_index} EQUAL -1)
603604
message(FATAL_ERROR "Invalid FILETYPE: ${FILETYPE}")
604605
endif()
605606
endfunction()
606607

607608
# Append a file to the SBOM. Use this after calling sbom_generate().
608-
function(sbom_add_file FILENAME )
609+
function(sbom_add_file FILENAME)
609610
set(options OPTIONAL)
610611
set(oneValueArgs RELATIONSHIP SPDXID)
611612
set(multiValueArgs FILETYPE)
@@ -691,11 +692,11 @@ function(sbom_add_target NAME)
691692
get_target_property(_type ${NAME} TYPE)
692693

693694
if("${_type}" STREQUAL "EXECUTABLE")
694-
sbom_add_file( ${CMAKE_INSTALL_BINDIR}/$<TARGET_FILE_NAME:${NAME}>
695+
sbom_add_file(${CMAKE_INSTALL_BINDIR}/$<TARGET_FILE_NAME:${NAME}>
695696
FILETYPE BINARY ${ARGN}
696697
)
697698
elseif("${_type}" STREQUAL "STATIC_LIBRARY")
698-
sbom_add_file( ${CMAKE_INSTALL_LIBDIR}/$<TARGET_FILE_NAME:${NAME}>
699+
sbom_add_file(${CMAKE_INSTALL_LIBDIR}/$<TARGET_FILE_NAME:${NAME}>
699700
FILETYPE BINARY ${ARGN}
700701
)
701702
elseif("${_type}" STREQUAL "SHARED_LIBRARY")
@@ -719,7 +720,6 @@ function(sbom_add_target NAME)
719720
endif()
720721

721722
set(SBOM_LAST_SPDXID "${SBOM_LAST_SPDXID}" PARENT_SCOPE)
722-
723723
endfunction()
724724

725725
# Append all files recursively in a directory to the SBOM. Use this after calling sbom_generate().
@@ -787,7 +787,6 @@ Relationship: ${SBOM_DIRECTORY_RELATIONSHIP}-\${_count}
787787
install(SCRIPT ${CMAKE_CURRENT_BINARY_DIR}/${SBOM_DIRECTORY_SPDXID}.cmake)
788788

789789
set(SBOM_LAST_SPDXID "" PARENT_SCOPE)
790-
791790
endfunction()
792791

793792
# Append a package (without files) to the SBOM. Use this after calling sbom_generate().
@@ -900,7 +899,6 @@ Relationship: ${SBOM_PACKAGE_SPDXID} CONTAINS NOASSERTION
900899
)
901900

902901
set(SBOM_LAST_SPDXID "${SBOM_LAST_SPDXID}" PARENT_SCOPE)
903-
904902
endfunction()
905903

906904
# Add a reference to a package in an external file.

example/CMakeLists.txt

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
# ##################################################################################################
66
# Preamble
77

8-
cmake_minimum_required(VERSION 3.7.1)
9-
cmake_policy(VERSION 3.7.1)
8+
cmake_minimum_required(VERSION 3.16)
109

1110
project(example-project)
1211

0 commit comments

Comments
 (0)