Skip to content

Commit 671a5f8

Browse files
committed
Treat warnings as errors
1 parent a77585d commit 671a5f8

File tree

2 files changed

+25
-5
lines changed

2 files changed

+25
-5
lines changed

.github/workflows/ci.yml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,9 @@ jobs:
9494
- name: print environment
9595
run: env
9696
- name: configure
97-
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
97+
run: cmake -S . -B build -DWERROR=ON -DCMAKE_BUILD_TYPE=Release
9898
- name: build
99-
run: cmake --build build --parallel 3
99+
run: cmake --build build --parallel 8
100100
env:
101101
CC: ${{ matrix.cc }}
102102
CXX: ${{ matrix.cxx }}
@@ -157,11 +157,11 @@ jobs:
157157
- name: print environment
158158
run: env
159159
- name: configure
160-
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
160+
run: cmake -S . -B build -DWERROR=ON -DCMAKE_BUILD_TYPE=Release
161161
env:
162162
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
163163
- name: build
164-
run: cmake --build build --parallel 3 --verbose
164+
run: cmake --build build --parallel 8 --verbose
165165
- name: test
166166
run: ./build/test/jsonrpcpp_test
167167

@@ -195,6 +195,6 @@ jobs:
195195
-DVCPKG_TARGET_TRIPLET="x64-windows" `
196196
-DCMAKE_BUILD_TYPE=Release `"
197197
- name: build
198-
run: cmake --build build --config Release --parallel 3 --verbose
198+
run: cmake --build build --config Release --parallel 8 --verbose
199199
- name: test
200200
run: .\build\test\Release\jsonrpcpp_test.exe

CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ set(PROJECT_URL "https://github.com/badaix/jsonrpcpp")
1818

1919
option(BUILD_EXAMPLE "Build example (build jsonrpcpp_example demo)" ON)
2020
option(BUILD_TESTS "Build tests" ON)
21+
option(WERROR "Treat warnings as errors" OFF)
2122

2223
set(CMAKE_CXX_STANDARD 11)
2324
set(CMAKE_CXX_EXTENSIONS OFF)
@@ -35,6 +36,25 @@ include_directories(
3536
install(FILES include/jsonrpcpp.hpp include/json.hpp
3637
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/jsonrpcpp")
3738

39+
if(MSVC)
40+
# warning level 4 and all warnings as errors warning C4505: 'getArch':
41+
# unreferenced local function has been removed warning C4458: declaration of
42+
# 'size' hides class member warning C4459: declaration of 'query' hides global
43+
# declaration
44+
add_compile_options(/W4 /wd4458 /wd4459 /wd4505)
45+
if(WERROR)
46+
add_compile_options(/WX)
47+
endif()
48+
else()
49+
# lots of warnings and all warnings as errors
50+
add_compile_options(-Wall -Wextra -pedantic)
51+
52+
if(WERROR)
53+
add_compile_options(-Werror)
54+
endif()
55+
endif()
56+
57+
3858
if (BUILD_EXAMPLE)
3959
add_subdirectory(example)
4060
endif (BUILD_EXAMPLE)

0 commit comments

Comments
 (0)