Skip to content

Commit

Permalink
Add CMake 3.14 CI
Browse files Browse the repository at this point in the history
  • Loading branch information
cschreib committed Sep 5, 2023
1 parent 3d72a8b commit e4689a0
Show file tree
Hide file tree
Showing 5 changed files with 100 additions and 2 deletions.
73 changes: 72 additions & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI
name: cmake

on:
workflow_dispatch:
Expand All @@ -11,9 +11,80 @@ env:
EM_VERSION: 3.1.35
EM_CACHE_FOLDER: 'emsdk-cache'
CODECOV_TOKEN: 'f8197851-e753-4291-a835-2d76090f2c92'
CMAKE_INSTALL_VERSION: 3.14.7

jobs:
install:
strategy:
fail-fast: false
matrix:
platform:
- { name: Ubuntu GCC static, flags: "", test-flags: ""}
- { name: Ubuntu GCC header-only, flags: "-DSNITCH_HEADER_ONLY=1", test-flags: "-DHEADER_ONLY=yes"}
- { name: Ubuntu GCC shared, flags: "-DBUILD_SHARED_LIBS=1", test-flags: ""}
build-type:
- Release

name: ${{matrix.platform.name}} ${{matrix.build-type}}
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3
with:
submodules: 'recursive'

- name: Setup GCC
shell: bash
run: |
sudo apt install g++-11
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave /usr/bin/g++ g++ /usr/bin/g++-11 --slave /usr/bin/gcov gcov /usr/bin/gcov-11
sudo update-alternatives --set gcc /usr/bin/gcc-11
- name: Setup CMake
shell: bash
run: |
wget -q https://github.com/Kitware/CMake/releases/download/v${CMAKE_VERSION}/cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz
tar -xvzf cmake-${CMAKE_VERSION}-Linux-x86_64.tar.gz -C "${{github.workspace}}"
echo "${{github.workspace}}/cmake-${CMAKE_VERSION}-Linux-x86_64/bin" >> ${GITHUB_PATH}
- name: Create Build Environment
shell: bash
run: |
cmake --version
cmake -E make_directory ${{github.workspace}}/build
- name: Configure CMake
shell: bash
working-directory: ${{github.workspace}}/build
run: cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=${{github.workspace}}/install ${{matrix.platform.flags}}

- name: Build
shell: bash
working-directory: ${{github.workspace}}/build
run: cmake --build . --parallel 2

- name: Install
shell: bash
working-directory: ${{github.workspace}}/build
run: make install

- name: Build test
shell: bash
working-directory: ${{github.workspace}}/tests/install_tests
run: |
cmake -E make_directory build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=${{github.workspace}}/install ${{matrix.platform.test-flags}}
cmake --build .
- name: Run test
shell: bash
working-directory: ${{github.workspace}}/tests/install_tests
run: ./build/standalone

build:
needs: install
strategy:
fail-fast: false
matrix:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/meson.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI_meson
name: meson

on:
workflow_dispatch:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ doc/html/
snitch.sublime-workspace
tests/approval_tests/data/actual
tests/approval_tests/data/blanked
install/
15 changes: 15 additions & 0 deletions tests/install_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
cmake_minimum_required(VERSION 3.8)
project(test_package LANGUAGES CXX)

find_package(snitch REQUIRED CONFIG)

add_executable(standalone standalone.cpp)

if (HEADER_ONLY)
target_compile_definitions(standalone PRIVATE HEADER_ONLY)
target_link_libraries(standalone PRIVATE snitch::snitch-header-only)
else()
target_link_libraries(standalone PRIVATE snitch::snitch)
endif()

target_compile_features(standalone PRIVATE cxx_std_20)
11 changes: 11 additions & 0 deletions tests/install_tests/standalone.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#if defined(HEADER_ONLY)
# define SNITCH_IMPLEMENTATION
# include <snitch/snitch_all.hpp>
#else
# include <snitch/snitch_macros_check.hpp>
# include <snitch/snitch_macros_test_case.hpp>
#endif

TEST_CASE("compiles and runs") {
REQUIRE(true == !false);
}

0 comments on commit e4689a0

Please sign in to comment.