Add WERROR option to cmake

This commit is contained in:
badaix 2020-11-28 23:14:49 +01:00
parent aab3c343d0
commit b7c69ab85a
4 changed files with 13 additions and 6 deletions

View file

@ -30,6 +30,6 @@ jobs:
#- name: ccache dump config
# run: ccache -p
- name: cmake build
run: cmake -S . -B build -DBOOST_ROOT=boost_1_74_0 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_FLAGS="-I/usr/local/include"
run: cmake -S . -B build -DBOOST_ROOT=boost_1_74_0 -DCMAKE_BUILD_TYPE=Release -DWERROR=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_FLAGS="-I/usr/local/include"
- name: cmake make
run: cmake --build build --parallel 3

View file

@ -31,7 +31,7 @@ jobs:
#- name: ccache dump config
# run: ccache -p
- name: cmake build
run: cmake -S . -B build -DBOOST_ROOT=boost_1_74_0 -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
run: cmake -S . -B build -DBOOST_ROOT=boost_1_74_0 -DCMAKE_BUILD_TYPE=Release -DWERROR=ON -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
- name: cmake make
run: cmake --build build --parallel 3
- name: debian package

View file

@ -199,9 +199,9 @@ script:
- |
(
if [ "$TRAVIS_OS_NAME" != 'windows' ]; then
cmake -DCMAKE_BUILD_TYPE=Release .. && make && sudo make install
cmake -DCMAKE_BUILD_TYPE=Release -DWERROR=ON .. && make && sudo make install
else
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows ..
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows -DCMAKE_BUILD_TYPE=Release -DWERROR=ON ..
cmake --build . --config Release
fi
)

View file

@ -7,15 +7,22 @@ set(PROJECT_URL "https://github.com/badaix/snapcast")
option(BUILD_SHARED_LIBS "Build snapcast in a shared context" ON)
option(BUILD_STATIC_LIBS "Build snapcast in a static context" ON)
option(BUILD_TESTS "Build tests (run tests with make test)" ON)
option(WERROR "Treat warnings as errors" OFF)
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
add_compile_options(/W4 /WX /wd4458 /wd4505)
add_compile_options(/W4 /wd4458 /wd4505)
if (WERROR)
add_compile_options(/WX)
endif()
else()
# lots of warnings and all warnings as errors
add_compile_options(-Wall -Wextra -pedantic -Werror -Wno-unused-function)
add_compile_options(-Wall -Wextra -pedantic -Wno-unused-function)
if (WERROR)
add_compile_options(-Werror)
endif()
endif()
include(GNUInstallDirs)