Skip to content
Open
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
51 changes: 44 additions & 7 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,58 @@ name: CMake
on: [push, pull_request]

jobs:
build:
runs-on: ubuntu-latest

build_and_test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
COMPILER: [gcc, clang]
LIBMBUS_SANITIZE_MEMORY: ["ON", "OFF"]

steps:
- name: setup (linux)
if: startsWith(matrix.os, 'ubuntu') && startsWith(matrix.COMPILER, 'clang')
run: |
sudo apt install clang

- uses: actions/checkout@v2
- name: build examples and tests
run: rm -rf build || true && mkdir build && cd build && cmake .. -DLIBMBUS_BUILD_EXAMPLES=ON -DLIBMBUS_BUILD_TESTS=ON -DLIBMBUS_ENABLE_COVERAGE=ON && cmake --build . -j && cd ..
run: |
if [[ ${{matrix.COMPILER}} == *"clang"* ]]; then
export CC=clang
export CXX=clang++
fi
rm -rf build || true
mkdir build
cd build
cmake .. \
-DLIBMBUS_BUILD_EXAMPLES=ON \
-DLIBMBUS_BUILD_TESTS=ON \
-DLIBMBUS_ENABLE_COVERAGE=ON \
-DLIBMBUS_SANITIZE_MEMORY=${{matrix.LIBMBUS_SANITIZE_MEMORY}}
cmake --build . -j
cd ..

- name: generate test frames
run: ./test/generate-xml.sh test/test-frames

- name: install and run gcovr
if: startsWith(matrix.COMPILER, 'gcc')
run: sudo pip install gcovr && gcovr build/.

debian:
debian_package:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: build debian package
run: rm -rf build || true && mkdir build && cd build && cmake .. -DLIBMBUS_PACKAGE_DEB=ON && cpack .. && sudo dpkg -i *.deb && ls /usr/lib
run: |
rm -rf build || true
mkdir build
cd build
cmake .. \
-DLIBMBUS_PACKAGE_DEB=ON
cpack .. && sudo dpkg -i *.deb && ls /usr/lib

doc:
runs-on: ubuntu-latest
Expand All @@ -34,5 +65,11 @@ jobs:
run: sudo apt install -y doxygen

- name: build doxygen documentation
run: rm -rf build || true && mkdir build && cd build && cmake .. -DLIBMBUS_BUILD_DOCS=ON && cmake --build . --target doc
run: |
rm -rf build || true
mkdir build
cd build
cmake .. \
-DLIBMBUS_BUILD_DOCS=ON
cmake --build . --target doc

15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ option(LIBMBUS_PACKAGE_DEB "build debian package" OFF)
option(LIBMBUS_PACKAGE_RPM "build rpm package" OFF)
option(LIBMBUS_BUILD_DOCS "build documentation" OFF)
option(BUILD_SHARED_LIBS "build shared lib" ON)
option(LIBMBUS_SANITIZE_MEMORY "sanitize memory" OFF)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
Expand Down Expand Up @@ -72,6 +73,20 @@ if(LIBMBUS_ENABLE_COVERAGE)
endif()
endif()

if(LIBMBUS_SANITIZE_MEMORY)
if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
message(STATUS "Sanitizing memory...")
set(CMAKE_BUILD_TYPE DEBUG)
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=memory -g")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=memory -g")
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=memory ")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=memory")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=memory")
else()
message(STATUS "LIBMBUS_SANITIZE_MEMORY only available with clang...")
endif()
endif()

include(CheckIncludeFile)

check_include_file(dlfcn.h HAVE_DLFCN_H)
Expand Down