Skip to content

Commit

Permalink
Treat warnings as errors
Browse files Browse the repository at this point in the history
  • Loading branch information
badaix committed Jun 9, 2024
1 parent a77585d commit 671a5f8
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 5 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ jobs:
- name: print environment
run: env
- name: configure
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
run: cmake -S . -B build -DWERROR=ON -DCMAKE_BUILD_TYPE=Release
- name: build
run: cmake --build build --parallel 3
run: cmake --build build --parallel 8
env:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
Expand Down Expand Up @@ -157,11 +157,11 @@ jobs:
- name: print environment
run: env
- name: configure
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
run: cmake -S . -B build -DWERROR=ON -DCMAKE_BUILD_TYPE=Release
env:
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode }}.app/Contents/Developer
- name: build
run: cmake --build build --parallel 3 --verbose
run: cmake --build build --parallel 8 --verbose
- name: test
run: ./build/test/jsonrpcpp_test

Expand Down Expand Up @@ -195,6 +195,6 @@ jobs:
-DVCPKG_TARGET_TRIPLET="x64-windows" `
-DCMAKE_BUILD_TYPE=Release `"
- name: build
run: cmake --build build --config Release --parallel 3 --verbose
run: cmake --build build --config Release --parallel 8 --verbose
- name: test
run: .\build\test\Release\jsonrpcpp_test.exe
20 changes: 20 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ set(PROJECT_URL "https://github.com/badaix/jsonrpcpp")

option(BUILD_EXAMPLE "Build example (build jsonrpcpp_example demo)" ON)
option(BUILD_TESTS "Build tests" ON)
option(WERROR "Treat warnings as errors" OFF)

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

if(MSVC)
# warning level 4 and all warnings as errors warning C4505: 'getArch':
# unreferenced local function has been removed warning C4458: declaration of
# 'size' hides class member warning C4459: declaration of 'query' hides global
# declaration
add_compile_options(/W4 /wd4458 /wd4459 /wd4505)
if(WERROR)
add_compile_options(/WX)
endif()
else()
# lots of warnings and all warnings as errors
add_compile_options(-Wall -Wextra -pedantic)

if(WERROR)
add_compile_options(-Werror)
endif()
endif()


if (BUILD_EXAMPLE)
add_subdirectory(example)
endif (BUILD_EXAMPLE)
Expand Down

0 comments on commit 671a5f8

Please sign in to comment.