Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ jobs:
- name: Build cpp example
run: |
just cmake_source_dir=ccp/example cmake_build_dir=cpp/example/build build-cpp
- name: Test cpp as external project
run: |
cd cpp/test/external_project
cmake -GNinja -S . -B build/
ninja -C build
- id: prep
name: Prepare deployment
run: |
Expand Down
1 change: 1 addition & 0 deletions cpp/test/external_project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
build/
21 changes: 21 additions & 0 deletions cpp/test/external_project/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (C) 2026 University College London
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.12.0)
cmake_policy(SET CMP0074 NEW) # find_package() uses <PackageName>_ROOT variables

project(PETSIRDtest VERSION 0.1 LANGUAGES CXX)

find_program(CCACHE_PROGRAM ccache)
if(CCACHE_PROGRAM)
set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "${CCACHE_PROGRAM}")
message(STATUS "ccache found, so we will use it.")
endif()

find_package(PETSIRD CONFIG REQUIRED)

add_executable(minimal_test minimal_test.cpp)
target_link_libraries(minimal_test PETSIRD::petsird)

add_executable(minimal_test_helpers minimal_test_helpers.cpp)
target_link_libraries(minimal_test_helpers PETSIRD::petsird_helpers)
7 changes: 7 additions & 0 deletions cpp/test/external_project/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Test files for using PETSIRD from C++ with CMake

This directory contains test files for a minimal test if
CMake can find PETSIRD with `find_package`, and if
The C++ files compile and link.

There is currently no run-time test.
26 changes: 26 additions & 0 deletions cpp/test/external_project/minimal_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
Copyright (C) 2026 University College London

SPDX-License-Identifier: Apache-2.0
*/

// (un)comment if you want HDF5 or binary output
#define USE_HDF5

#ifdef USE_HDF5
# include "petsird/hdf5/protocols.h"
using petsird::hdf5::PETSIRDReader;
#else
# include "petsird/binary/protocols.h"
using petsird::binary::PETSIRDReader;
#endif

int
main(int, char const* argv[])
{
PETSIRDReader reader(argv[1]);
petsird::Header header;
reader.ReadHeader(header);

return 0;
}
29 changes: 29 additions & 0 deletions cpp/test/external_project/minimal_test_helpers.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
Copyright (C) 2026 University College London

SPDX-License-Identifier: Apache-2.0
*/

// (un)comment if you want HDF5 or binary output
#define USE_HDF5

#ifdef USE_HDF5
# include "petsird/hdf5/protocols.h"
using petsird::hdf5::PETSIRDReader;
#else
# include "petsird/binary/protocols.h"
using petsird::binary::PETSIRDReader;
#endif
#include "petsird_helpers.h"
#include "petsird_helpers/geometry.h"
#include "petsird_helpers/create.h"

int
main(int, char const* argv[])
{
PETSIRDReader reader(argv[1]);
petsird::Header header;
reader.ReadHeader(header);

return 0;
}