Skip to content

Commit 9d315ac

Browse files
committed
Adding libintx ci for cpp build + test
1 parent dd5bb8b commit 9d315ac

3 files changed

Lines changed: 93 additions & 19 deletions

File tree

.github/workflows/ci.yml

Lines changed: 79 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
name: libintx CI
22

3-
on: [push]
4-
5-
env:
6-
CMAKE_BUILD_PARALLEL_LEVEL : 4
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
77

88
defaults:
99
run:
@@ -16,31 +16,92 @@ jobs:
1616
strategy:
1717
fail-fast: false
1818
matrix:
19-
os : [ macos-15 ]
20-
cxx : [ clang++ ]
21-
build_type : [ Debug ]
19+
os :
20+
- ubuntu-latest
21+
- ubuntu-24.04-arm
22+
23+
compiler :
24+
- clang
25+
- gcc
26+
27+
build_type :
28+
# - Debug
29+
- Release
2230

23-
name: "${{ matrix.os }}: ${{ matrix.cxx }} ${{ matrix.build_type }}"
31+
simd:
32+
- ON
33+
- OFF
34+
35+
name: "${{ matrix.os }}: ${{ matrix.compiler }} ${{ matrix.build_type }} ${{matrix.simd == 'ON' && '(simd)' || ''}}"
2436
runs-on: ${{ matrix.os }}
25-
env:
26-
CXX : ${{ matrix.cxx }}
27-
CMAKE_CONFIG : >
28-
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
29-
-DLIBINTX_MAX_L=2
30-
-DLIBINTX_SIMD=OFF
3137

3238
steps:
33-
- uses: actions/checkout@v3
3439

35-
- name: "Configure: ${{ env.CMAKE_CONFIG }}"
40+
- uses: actions/checkout@v4
41+
42+
- name: Setup Cache
43+
uses: actions/cache@v4
44+
with:
45+
path: |
46+
~/.ccache
47+
key: ${{ runner.os }}-${{ runner.arch }}-${{ matrix.compiler }}-${{ matrix.build_type }}-${{ matrix.simd }}-${{ hashFiles('**/CMakeLists.txt') }}
48+
restore-keys: |
49+
${{ runner.os }}-${{ runner.arch }}-${{ matrix.compiler }}-${{ matrix.build_type }}-${{ matrix.simd }}
50+
51+
- name: Set compiler
52+
run: |
53+
if [[ "${{ matrix.compiler }}" == "gcc" ]]; then
54+
echo "CC=gcc" >> $GITHUB_ENV
55+
echo "CXX=g++" >> $GITHUB_ENV
56+
elif [[ "${{ matrix.compiler }}" == "clang" ]]; then
57+
echo "CC=clang" >> $GITHUB_ENV
58+
echo "CXX=clang++" >> $GITHUB_ENV
59+
else
60+
echo "Unsupported compiler: ${{ matrix.compiler }}"
61+
exit 1
62+
fi
63+
64+
- name: Verify compiler
65+
run: |
66+
set -x;
67+
$CC --version
68+
$CXX --version
69+
70+
- name: Install Build Dependencies
3671
run: |
3772
set -x;
38-
cmake -B${{github.workspace}}/build $CMAKE_CONFIG
73+
sudo apt-get update && sudo apt-get install -y \
74+
ccache \
75+
libopenblas-dev \
76+
liblapacke-dev
77+
78+
- name: Set up ccache environment
79+
run: |
80+
echo "CCACHE_DIR=$HOME/.ccache" >> $GITHUB_ENV
81+
echo "CCACHE_MAXSIZE=1G" >> $GITHUB_ENV
82+
83+
- name: ccache stats
84+
run: |
85+
ccache --zero-stats && ccache --show-stats
86+
87+
- name: Configure
88+
run: |
89+
set -x;
90+
cmake -S . -B ./build -G "Ninja Multi-Config" \
91+
-DLIBINTX_MAX_L=2 \
92+
-DLIBINTX_SIMD=${{matrix.simd}} \
93+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
94+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
95+
-DCMAKE_BUILD_TYPE:STRING=${{matrix.build_type}}
96+
3997
4098
- name: Build
4199
working-directory: ${{github.workspace}}/build
42100
run: |
43-
cmake --build . --target all all.tests
101+
cmake --build . --target all all.tests --config ${{matrix.build_type}}
102+
103+
- name: Show ccache stats (after build)
104+
run: ccache -s
44105

45106
- name: Test
46107
working-directory: ${{github.workspace}}/build

CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,19 @@ if (TARGET LAPACK::LAPACK)
6262
unset(_lib)
6363
endif()
6464

65+
find_package(LAPACKE QUIET)
66+
if (NOT TARGET LAPACKE::LAPACKE)
67+
find_package(PkgConfig REQUIRED)
68+
pkg_check_modules(LAPACKE_PC lapacke)
69+
if (LAPACKE_PC_FOUND)
70+
message(STATUS "Found LAPACKE via pkg-config")
71+
set(LAPACKE_INCLUDE_DIRS ${LAPACKE_PC_INCLUDE_DIRS})
72+
set(LAPACKE_LIBRARIES ${LAPACKE_PC_LIBRARIES})
73+
else()
74+
message(FATAL_ERROR "LAPACKE not found via find_package or pkg-config")
75+
endif()
76+
endif()
77+
6578
set(LIBINTX_CBLAS_H "" CACHE STRING "")
6679
set(LIBINTX_LAPACKE_H "" CACHE STRING "")
6780
mark_as_advanced(LIBINTX_CBLAS_H LIBINTX_LAPACKE_H)

src/libintx/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ if (LIBINTX_APPLE_ACCELERATE)
1818
endif()
1919

2020
if (TARGET LAPACK::LAPACK)
21-
target_link_libraries(libintx.blas LAPACK::LAPACK)
21+
target_link_libraries(libintx.blas LAPACK::LAPACK ${LAPACKE_LIBRARIES})
2222
endif()
2323

2424
install(

0 commit comments

Comments
 (0)