Skip to content

Commit

Permalink
Replace Boost.Test with Catch2
Browse files Browse the repository at this point in the history
  • Loading branch information
mhekkel committed Nov 17, 2023
1 parent 70e9cf6 commit 0750094
Show file tree
Hide file tree
Showing 4 changed files with 189 additions and 171 deletions.
16 changes: 0 additions & 16 deletions .github/workflows/cmake-multi-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,7 @@ jobs:
run: |
echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT"
- name: Install dependencies Ubuntu
if: matrix.os == 'ubuntu-latest'
run: >
sudo apt-get update && sudo apt-get install libboost-dev
- name: Install Boost Windows
if: matrix.os == 'windows-latest'
uses: MarkusJx/[email protected]
id: install-boost
with:
boost_version: 1.82.0
platform_version: 2019
toolset: msvc

- name: Configure CMake
env:
BOOST_ROOT: ${{ steps.install-boost.outputs.BOOST_ROOT }}
run: >
cmake -B ${{ steps.strings.outputs.build-output-dir }}
-DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }}
Expand Down
18 changes: 15 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -129,19 +129,31 @@ install(
DESTINATION ${CONFIG_LOC})

if(BUILD_TESTING)
find_package(Boost REQUIRED)
find_package(Catch2 3 QUIET)

if(NOT Catch2_FOUND)
Include(FetchContent)

FetchContent_Declare(
Catch2
GIT_REPOSITORY https://github.com/catchorg/Catch2.git
GIT_TAG v3.4.0 # or a later release
)

FetchContent_MakeAvailable(Catch2)
endif()

add_executable(libmcfp-unit-test ${PROJECT_SOURCE_DIR}/test/unit-test.cpp)

target_link_libraries(libmcfp-unit-test libmcfp::libmcfp Boost::boost)
target_link_libraries(libmcfp-unit-test libmcfp::libmcfp Catch2::Catch2)

if(MSVC)
# Specify unwind semantics so that MSVC knowns how to handle exceptions
target_compile_options(libmcfp-unit-test PRIVATE /EHsc)
endif()

add_test(NAME libmcfp-unit-test
COMMAND $<TARGET_FILE:libmcfp-unit-test> -- ${PROJECT_SOURCE_DIR}/test)
COMMAND $<TARGET_FILE:libmcfp-unit-test> --work-dir ${PROJECT_SOURCE_DIR}/test)
endif()

if(BUILD_DOCUMENTATION)
Expand Down
1 change: 1 addition & 0 deletions changelog
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Version 1.2.5
- Replace test for _MSC_VER with more generic _WIN32
- Replace Boost.Test with Catch2

Version 1.2.4
- Simpler get (added a version without template arguments)
Expand Down
Loading

0 comments on commit 0750094

Please sign in to comment.