diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..9491454 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,35 @@ +name: build +on: [push] +jobs: + build: + runs-on: ${{ matrix.os }} + strategy: + fail-fast: false + matrix: + os: [windows-latest, macos-latest, ubuntu-latest] + build_type: [debug,release] + sanitizer: [""] + include: + - os: macos-latest + build_type: debug + sanitizer: "-fsanitize=address" + steps: + - uses: actions/checkout@v2 + - uses: seanmiddleditch/gha-setup-ninja@master + - uses: ilammy/msvc-dev-cmd@v1 + if: runner.os == 'Windows' + - name: Generating Makefiles + shell: bash + run: | + cmake . -G Ninja \ + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \ + -DCMAKE_CXX_FLAGS=${{ matrix.sanitizer }} \ + -DCMAKE_EXE_LINKER_FLAGS=${{ matrix.sanitizer }} + - name: Compiling + shell: bash + run: | + ninja + - name: Running Tests + shell: bash + run: | + msgpack/tests/Msgpack_tests diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c640340..0000000 --- a/.travis.yml +++ /dev/null @@ -1,25 +0,0 @@ -dist: xenial -sudo: true -language: cpp - -addons: - apt: - sources: - - ubuntu-toolchain-r-test - packages: - - g++-7 - -matrix: - include: - - os: linux - before_install: - - git clone https://github.com/catchorg/Catch2.git - - cd Catch2 - - cmake -Bbuild -H. -DBUILD_TESTING=OFF - - sudo env "PATH=$PATH" cmake --build build/ --target install - - cd .. - -script: - - CXX=/usr/bin/g++-7 CC=/usr/bin/gcc-7 cmake . - - cmake --build . -- -j2 - - ./msgpack/tests/Msgpack_tests \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index ad9937a..53b7fa3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,3 +1,6 @@ cmake_minimum_required(VERSION 3.9) +project(Msgpack LANGUAGES CXX VERSION 1.0) + +option(CPPACK_TESTS "Enable cppack tests" ON) add_subdirectory(msgpack) \ No newline at end of file diff --git a/README.md b/README.md index 1615eb2..7983945 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://travis-ci.com/mikeloomisgg/cppack.svg?branch=master)](https://travis-ci.com/mikeloomisgg/cppack) +[![build](https://github.com/dacap/cppack/actions/workflows/build.yml/badge.svg)](https://github.com/dacap/cppack/actions/workflows/build.yml) # cppack A modern (c++17 required) implementation of the [msgpack spec](https://github.com/msgpack/msgpack/blob/master/spec.md). diff --git a/msgpack/CMakeLists.txt b/msgpack/CMakeLists.txt index 4bee2bc..077168a 100644 --- a/msgpack/CMakeLists.txt +++ b/msgpack/CMakeLists.txt @@ -1,5 +1,4 @@ cmake_minimum_required(VERSION 3.9) -project(Msgpack LANGUAGES CXX VERSION 1.0) list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/cmake) @@ -49,4 +48,6 @@ install(FILES export(EXPORT MsgpackTargets FILE ${CMAKE_CURRENT_BINARY_DIR}/MsgpackTargets.cmake NAMESPACE Msgpack::) export(PACKAGE Msgpack) -add_subdirectory(tests) \ No newline at end of file +if(CPPACK_TESTS) + add_subdirectory(tests) +endif() \ No newline at end of file diff --git a/msgpack/include/msgpack/msgpack.hpp b/msgpack/include/msgpack/msgpack.hpp index a300d5d..284ebdf 100644 --- a/msgpack/include/msgpack/msgpack.hpp +++ b/msgpack/include/msgpack/msgpack.hpp @@ -13,6 +13,8 @@ #include #include #include +#include +#include namespace msgpack { enum class UnpackerError { @@ -33,12 +35,12 @@ struct UnpackerErrCategory : public std::error_category { return "(unrecognized error)"; } }; -}; -const UnpackerErrCategory theUnpackerErrCategory{}; +}; inline std::error_code make_error_code(msgpack::UnpackerError e) { + static UnpackerErrCategory theUnpackerErrCategory; return {static_cast(e), theUnpackerErrCategory}; } } diff --git a/msgpack/tests/CMakeLists.txt b/msgpack/tests/CMakeLists.txt index a9725f2..d0b6b78 100644 --- a/msgpack/tests/CMakeLists.txt +++ b/msgpack/tests/CMakeLists.txt @@ -1,9 +1,12 @@ cmake_minimum_required(VERSION 3.9) -find_package(Catch2 REQUIRED) +include(FetchContent) +FetchContent_Declare(Catch2 + GIT_REPOSITORY https://github.com/catchorg/Catch2.git + GIT_TAG v3.1.0) +FetchContent_MakeAvailable(Catch2) add_executable(Msgpack_tests - main.cpp type_packing_tests.cpp examples.cpp error_handling.cpp @@ -11,13 +14,13 @@ add_executable(Msgpack_tests ) if (MSVC) - target_compile_options(Msgpack_tests PRIVATE /WX /Zc:__cplusplus) + target_compile_options(Msgpack_tests PRIVATE /WX /Zc:__cplusplus /EHsc) else (MSVC) target_compile_options(Msgpack_tests PRIVATE -Wall -Wextra -pedantic -Werror) endif (MSVC) target_link_libraries(Msgpack_tests - Catch2::Catch2 + Catch2::Catch2WithMain Msgpack::Msgpack) set_target_properties(Msgpack_tests PROPERTIES CXX_STANDARD 17) diff --git a/msgpack/tests/error_handling.cpp b/msgpack/tests/error_handling.cpp index 197b3cf..99dda61 100644 --- a/msgpack/tests/error_handling.cpp +++ b/msgpack/tests/error_handling.cpp @@ -2,7 +2,7 @@ // Created by Mike Loomis on 6/29/2019. // -#include +#include #include "msgpack/msgpack.hpp" diff --git a/msgpack/tests/examples.cpp b/msgpack/tests/examples.cpp index 6519c67..d7e768a 100644 --- a/msgpack/tests/examples.cpp +++ b/msgpack/tests/examples.cpp @@ -2,7 +2,7 @@ // Created by Mike Loomis on 6/28/2019. // -#include +#include #include "msgpack/msgpack.hpp" diff --git a/msgpack/tests/main.cpp b/msgpack/tests/main.cpp deleted file mode 100644 index 9673894..0000000 --- a/msgpack/tests/main.cpp +++ /dev/null @@ -1,7 +0,0 @@ -// -// Created by Mike Loomis on 6/22/2019. -// - -#define CATCH_CONFIG_MAIN - -#include diff --git a/msgpack/tests/object_packing_tests.cpp b/msgpack/tests/object_packing_tests.cpp index 6dfb391..50f2399 100644 --- a/msgpack/tests/object_packing_tests.cpp +++ b/msgpack/tests/object_packing_tests.cpp @@ -2,7 +2,7 @@ // Created by Mike Loomis on 7/31/2019. // -#include +#include #include diff --git a/msgpack/tests/type_packing_tests.cpp b/msgpack/tests/type_packing_tests.cpp index a80f21a..02e9b15 100644 --- a/msgpack/tests/type_packing_tests.cpp +++ b/msgpack/tests/type_packing_tests.cpp @@ -2,7 +2,7 @@ // Created by Mike Loomis on 6/22/2019. // -#include +#include #include