Skip to content

Commit 40531a0

Browse files
authored
πŸ‘¨πŸΎβ€πŸ€β€πŸ‘¨πŸ½ Test both C++17 and C++20 builds (#26)
resolves #18
1 parent c1c35e9 commit 40531a0

File tree

4 files changed

+50
-8
lines changed

4 files changed

+50
-8
lines changed

β€Ž.github/workflows/unit_tests.ymlβ€Ž

Lines changed: 43 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,52 @@ jobs:
1616
fail-fast: false
1717
matrix:
1818
compiler:
19+
# test the generated single header
1920
- name: clang-14
2021
single_header: 1
2122
install: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 14
2223
cc: " /usr/lib/llvm-14/bin/clang"
2324
cxx: "/usr/lib/llvm-14/bin/clang++"
25+
- name: gcc-11
26+
single_header: 1
27+
install: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt update && sudo apt-get install -y gcc-11 g++-11
28+
cc: "/usr/bin/gcc-11"
29+
cxx: "/usr/bin/g++-11"
30+
31+
# test c++20 build
32+
- name: clang-14
33+
cxx_standard: 20
34+
install: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 14
35+
cc: " /usr/lib/llvm-14/bin/clang"
36+
cxx: "/usr/lib/llvm-14/bin/clang++"
37+
- name: clang-13
38+
cxx_standard: 20
39+
install: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 13
40+
cc: " /usr/lib/llvm-13/bin/clang"
41+
cxx: "/usr/lib/llvm-13/bin/clang++"
42+
- name: clang-12
43+
cxx_standard: 20
44+
install: sudo apt update && sudo apt-get install -y clang-12
45+
cc: " /usr/lib/llvm-12/bin/clang"
46+
cxx: "/usr/lib/llvm-12/bin/clang++"
47+
- name: clang-11
48+
cxx_standard: 20
49+
install: sudo apt update && sudo apt-get install -y clang-11
50+
cc: " /usr/lib/llvm-11/bin/clang"
51+
cxx: "/usr/lib/llvm-11/bin/clang++"
52+
# gcc-11 c++20 is disabled because it fails to compile the unit tests
53+
# - name: gcc-11
54+
# cxx_standard: 20
55+
# install: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt update && sudo apt-get install -y gcc-11 g++-11
56+
# cc: "/usr/bin/gcc-11"
57+
# cxx: "/usr/bin/g++-11"
58+
- name: gcc-10
59+
cxx_standard: 20
60+
install: sudo apt update && sudo apt-get install -y gcc-10
61+
cc: "/usr/bin/gcc-10"
62+
cxx: "/usr/bin/g++-10"
63+
64+
# test c++17 build
2465
- name: clang-14
2566
install: wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 14
2667
cc: " /usr/lib/llvm-14/bin/clang"
@@ -53,11 +94,7 @@ jobs:
5394
install: sudo apt update && sudo apt-get install -y clang-7
5495
cc: " /usr/lib/llvm-7/bin/clang"
5596
cxx: "/usr/lib/llvm-7/bin/clang++"
56-
- name: gcc-11
57-
single_header: 1
58-
install: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt update && sudo apt-get install -y gcc-11 g++-11
59-
cc: "/usr/bin/gcc-11"
60-
cxx: "/usr/bin/g++-11"
97+
6198
- name: gcc-11
6299
install: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test && sudo apt update && sudo apt-get install -y gcc-11 g++-11
63100
cc: "/usr/bin/gcc-11"
@@ -88,6 +125,7 @@ jobs:
88125
CC: ${{ matrix.compiler.cc }}
89126
CXX: ${{ matrix.compiler.cxx }}
90127
SINGLE_HEADER: ${{ matrix.compiler.single_header }}
128+
CXX_STANDARD: ${{ matrix.compiler.cxx_standard }}
91129
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
92130

93131
- name: Build Unit Tests

β€ŽCMakeLists.txtβ€Ž

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,13 @@
11
cmake_minimum_required(VERSION 3.16)
22
project(compile_time_init_build)
33

4-
set(CMAKE_CXX_STANDARD 17)
4+
5+
if (DEFINED ENV{CXX_STANDARD} AND NOT $ENV{CXX_STANDARD} EQUAL "")
6+
set(CMAKE_CXX_STANDARD $ENV{CXX_STANDARD})
7+
else()
8+
set(CMAKE_CXX_STANDARD 17)
9+
endif()
10+
message("CMAKE_CXX_STANDARD = ${CMAKE_CXX_STANDARD}")
511

612
enable_testing()
713

β€Žbenchmark/CMakeLists.txtβ€Ž

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
cmake_minimum_required(VERSION 3.16)
22
project(compile_time_init_build)
33

4-
set(CMAKE_CXX_STANDARD 17)
54

65
add_executable(compilation_benchmark
76
big_nexus.cpp

β€Žtest/CMakeLists.txtβ€Ž

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
cmake_minimum_required(VERSION 3.16)
22
project(compile_time_init_build)
33

4-
set(CMAKE_CXX_STANDARD 17)
54

65
add_executable(tests
76
detail/type_list.cpp

0 commit comments

Comments
Β (0)