Skip to content

Commit

Permalink
Merge pull request #26 from hofmannu/ci-build
Browse files Browse the repository at this point in the history
Create cmake-multi-platform.yml
  • Loading branch information
hofmannu authored Jul 22, 2024
2 parents 8f31aeb + 3d1349e commit 410b764
Show file tree
Hide file tree
Showing 45 changed files with 1,602 additions and 976 deletions.
77 changes: 77 additions & 0 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# This starter workflow is for a CMake project running on multiple platforms. There is a different starter workflow if you just want a single platform.
# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml
name: CMake on multiple platforms

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
runs-on: ${{ matrix.os }}

strategy:
# Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable.
fail-fast: false

# Set up a matrix to run the following 3 configurations:
# 1. <Windows, Release, latest MSVC compiler toolchain on the default runner image, default generator>
# 2. <Linux, Release, latest GCC compiler toolchain on the default runner image, default generator>
# 3. <Linux, Release, latest Clang compiler toolchain on the default runner image, default generator>
#
# To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list.
matrix:
os: [ubuntu-latest]
build_type: [Release]
c_compiler: [gcc, clang]
include:
- os: ubuntu-latest
c_compiler: gcc
cpp_compiler: g++
# define the standard C++ version to use
env:
CXX_STANDARD: 20
- os: ubuntu-latest
c_compiler: clang
cpp_compiler: clang++
# define the standard C++ version to use
env:
CXX_STANDARD: 20

steps:
- uses: actions/checkout@v4

- name: Set reusable strings
# Turn repeated input strings (such as the build output directory) into step outputs. These step outputs can be used throughout the workflow file.
id: strings
shell: bash
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get -y install libxrandr-dev libhdf5-serial-dev libxinerama-dev libxcursor-dev libxi-dev libgl1-mesa-dev
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
-DCMAKE_C_COMPILER=${{ matrix.c_compiler }}
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-S ${{ github.workspace }}
- name: Build
# Build your program with the given configuration. Note that --config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }}

- name: Test
working-directory: ${{ steps.strings.outputs.build-output-dir }}
# Execute tests defined by the CMake configuration. Note that --build-config is needed because the default Windows generator is a multi-config generator (Visual Studio generator).
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
run: ctest --build-config ${{ matrix.build_type }}
64 changes: 64 additions & 0 deletions .github/workflows/deploy-documentation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# Sample workflow for building and deploying a VitePress site to GitHub Pages
#
name: Deploy VitePress site to Pages

on:
# Runs on pushes targeting the `main` branch. Change this to `master` if you're
# using the `master` branch as the default branch.
push:
branches: [main]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
permissions:
contents: read
pages: write
id-token: write

# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: pages
cancel-in-progress: false

jobs:
# Build job
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0 # Not needed if lastUpdated is not enabled
# - uses: pnpm/action-setup@v3 # Uncomment this if you're using pnpm
# - uses: oven-sh/setup-bun@v1 # Uncomment this if you're using Bun
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm # or pnpm / yarn
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Install dependencies
run: npm ci # or pnpm install / yarn install / bun install
- name: Build with VitePress
run: npm run docs:build # or pnpm docs:build / yarn docs:build / bun run docs:build
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: docs/.vitepress/dist

# Deployment job
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
needs: build
runs-on: ubuntu-latest
name: Deploy
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
79 changes: 47 additions & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,15 @@ project(opensaft
LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED true)
set(CMAKE_CXX_STANDARD_REQUIRED True)

if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE RelWithDebInfo)
endif()
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")


option(OPENSAFT_CUDA_SUPPORT "Enable CUDA support" OFF)
option(OPENSAFT_TESTING "Build unit tests" ON)
option(OPENSAFT_GUI "build graphical user interface alongside" OFF)

# prepare for cuda compilation
if (OPENSAFT_CUDA_SUPPORT)
Expand All @@ -37,55 +36,71 @@ set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS}; -x cu -rdc=true -ftz=false -prec-div=tru
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/modules/")

# find dependencies (most of them are handled through FetchContent)
find_package(ImGUI REQUIRED)
find_package(glfw3 REQUIRED)
find_package(OpenGL REQUIRED)
find_package(SDL2 REQUIRED)
find_library(H5CPP_LIB hdf5_cpp)
find_library(H5_LIB hdf5) # todo this sounds fishy that
find_package(ImPlot REQUIRED)
find_package(ImGUIFileDialog REQUIRED)
find_package(CVolume REQUIRED)
find_package(Backward REQUIRED)

# main library holding the backbone of the application
add_library(opensaft STATIC "")

add_subdirectory(src/)

target_link_libraries(opensaft PUBLIC
${ImGUI_LIBRARIES}
${implot_LIBRARIES}
${GLFW_LIBRARIES}
${cvolume_LIBRARIES}
${ImGUIFileDialog_LIBRARIES}
${backward_LIBRARIES}
)

target_include_directories(opensaft PUBLIC
${CMAKE_SOURCE_DIR}/src
${ImGUI_INCLUDE_DIR}
${ImPlot_INCLUDE_DIR}
${ImGUIFileDialog_INCLUDE_DIR}
${OPENGL_INCLUDE_DIRS}
${GLFW3_INCLUDE_DIR}
${cvolume_INCLUDE_DIR}
${backward_INCLUDE_DIR}
)

if (OPENSAFT_GUI)

add_library(opensaft-gui)

find_package(ImGUI REQUIRED)
find_package(GLFW REQUIRED)
find_package(OpenGL REQUIRED)
find_package(ImPlot REQUIRED)
find_package(ImGUIFileDialog REQUIRED)
find_package(Backward REQUIRED)


target_link_libraries(opensaft-gui PUBLIC
${ImGUI_LIBRARIES}
${implot_LIBRARIES}
${GLFW_LIBRARIES}
${cvolume_LIBRARIES}
${ImGUIFileDialog_LIBRARIES}
${backward_LIBRARIES}
)

target_include_directories(opensaft PUBLIC
${CMAKE_SOURCE_DIR}/src
${ImGUI_INCLUDE_DIR}
${ImPlot_INCLUDE_DIR}
${ImGUIFileDialog_INCLUDE_DIR}
${OPENGL_INCLUDE_DIRS}
${GLFW3_INCLUDE_DIR}
${cvolume_INCLUDE_DIR}
${backward_INCLUDE_DIR}
)


# add an executable for the main graphical user interface
add_executable(OpensaftGui src/main.cpp)
if (OPENSAFT_CUDA_SUPPORT)
set_property(TARGET OpensaftGui PROPERTY CUDA_SEPARABLE_COMPILATION ON)
set_property(TARGET OpensaftGui PROPERTY CUDA_ARCHITECTURES 50 75 86)
endif()
target_link_libraries(OpensaftGui PUBLIC opensaft-gui)

install(TARGETS OpensaftGui DESTINATION bin)

endif (OPENSAFT_GUI)


find_library(TERM_LIB curses)

if (OPENSAFT_TESTING)
add_subdirectory(tests)
endif()

# add an executable for the main graphical user interface
add_executable(main_exp src/main.cpp)
if (OPENSAFT_CUDA_SUPPORT)
set_property(TARGET main_exp PROPERTY CUDA_SEPARABLE_COMPILATION ON)
set_property(TARGET main_exp PROPERTY CUDA_ARCHITECTURES 50 75 86)
endif()
target_link_libraries(main_exp PUBLIC opensaft)

install(TARGETS main_exp DESTINATION bin)
25 changes: 22 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# opensaft

::: warning
This project is currently under development and not yet ready for use. Please check back later.
:::

Volumetric synthetic aperture focusing technique (SAFT) for acoustic resolution optoacoustic microscopy and (soon) scanning acoustic microscopy.

This repository contains an implementation of the synthetic aperture focsuing technique purely written in C++ and CUDA. You need a CUDA capable device and Linux installed on your PC to run the fast GPU version of it. A "slow" CPU version is implemented as well. Installation instructions will soon be provided for ArchLinux as well as dataset specifications.
Expand All @@ -21,17 +25,18 @@ Required packages:
- a capable C++ compiler which can be consumed by `CMake`
- `CUDA` for GPU acceleration (can be disabled, not required)
- `hdf5` for dataset import and export
- `libxrandr`, `libxinerama`, `libxcursor`, `libxi`, `libgl1-mesa-dev`: used for GUI framework

Package installation command ArchLinux:

```bash
pacman -S hdf5
pacman -S hdf5 libxrandr libxinerama
```

Package installation command Ubuntu:

```bash
apt-get install libhdf5-serial-dev
apt-get install libhdf5-serial-dev libxrandr-dev libxinerama-dev libxcursor-dev libxi-dev libgl1-mesa-dev
```

Many other dependencies are directly managed through CMake based on `FetchContent`.
Expand Down Expand Up @@ -62,12 +67,26 @@ SAFT induces a strong absorption bias over depth. Absorbance "reconstructed" at

The documentation should be running with `vitepress` and is compiled into a static website that is also published to github pages. All documentation is written in markdown and can be found in the doc folder.

To run the documentation locally, run the following commands:
If this is the first time that you have a look at the documentation, you need to run

```bash
npm install
```

Afterwards, to display the documentation run

```bash
npm run docs:dev
```

To build the static website, run

```bash
npm run docs:build
```

The documentation is published on every merge to `main` to [github pages](https://hofmannu.github.io/opensaft/).

## Literature

- J. Turner et al.: Improved optoacoustic microscopy through three-dimensional spatial impulse response synthetic aperture focusing technique in Optics Letters 39 (12), pp. 3390 - 3393 (2014), [10.1364/OL.39.003390](https://doi.org/10.1364/OL.39.003390)
Expand Down
11 changes: 6 additions & 5 deletions cmake/modules/FindBackward.cmake
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
include(FetchContent)

FetchContent_Declare(backward
GIT_REPOSITORY https://github.com/bombela/backward-cpp
GIT_TAG master # or a version tag, such as v1.6
SYSTEM # optional, the Backward include directory will be treated as system directory
FetchContent_Declare(
backward
GIT_REPOSITORY https://github.com/bombela/backward-cpp
GIT_TAG master # or a version tag, such as v1.6
SYSTEM # optional, the Backward include directory will be treated as system directory
)

FetchContent_GetProperties(backward)
if(NOT backward_POPULATED)
if (NOT backward_POPULATED)
FetchContent_Populate(backward)
add_subdirectory(${backward_SOURCE_DIR} ${backward_BINARY_DIR})
endif()
Expand Down
19 changes: 0 additions & 19 deletions cmake/modules/FindCVolume.cmake

This file was deleted.

2 changes: 1 addition & 1 deletion cmake/modules/FindCatch2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ FetchContent_Declare(
)

FetchContent_GetProperties(catch2)
if(NOT catch2_POPULATED)
if (NOT catch2_POPULATED)
FetchContent_Populate(catch2)
add_subdirectory(${catch2_SOURCE_DIR} ${catch2_BINARY_DIR})
endif()
Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/FindImGUI.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ if (NOT imgui_POPULATED)
# glfw3_LIBRARIES is empty
target_link_libraries(ImGUI_target
PRIVATE
${glfw3_LIBRARIES}
${glfw_LIBRARIES}
${OPENGL_LIBRARIES}
)

Expand Down
Loading

0 comments on commit 410b764

Please sign in to comment.