Skip to content

Commit a560297

Browse files
authored
build: support meson build system (#375)
* tests: migrate deprecated std::is_trivial_v * tools: add python typings * build: support meson build system CMake feature parity: - [x] Export meson target - [x] Export meson c++20 modules target - [ ] Export cmake target - [x] Installing headers - [x] Googletest support - [x] Freestanding tests - [x] Modules tests - [x] Google Benchmark support - [x] Extract examples from docs Extra features: - [x] Export pkgconfig target - [x] clang-format support - [x] Make fmtlib optional when building examples - [x] Install documents to docdir Tested on Fedora Linux 44 (gcc/clang/msvc-wine + ninja) and Windows 10 22H2 (msvc + vs2022). * ci: fix shellcheck warnings * ci: add meson tests * style: run clang-format * ci: workaround clang sanitizer linking bug * build/meson: fix modules builds on mingw winpthreads * build/meson: do not link -nodefaultlibs on sanitized builds * build/meson: increase max object section count on msvc * ci: only test release builds, do not run benchmarks * ci: pin runner versions * ci: exclude unsupported / broken platforms * build: add a notice about clang-cl broken msvc compatibility * build: meson gtest autodiscovery * build: meson doctest autoglob * ci: manage meson builds from proxy-ci * build: meson benchmarks autogen * build: make meson use common doctest extract logic * build/meson: auto disable tests if in a subproject * build/meson: auto disable benchmarks if in a subproject * build/meson: remove docdir installation the glob only contains files with C++ source code now. * build/meson: remove all autogen * build/meson: only add WINPTHREAD_COND_DECL workaround if winpthreads is found * ci: reword step names * ci: move meson ci tests into bvt workflows * build/meson: support pgi compilers * ci: remove meson from compatibility tests * ci: run meson and cmake in one pass * Test for std::format using __cpp_lib_format With specialization for libc++. Fixes compilation on libc++ 16-18 that has incomplete std::format support. * build/meson: remove module support too many compiler-specific workarounds. waiting for better upstream support. * fixup! ci: add meson tests * fixup! Test for std::format using __cpp_lib_format * build/meson: add test and benchmarks to all targets, only test build benchmark on ci * fixup! Test for std::format using __cpp_lib_format * fixup! build/meson: add test and benchmarks to all targets, only test build benchmark on ci * fixup! build/meson: add test and benchmarks to all targets, only test build benchmark on ci * build/meson: update fmt to 12.1.0 * fixup! tools: add python typings * fixup! build/meson: remove all autogen
1 parent 1d4ea35 commit a560297

26 files changed

+587
-158
lines changed

.github/workflows/bvt-appleclang.yml

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,33 @@ jobs:
77
steps:
88
- uses: actions/checkout@v4
99

10+
- name: install meson
11+
run: pipx install meson
12+
1013
- name: check compiler versions
1114
run: |
12-
clang --version
15+
cc --version
1316
xcodebuild -version
1417
15-
- name: build and run test with AppleClang
18+
- name: build and run test with AppleClang on cmake
1619
run: |
17-
cmake -B build -GNinja -DCMAKE_CXX_STANDARD=23 -DCMAKE_BUILD_TYPE=Release -DPROXY_BUILD_MODULES=FALSE
18-
cmake --build build -j
19-
ctest --test-dir build -j
20-
mkdir build/drop
21-
chmod +x tools/dump_build_env.sh
22-
./tools/dump_build_env.sh clang++ build/drop/env-info.json
20+
cmake -B build-cmake -GNinja -DCMAKE_CXX_STANDARD=23 -DCMAKE_BUILD_TYPE=Release -DPROXY_BUILD_MODULES=FALSE
21+
cmake --build build-cmake -j
22+
ctest --test-dir build-cmake -j
23+
mkdir build-cmake/drop
24+
bash ./tools/dump_build_env.sh c++ build-cmake/drop/env-info.json
2325
24-
- name: run benchmarks
26+
- name: build and run test with AppleClang on meson
2527
run: |
26-
build/benchmarks/msft_proxy_benchmarks --benchmark_min_warmup_time=0.1 --benchmark_min_time=0.1s --benchmark_repetitions=30 --benchmark_enable_random_interleaving=true --benchmark_report_aggregates_only=true --benchmark_format=json > build/drop/benchmarking-results.json
28+
meson setup build-meson --buildtype=release -Dtests=enabled -Dbenchmarks=enabled --force-fallback-for=fmt
29+
meson test -C build-meson
30+
meson test -C build-meson --benchmark --test-args=--benchmark_list_tests=true
31+
32+
- name: run benchmarks
33+
run: build-cmake/benchmarks/msft_proxy_benchmarks --benchmark_min_warmup_time=0.1 --benchmark_min_time=0.1s --benchmark_repetitions=30 --benchmark_enable_random_interleaving=true --benchmark_report_aggregates_only=true --benchmark_format=json > build-cmake/drop/benchmarking-results.json
2734

2835
- name: archive benchmarking results
2936
uses: actions/upload-artifact@v4
3037
with:
3138
name: drop-appleclang
32-
path: build/drop/
39+
path: build-cmake/drop/

.github/workflows/bvt-clang.yml

Lines changed: 26 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,45 @@ jobs:
77
steps:
88
- uses: actions/checkout@v4
99

10+
- name: install meson
11+
run: pipx install meson
12+
1013
- name: install clang
1114
run: |
12-
wget https://apt.llvm.org/llvm.sh
13-
chmod +x llvm.sh
14-
sudo ./llvm.sh 21
15-
sudo apt install -y libc++-21-dev clang-format-21
15+
curl https://apt.llvm.org/llvm.sh | sudo bash -s -- 21
16+
sudo apt install -y clang-21 libc++-21-dev clang-format-21
17+
cat <<'EOF' >> "$GITHUB_ENV"
18+
CC=clang-21
19+
CXX=clang++-21
20+
CXXFLAGS=-stdlib=libc++
21+
EOF
1622
1723
- name: check compiler version
1824
run: |
19-
clang++-21 --version
25+
"$CXX" --version
2026
21-
- name: build and run test with clang 21
27+
- name: build and run test with clang 21 on cmake
2228
run: |
23-
cmake -B build -GNinja -DCMAKE_C_COMPILER=clang-21 -DCMAKE_CXX_COMPILER=clang++-21 -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_CXX_STANDARD=23 -DCMAKE_BUILD_TYPE=Release -DPROXY_BUILD_MODULES=TRUE
24-
mapfile -t FILES < <(find include tests benchmarks build/examples_from_docs tools -type f \( -name '*.h' -o -name '*.ixx' -o -name '*.cpp' \))
29+
cmake -B build-cmake -GNinja -DCMAKE_CXX_STANDARD=23 -DCMAKE_BUILD_TYPE=Release -DPROXY_BUILD_MODULES=TRUE
30+
mapfile -t FILES < <(find include tests benchmarks build-cmake/examples_from_docs tools -type f \( -name '*.h' -o -name '*.ixx' -o -name '*.cpp' \))
2531
echo "Running clang-format on ${#FILES[@]} files: ${FILES[*]}"
2632
clang-format-21 --dry-run --Werror "${FILES[@]}"
27-
cmake --build build -j
28-
ctest --test-dir build -j
29-
mkdir build/drop
30-
chmod +x tools/dump_build_env.sh
31-
./tools/dump_build_env.sh clang++-21 build/drop/env-info.json
33+
cmake --build build-cmake -j
34+
ctest --test-dir build-cmake -j
35+
mkdir build-cmake/drop
36+
bash ./tools/dump_build_env.sh "$CXX" build-cmake/drop/env-info.json
3237
33-
- name: run benchmarks
38+
- name: build and run test with clang 21 on meson
3439
run: |
35-
build/benchmarks/msft_proxy_benchmarks --benchmark_min_warmup_time=0.1 --benchmark_min_time=0.1s --benchmark_repetitions=30 --benchmark_enable_random_interleaving=true --benchmark_report_aggregates_only=true --benchmark_format=json > build/drop/benchmarking-results.json
40+
meson setup build-meson --buildtype=release -Dtests=enabled -Dbenchmarks=enabled --force-fallback-for=fmt
41+
meson test -C build-meson
42+
meson test -C build-meson --benchmark --test-args=--benchmark_list_tests=true
43+
44+
- name: run benchmarks
45+
run: build-cmake/benchmarks/msft_proxy_benchmarks --benchmark_min_warmup_time=0.1 --benchmark_min_time=0.1s --benchmark_repetitions=30 --benchmark_enable_random_interleaving=true --benchmark_report_aggregates_only=true --benchmark_format=json > build-cmake/drop/benchmarking-results.json
3646

3747
- name: archive benchmarking results
3848
uses: actions/upload-artifact@v4
3949
with:
4050
name: drop-clang
41-
path: build/drop/
51+
path: build-cmake/drop/

.github/workflows/bvt-compatibility.yml

Lines changed: 33 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -4,63 +4,46 @@ on:
44
jobs:
55
bvt-compatibility:
66
runs-on: ubuntu-24.04
7+
strategy:
8+
fail-fast: false
9+
matrix:
10+
compiler:
11+
- {family: gcc, version: 13, modules: false}
12+
- {family: gcc, version: 14, modules: true}
13+
- {family: clang, version: 16, modules: false}
14+
- {family: clang, version: 17, modules: false}
15+
- {family: clang, version: 18, modules: false}
16+
- {family: clang, version: 19, modules: false}
17+
- {family: clang, version: 20, modules: true}
18+
719
steps:
820
- uses: actions/checkout@v4
921

10-
- name: install compilers
11-
run: |
12-
wget https://apt.llvm.org/llvm.sh
13-
chmod +x llvm.sh
14-
sudo ./llvm.sh 20
15-
sudo apt install -y gcc-13 g++-13 gcc-14 g++-14 clang-16 clang-17 clang-18 clang-19 libc++-17-dev
16-
17-
- name: check compiler versions
18-
run: |
19-
g++-13 --version
20-
g++-14 --version
21-
clang++-16 --version
22-
clang++-17 --version
23-
clang++-18 --version
24-
clang++-19 --version
25-
clang++-20 --version
26-
27-
- name: build and run test with gcc 14
28-
run: |
29-
cmake -B build-gcc-14 -GNinja -DCMAKE_C_COMPILER=gcc-14 -DCMAKE_CXX_COMPILER=g++-14 -DCMAKE_BUILD_TYPE=Release -DPROXY_BUILD_MODULES=TRUE
30-
cmake --build build-gcc-14 -j
31-
ctest --test-dir build-gcc-14 -j
32-
33-
- name: build and run test with gcc 13
34-
run: |
35-
cmake -B build-gcc-13 -DCMAKE_C_COMPILER=gcc-13 -DCMAKE_CXX_COMPILER=g++-13 -DCMAKE_BUILD_TYPE=Release -DPROXY_BUILD_MODULES=FALSE
36-
cmake --build build-gcc-13 -j
37-
ctest --test-dir build-gcc-13 -j
38-
39-
- name: build and run test with clang 20
40-
run: |
41-
cmake -B build-clang-20 -GNinja -DCMAKE_C_COMPILER=clang-20 -DCMAKE_CXX_COMPILER=clang++-20 -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_BUILD_TYPE=Release -DPROXY_BUILD_MODULES=TRUE
42-
cmake --build build-clang-20 -j
43-
ctest --test-dir build-clang-20 -j
44-
- name: build and run test with clang 19
22+
- name: install gcc
23+
if: ${{ matrix.compiler.family == 'gcc' }}
4524
run: |
46-
cmake -B build-clang-19 -DCMAKE_C_COMPILER=clang-19 -DCMAKE_CXX_COMPILER=clang++-19 -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_BUILD_TYPE=Release -DPROXY_BUILD_MODULES=FALSE
47-
cmake --build build-clang-19 -j
48-
ctest --test-dir build-clang-19 -j
25+
sudo apt install -y 'g++-${{ matrix.compiler.version }}'
26+
cat <<'EOF' >> "$GITHUB_ENV"
27+
CC=gcc-${{ matrix.compiler.version }}
28+
CXX=g++-${{ matrix.compiler.version }}
29+
EOF
4930
50-
- name: build and run test with clang 18
31+
- name: install clang
32+
if: ${{ matrix.compiler.family == 'clang' }}
5133
run: |
52-
cmake -B build-clang-18 -DCMAKE_C_COMPILER=clang-18 -DCMAKE_CXX_COMPILER=clang++-18 -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_BUILD_TYPE=Release -DPROXY_BUILD_MODULES=FALSE
53-
cmake --build build-clang-18 -j
54-
ctest --test-dir build-clang-18 -j
34+
sudo apt install -y 'clang-${{ matrix.compiler.version }}' 'clang-tools-${{ matrix.compiler.version }}' 'libc++-${{ matrix.compiler.version }}-dev' 'libc++abi-${{ matrix.compiler.version }}-dev'
35+
cat <<'EOF' >> "$GITHUB_ENV"
36+
CC=clang-${{ matrix.compiler.version }}
37+
CXX=clang++-${{ matrix.compiler.version }}
38+
CXXFLAGS=-stdlib=libc++
39+
EOF
5540
56-
- name: build and run test with clang 17
41+
- name: check compiler version
5742
run: |
58-
cmake -B build-clang-17 -DCMAKE_C_COMPILER=clang-17 -DCMAKE_CXX_COMPILER=clang++-17 -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_BUILD_TYPE=Release -DPROXY_BUILD_MODULES=FALSE
59-
cmake --build build-clang-17 -j
60-
ctest --test-dir build-clang-17 -j
43+
"$CXX" --version
6144
62-
- name: build and run test with clang 16
45+
- name: build and run test with cmake
6346
run: |
64-
cmake -B build-clang-16 -DCMAKE_C_COMPILER=clang-16 -DCMAKE_CXX_COMPILER=clang++-16 -DCMAKE_CXX_FLAGS="-stdlib=libc++" -DCMAKE_BUILD_TYPE=Release -DPROXY_BUILD_MODULES=FALSE
65-
cmake --build build-clang-16 -j
66-
ctest --test-dir build-clang-16 -j
47+
cmake -B build -GNinja -DCMAKE_BUILD_TYPE=Release '-DPROXY_BUILD_MODULES=${{ matrix.compiler.modules }}'
48+
cmake --build build -j
49+
ctest --test-dir build -j

.github/workflows/bvt-gcc.yml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,35 @@ jobs:
88
steps:
99
- uses: actions/checkout@v4
1010

11-
- name: install dependencies
11+
- name: install cmake and meson
1212
run: |
1313
apt-get update
14-
apt-get install -y cmake ninja-build
14+
apt-get install -y cmake meson ninja-build
1515
1616
- name: check compiler version
1717
run: |
1818
g++ --version
1919
20-
- name: build and run test with gcc 15
20+
- name: build and run test with gcc 15 on cmake
2121
run: |
22-
cmake -B build -GNinja -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_CXX_STANDARD=23 -DCMAKE_BUILD_TYPE=Release -DPROXY_BUILD_MODULES=TRUE
23-
cmake --build build -j
24-
ctest --test-dir build -j
25-
mkdir build/drop
22+
cmake -B build-cmake -GNinja -DCMAKE_CXX_STANDARD=23 -DCMAKE_BUILD_TYPE=Release -DPROXY_BUILD_MODULES=TRUE
23+
cmake --build build-cmake -j
24+
ctest --test-dir build-cmake -j
25+
mkdir build-cmake/drop
2626
chmod +x tools/dump_build_env.sh
27-
./tools/dump_build_env.sh g++ build/drop/env-info.json
27+
./tools/dump_build_env.sh g++ build-cmake/drop/env-info.json
2828
29-
- name: run benchmarks
29+
- name: build and run test with gcc 15 on meson
3030
run: |
31-
build/benchmarks/msft_proxy_benchmarks --benchmark_min_warmup_time=0.1 --benchmark_min_time=0.1s --benchmark_repetitions=30 --benchmark_enable_random_interleaving=true --benchmark_report_aggregates_only=true --benchmark_format=json > build/drop/benchmarking-results.json
31+
meson setup build-meson --buildtype=release -Dtests=enabled -Dbenchmarks=enabled --force-fallback-for=fmt
32+
meson test -C build-meson
33+
meson test -C build-meson --benchmark --test-args=--benchmark_list_tests=true
34+
35+
- name: run benchmarks
36+
run: build-cmake/benchmarks/msft_proxy_benchmarks --benchmark_min_warmup_time=0.1 --benchmark_min_time=0.1s --benchmark_repetitions=30 --benchmark_enable_random_interleaving=true --benchmark_report_aggregates_only=true --benchmark_format=json > build-cmake/drop/benchmarking-results.json
3237

3338
- name: archive benchmarking results
3439
uses: actions/upload-artifact@v4
3540
with:
3641
name: drop-gcc
37-
path: build/drop/
42+
path: build-cmake/drop/

.github/workflows/bvt-msvc.yml

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,31 @@ jobs:
77
steps:
88
- uses: actions/checkout@v4
99

10+
- name: install meson
11+
run: pipx install meson
12+
1013
- name: add cl.exe to PATH
1114
uses: ilammy/msvc-dev-cmd@v1
1215

13-
- name: build and run test with MSVC
16+
- name: build and run test with MSVC on cmake
1417
run: |
15-
cmake -B build -DCMAKE_CXX_STANDARD=23 -DPROXY_BUILD_MODULES=TRUE `
16-
&& cmake --build build --config Release -j `
17-
&& ctest --test-dir build -j `
18-
&& mkdir build\drop > $null `
19-
&& .\tools\dump_build_env_msvc.ps1 -OutputPath build\drop\env-info.json
18+
cmake -B build-cmake -DCMAKE_CXX_STANDARD=23 -DPROXY_BUILD_MODULES=TRUE `
19+
&& cmake --build build-cmake --config Release -j `
20+
&& ctest --test-dir build-cmake -j `
21+
&& mkdir build-cmake\drop > $null `
22+
&& .\tools\dump_build_env_msvc.ps1 -OutputPath build-cmake\drop\env-info.json
2023
21-
- name: run benchmarks
24+
- name: build and run test with MSVC on meson
2225
run: |
23-
build\benchmarks\Release\msft_proxy_benchmarks.exe --benchmark_min_warmup_time=0.1 --benchmark_min_time=0.1s --benchmark_repetitions=30 --benchmark_enable_random_interleaving=true --benchmark_report_aggregates_only=true --benchmark_format=json > build\drop\benchmarking-results.json
26+
meson setup build-meson --buildtype=release -Dtests=enabled -Dbenchmarks=enabled --force-fallback-for=fmt --vsenv
27+
meson test -C build-meson
28+
meson test -C build-meson --benchmark --test-args=--benchmark_list_tests=true
29+
30+
- name: run benchmarks
31+
run: build-cmake\benchmarks\Release\msft_proxy_benchmarks.exe --benchmark_min_warmup_time=0.1 --benchmark_min_time=0.1s --benchmark_repetitions=30 --benchmark_enable_random_interleaving=true --benchmark_report_aggregates_only=true --benchmark_format=json > build-cmake\drop\benchmarking-results.json
2432

2533
- name: archive benchmarking results
2634
uses: actions/upload-artifact@v4
2735
with:
2836
name: drop-msvc
29-
path: build/drop/
37+
path: build-cmake/drop/

.github/workflows/bvt-nvhpc.yml

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,29 +10,41 @@ jobs:
1010
- name: free disk space
1111
uses: jlumbroso/free-disk-space@v1.3.1
1212

13+
# - name: install meson
14+
# # FIXME: install from upstream once https://github.com/mesonbuild/meson/pull/15353 is released
15+
# run: pipx install git+https://github.com/mesonbuild/meson@02b85a846629090a0c7f18e860bab0a10ea4349b
16+
1317
- name: install NVHPC 25.11
1418
run: |
1519
curl https://developer.download.nvidia.com/hpc-sdk/ubuntu/DEB-GPG-KEY-NVIDIA-HPC-SDK | sudo gpg --dearmor -o /usr/share/keyrings/nvidia-hpcsdk-archive-keyring.gpg
1620
echo 'deb [signed-by=/usr/share/keyrings/nvidia-hpcsdk-archive-keyring.gpg] https://developer.download.nvidia.com/hpc-sdk/ubuntu/amd64 /' | sudo tee /etc/apt/sources.list.d/nvhpc.list
1721
sudo apt-get update -y
1822
sudo apt-get install -y nvhpc-25-11
23+
cat<<'EOF' >> "$GITHUB_ENV"
24+
CC=/opt/nvidia/hpc_sdk/Linux_x86_64/25.11/compilers/bin/nvc
25+
CXX=/opt/nvidia/hpc_sdk/Linux_x86_64/25.11/compilers/bin/nvc++
26+
EOF
1927
20-
- name: build and run test with NVHPC 25.11
28+
- name: build and run test with NVHPC 25.11 on cmake
2129
run: |
22-
PATH=/opt/nvidia/hpc_sdk/Linux_x86_64/25.11/compilers/bin:$PATH; export PATH
23-
cmake -B build -GNinja -DCMAKE_C_COMPILER=nvc -DCMAKE_CXX_COMPILER=nvc++ -DCMAKE_BUILD_TYPE=Release -DPROXY_BUILD_MODULES=FALSE
24-
cmake --build build -j
25-
ctest --test-dir build -j
26-
mkdir build/drop
30+
cmake -B build-cmake -GNinja -DCMAKE_BUILD_TYPE=Release -DPROXY_BUILD_MODULES=FALSE
31+
cmake --build build-cmake -j
32+
ctest --test-dir build-cmake -j
33+
mkdir build-cmake/drop
2734
chmod +x tools/dump_build_env.sh
28-
./tools/dump_build_env.sh nvc++ build/drop/env-info.json
35+
./tools/dump_build_env.sh "$CXX" build-cmake/drop/env-info.json
36+
37+
# - name: build and run test with NVHPC 25.11 on meson
38+
# run: |
39+
# meson setup build-meson --buildtype=release -Dtests=enabled -Dbenchmarks=enabled --force-fallback-for=fmt
40+
# meson test -C build-meson
41+
# meson test -C build-meson --benchmark --test-args=--benchmark_list_tests=true
2942

3043
- name: run benchmarks
31-
run: |
32-
build/benchmarks/msft_proxy_benchmarks --benchmark_min_warmup_time=0.1 --benchmark_min_time=0.1s --benchmark_repetitions=30 --benchmark_enable_random_interleaving=true --benchmark_report_aggregates_only=true --benchmark_format=json > build/drop/benchmarking-results.json
44+
run: build-cmake/benchmarks/msft_proxy_benchmarks --benchmark_min_warmup_time=0.1 --benchmark_min_time=0.1s --benchmark_repetitions=30 --benchmark_enable_random_interleaving=true --benchmark_report_aggregates_only=true --benchmark_format=json > build-cmake/drop/benchmarking-results.json
3345

3446
- name: archive benchmarking results
3547
uses: actions/upload-artifact@v4
3648
with:
3749
name: drop-nvhpc
38-
path: build/drop/
50+
path: build-cmake/drop/

0 commit comments

Comments
 (0)