diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index 7c93b9ad..abc80f13 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -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 diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index 4fdf2e53..f98c5383 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -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 diff --git a/.travis.yml b/.travis.yml index a7b62deb..241d2ed5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 ) diff --git a/CMakeLists.txt b/CMakeLists.txt index c576a573..6e53797e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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)