Skip to content

Commit 067c37f

Browse files
committed
ci: testing more CMake versions
1 parent 11887a8 commit 067c37f

File tree

4 files changed

+21
-17
lines changed

4 files changed

+21
-17
lines changed

.github/workflows/cmake-multi-platform.yml

+14-7
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ 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 the supported lts versions of Ubuntu, and the latest version.
20+
# Once support for a version is dropped, the minimum version can be updated.
2521
matrix:
2622
os: [ubuntu-latest, windows-latest]
27-
build_type: [Release]
23+
build_type: [Release, Debug]
2824
c_compiler: [gcc, clang, cl]
25+
cmake_version: ['3.16.3', # 20.04 LTS
26+
'3.22.1', # 22.04 LTS
27+
'3.28.3', # 24.04 LTS
28+
'3.30']
2929
include:
3030
- os: windows-latest
3131
c_compiler: cl
@@ -54,6 +54,11 @@ jobs:
5454
run: |
5555
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
5656
57+
- name: Setup cmake
58+
uses: jwlawson/[email protected]
59+
with:
60+
cmake-version: ${{ matrix.cmake_version }}
61+
5762
- name: Configure CMake
5863
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
5964
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
@@ -63,9 +68,11 @@ jobs:
6368
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
6469
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
6570
-S ${{ github.workspace }}
71+
env: CMAKE_VERSION: ${{ matrix.cmake_version }}
6672

6773
#- name: Build
6874
# run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}
6975

7076
- name: Install
7177
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --target install
78+
env: 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)