Skip to content

Commit f9b39f8

Browse files
authored
chore: merge pull request #20 from threeal/msvc-build-support
MSVC Build Support
2 parents ae1cc39 + ae76e70 commit f9b39f8

File tree

2 files changed

+48
-2
lines changed

2 files changed

+48
-2
lines changed

.github/workflows/build.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,29 @@ jobs:
4444
${{ matrix.package }}/test/*
4545
fail-under-line: 100
4646

47+
debug-msvc:
48+
runs-on: windows-latest
49+
strategy:
50+
matrix:
51+
package: [error]
52+
steps:
53+
- name: Checkout repository
54+
uses: actions/checkout@v3.5.3
55+
56+
- name: Configure CMake
57+
run: |
58+
cmake ${{ matrix.package }} `
59+
-B ${{ matrix.package }}/build `
60+
-D CMAKE_CXX_COMPILER=cl `
61+
-D CMAKE_CXX_FLAGS=/WX `
62+
-D BUILD_TESTING=ON
63+
64+
- name: Build project
65+
run: cmake --build ${{ matrix.package }}/build
66+
67+
- name: Run unit tests
68+
run: ctest --test-dir ${{ matrix.package }}/build --output-on-failure --no-tests=error
69+
4770
release:
4871
runs-on: ubuntu-latest
4972
strategy:
@@ -58,3 +81,19 @@ jobs:
5881
with:
5982
source-dir: ${{ matrix.package }}
6083
build-dir: ${{ matrix.package }}/build
84+
85+
release-msvc:
86+
runs-on: windows-latest
87+
strategy:
88+
matrix:
89+
package: [error]
90+
steps:
91+
- name: Checkout repository
92+
uses: actions/checkout@v3.5.3
93+
94+
- name: Configure and build project
95+
uses: threeal/cmake-action@v1.1.0
96+
with:
97+
source-dir: ${{ matrix.package }}
98+
build-dir: ${{ matrix.package }}/build
99+
cxx-compiler: cl

error/CMakeLists.txt

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,12 @@ cmake_minimum_required(VERSION 3.0)
22

33
project(error)
44

5-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wnon-virtual-dtor -Wpedantic")
5+
if(MSVC)
6+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /permissive- /W4 /w14640 /EHsc")
7+
else()
8+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wnon-virtual-dtor -Wpedantic")
9+
endif()
10+
611
set(CMAKE_CXX_STANDARD 11)
712

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

24-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -fPIC -O0")
29+
if(NOT MSVC)
30+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -fPIC -O0")
31+
endif()
2532

2633
add_executable(error_test test/error_test.cpp)
2734
target_link_libraries(error_test PRIVATE error Catch2::Catch2WithMain)

0 commit comments

Comments
 (0)