Add integration tests for cmake (#17)

This commit is contained in:
Jeremy Rifkin 2023-07-23 15:57:44 -04:00 committed by GitHub
parent cfd0a4e762
commit a8169aba8e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 158 additions and 0 deletions

105
.github/workflows/cmake-integration.yml vendored Normal file
View File

@ -0,0 +1,105 @@
name: cmake-integration
on:
push:
pull_request:
# Awful hackery: github.event.workflow_run.head_sha is defined on push, github.event.pull_request.base.sha is defined on
# pull
jobs:
test-linux-fetchcontent:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: test
run: |
tag=$(git rev-parse --abbrev-ref HEAD)
cd ..
cp -rv cpptrace/test/fetchcontent-integration .
mkdir fetchcontent-integration/build
cd fetchcontent-integration/build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCPPTRACE_TAG=$tag
make
./main
test-linux-findpackage:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v2
- name: build
run: |
tag=$(git rev-parse --abbrev-ref HEAD)
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=On
sudo make -j install
cd ../..
cp -rv cpptrace/test/findpackage-integration .
mkdir findpackage-integration/build
cd findpackage-integration/build
cmake .. -DCMAKE_BUILD_TYPE=Debug
make
./main
test-macos-fetchcontent:
runs-on: macos-13
steps:
- uses: actions/checkout@v2
- name: test
run: |
tag=$(git rev-parse --abbrev-ref HEAD)
cd ..
cp -rv cpptrace/test/fetchcontent-integration .
mkdir fetchcontent-integration/build
cd fetchcontent-integration/build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCPPTRACE_TAG=$tag
make
./main
test-macos-findpackage:
runs-on: macos-13
steps:
- uses: actions/checkout@v2
- name: build
run: |
tag=$(git rev-parse --abbrev-ref HEAD)
mkdir build
cd build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DBUILD_SHARED_LIBS=On
sudo make -j install
cd ../..
cp -rv cpptrace/test/findpackage-integration .
mkdir findpackage-integration/build
cd findpackage-integration/build
cmake .. -DCMAKE_BUILD_TYPE=Debug
make
./main
test-mingw-fetchcontent:
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
- name: test
run: |
$tag=$(git rev-parse --abbrev-ref HEAD)
cd ..
cp -Recurse cpptrace/test/fetchcontent-integration .
mkdir fetchcontent-integration/build
cd fetchcontent-integration/build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCPPTRACE_TAG="$tag" -DCMAKE_BUILD_TYPE=g++ "-GUnix Makefiles"
make
.\main.exe
test-windows-fetchcontent:
runs-on: windows-2019
steps:
- uses: actions/checkout@v2
- name: Enable Developer Command Prompt
uses: ilammy/msvc-dev-cmd@v1.10.0
- name: test
run: |
$tag=$(git rev-parse --abbrev-ref HEAD)
cd ..
cp -Recurse cpptrace/test/fetchcontent-integration .
mkdir fetchcontent-integration/build
cd fetchcontent-integration/build
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCPPTRACE_TAG="$tag"
msbuild demo_project.sln
.\Debug\main.exe

View File

@ -4,6 +4,7 @@
[![test](https://github.com/jeremy-rifkin/cpptrace/actions/workflows/test.yml/badge.svg?branch=main)](https://github.com/jeremy-rifkin/cpptrace/actions/workflows/test.yml)
[![performance-test](https://github.com/jeremy-rifkin/cpptrace/actions/workflows/performance-tests.yml/badge.svg?branch=main)](https://github.com/jeremy-rifkin/cpptrace/actions/workflows/performance-tests.yml)
[![lint](https://github.com/jeremy-rifkin/cpptrace/actions/workflows/lint.yml/badge.svg?branch=main)](https://github.com/jeremy-rifkin/cpptrace/actions/workflows/lint.yml)
[![cmake-integration](https://github.com/jeremy-rifkin/cpptrace/actions/workflows/cmake-integration.yml/badge.svg?branch=main)](https://github.com/jeremy-rifkin/cpptrace/actions/workflows/cmake-integration.yml)
<br/>
[![Community Discord Link](https://img.shields.io/badge/Chat%20on%20(the%20very%20small)-Community%20Discord-blue?labelColor=2C3239&color=7289DA&style=flat&logo=discord&logoColor=959DA5)](https://discord.gg/7kv5AuCndG)

View File

@ -0,0 +1,16 @@
cmake_minimum_required(VERSION 3.8)
project(demo_project VERSION 0.0.1 LANGUAGES CXX)
add_executable(main main.cpp)
set(CPPTRACE_TAG "" CACHE STRING "cpptrace git tag")
include(FetchContent)
FetchContent_Declare(
cpptrace
GIT_REPOSITORY https://github.com/jeremy-rifkin/cpptrace.git
GIT_TAG ${CPPTRACE_TAG}
)
FetchContent_MakeAvailable(cpptrace)
target_link_libraries(main cpptrace)

View File

@ -0,0 +1,14 @@
#include <cpptrace/cpptrace.hpp>
void trace() {
cpptrace::print_trace();
}
void foo(int) {
trace();
}
int main() {
foo(0);
}

View File

@ -0,0 +1,8 @@
cmake_minimum_required(VERSION 3.8)
project(demo_project VERSION 0.0.1 LANGUAGES CXX)
add_executable(main main.cpp)
find_package(cpptrace REQUIRED)
target_link_libraries(main cpptrace::cpptrace)

View File

@ -0,0 +1,14 @@
#include <cpptrace/cpptrace.hpp>
void trace() {
cpptrace::print_trace();
}
void foo(int) {
trace();
}
int main() {
foo(0);
}