Skip to content

MSVC Build Support #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 24, 2023
Merged
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
39 changes: 39 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,29 @@ jobs:
${{ matrix.package }}/test/*
fail-under-line: 100

debug-msvc:
runs-on: windows-latest
strategy:
matrix:
package: [error]
steps:
- name: Checkout repository
uses: actions/checkout@v3.5.3

- name: Configure CMake
run: |
cmake ${{ matrix.package }} `
-B ${{ matrix.package }}/build `
-D CMAKE_CXX_COMPILER=cl `
-D CMAKE_CXX_FLAGS=/WX `
-D BUILD_TESTING=ON

- name: Build project
run: cmake --build ${{ matrix.package }}/build

- name: Run unit tests
run: ctest --test-dir ${{ matrix.package }}/build --output-on-failure --no-tests=error

release:
runs-on: ubuntu-latest
strategy:
Expand All @@ -58,3 +81,19 @@ jobs:
with:
source-dir: ${{ matrix.package }}
build-dir: ${{ matrix.package }}/build

release-msvc:
runs-on: windows-latest
strategy:
matrix:
package: [error]
steps:
- name: Checkout repository
uses: actions/checkout@v3.5.3

- name: Configure and build project
uses: threeal/cmake-action@v1.1.0
with:
source-dir: ${{ matrix.package }}
build-dir: ${{ matrix.package }}/build
cxx-compiler: cl
11 changes: 9 additions & 2 deletions error/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@ cmake_minimum_required(VERSION 3.0)

project(error)

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wnon-virtual-dtor -Wpedantic")
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive- /W4 /w14640 /EHsc")
else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wnon-virtual-dtor -Wpedantic")
endif()

set(CMAKE_CXX_STANDARD 11)

include(cmake/CPM.cmake)
Expand All @@ -21,7 +26,9 @@ if(CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
cpmaddpackage("gh:catchorg/Catch2@3.3.2")
include("${Catch2_SOURCE_DIR}/extras/Catch.cmake")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -fPIC -O0")
if(NOT MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -fPIC -O0")
endif()

add_executable(error_test test/error_test.cpp)
target_link_libraries(error_test PRIVATE error Catch2::Catch2WithMain)
Expand Down