Skip to content

Commit d543d86

Browse files
authored
Merge pull request #12 from ivan-pi/copilot/add-cmake-ctest-setup
Add minimalistic CMake/CTest build support
2 parents 057a699 + 89edb75 commit d543d86

4 files changed

Lines changed: 48 additions & 0 deletions

File tree

.github/workflows/test.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,24 @@ name: test
33
on: [push, pull_request]
44

55
jobs:
6+
cmake:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: Checkout code
10+
uses: actions/checkout@v4
11+
12+
- name: Install GFortran and LAPACK
13+
run: sudo apt-get install -y gfortran liblapack-dev libblas-dev
14+
15+
- name: Configure
16+
run: cmake -B build -DCMAKE_BUILD_TYPE=Release
17+
18+
- name: Build
19+
run: cmake --build build
20+
21+
- name: Test
22+
run: ctest --test-dir build --output-on-failure
23+
624
gfortran-nix:
725
runs-on: ${{ matrix.os }}
826
strategy:

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
cmake_minimum_required(VERSION 3.14)
2+
3+
project(stiff3
4+
VERSION 0.1.0
5+
DESCRIPTION "Adaptive solver for stiff systems of ODEs"
6+
LANGUAGES Fortran
7+
)
8+
9+
# Find LAPACK (which typically pulls in BLAS as well)
10+
find_package(LAPACK REQUIRED)
11+
12+
include(CTest)
13+
14+
add_subdirectory(src)
15+
add_subdirectory(example)

example/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
foreach(example robertson vanpol)
2+
add_executable(${example} ${example}.f90)
3+
target_link_libraries(${example} PRIVATE stiff3)
4+
add_test(NAME ${example} COMMAND ${example})
5+
endforeach()

src/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
add_library(stiff3
2+
stiff3_linalg.f90
3+
stiff3_solver.f90
4+
)
5+
6+
target_link_libraries(stiff3 PUBLIC ${LAPACK_LIBRARIES})
7+
8+
target_include_directories(stiff3 PUBLIC
9+
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
10+
)

0 commit comments

Comments
 (0)