-
Notifications
You must be signed in to change notification settings - Fork 2
105 lines (88 loc) · 3.49 KB
/
Copy pathcmake-multi-platform.yml
File metadata and controls
105 lines (88 loc) · 3.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: CMake on multiple platforms
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
# -------------------------------------------------------------------------
# Build + test (developer tree)
# -------------------------------------------------------------------------
build:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
preset: ci-gcc
- os: ubuntu-latest
preset: ci-clang
- os: windows-latest
preset: ci
steps:
- uses: actions/checkout@v4
- name: Configure CMake
run: cmake --preset ${{ matrix.preset }}
- name: Build
run: cmake --build --preset ${{ matrix.preset }}
- name: Test
run: ctest --preset ${{ matrix.preset }}
# -------------------------------------------------------------------------
# Install + consumer smoke test
# Verifies that find_package(Blast) works from an installed tree. The tiny
# consumer project is generated inline below (not checked into the repo) to
# keep the source tree clean. Only runs on Linux to keep CI fast; the logic
# is platform-agnostic.
# -------------------------------------------------------------------------
install-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Configure Blast
run: >
cmake -B ${{ github.workspace }}/build
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_INSTALL_PREFIX=${{ github.workspace }}/install
-S ${{ github.workspace }}
- name: Build Blast
run: cmake --build ${{ github.workspace }}/build --config Release
- name: Install Blast
run: cmake --install ${{ github.workspace }}/build --config Release
- name: Generate consumer smoke test
run: |
mkdir -p "$RUNNER_TEMP/consumer"
cat > "$RUNNER_TEMP/consumer/CMakeLists.txt" <<'EOF'
cmake_minimum_required(VERSION 3.21)
project(blast_consumer CXX)
find_package(Blast REQUIRED)
add_executable(test_consumer main.cpp)
target_link_libraries(test_consumer PRIVATE Blast::blast)
EOF
cat > "$RUNNER_TEMP/consumer/main.cpp" <<'EOF'
// Consumer smoke test — verifies that find_package(Blast) exposes the
// headers/nlopt AND that the AVX2+FMA contract holds: blast::dot uses
// _mm256_fmadd_pd, so this fails to compile unless the installed
// Blast::blast target propagates the required ISA flags (or the
// #error guard fires). No flags are set here on purpose — that is what
// the test checks.
#include <blast>
#include <iostream>
int main() {
blast::Array a({1.0, 2.0, 3.0, 4.0});
blast::Array b({4.0, 3.0, 2.0, 1.0});
blast::real d = blast::dot(a, b); // exercises the AVX2/FMA path
std::cout << "Blast::dot = " << d << "\n";
return (d == 20.0) ? 0 : 1; // 1*4 + 2*3 + 3*2 + 4*1 = 20
}
EOF
- name: Configure consumer
run: >
cmake -B "$RUNNER_TEMP/consumer/build"
-DCMAKE_BUILD_TYPE=Release
-DCMAKE_PREFIX_PATH=${{ github.workspace }}/install
-S "$RUNNER_TEMP/consumer"
- name: Build consumer
run: cmake --build "$RUNNER_TEMP/consumer/build" --config Release
- name: Run consumer
run: "$RUNNER_TEMP/consumer/build/test_consumer"