From d2816e0b90cf78477f799af405e92fb6e6ee0558 Mon Sep 17 00:00:00 2001 From: nircoe Date: Sun, 27 Sep 2026 11:51:02 +0300 Subject: [PATCH 1/2] [Build]: Enable warnings-as-errors --- CMakeLists.txt | 2 ++ cmake/utils.cmake | 8 ++++++++ src/logcoe.cpp | 19 +++++++++---------- tests/CMakeLists.txt | 4 ++++ tests/logcoe_thread_test.cpp | 6 +++--- 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5d6d118..aca8234 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,6 +19,8 @@ target_include_directories(logcoe include(cmake/utils.cmake) +enable_strict_warnings(logcoe) + option(LOGCOE_BUILD_TESTS "Build the logcoe test suite" OFF) if(LOGCOE_BUILD_TESTS) add_subdirectory(tests) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index 5b6fcda..6903c01 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -53,3 +53,11 @@ function(ignore_external_warnings target_name) message(WARNING "Target ${target_name} not found") endif() endfunction() + +function(enable_strict_warnings target_name) + if(MSVC) + target_compile_options(${target_name} PRIVATE /W4 /WX) + else() + target_compile_options(${target_name} PRIVATE -Werror -Wall -Wextra -Wpedantic) + endif() +endfunction() diff --git a/src/logcoe.cpp b/src/logcoe.cpp index 067eec3..592daa2 100644 --- a/src/logcoe.cpp +++ b/src/logcoe.cpp @@ -358,25 +358,24 @@ namespace namespace logcoe { #ifdef NDEBUG - void initialize(LogLevel level, const std::string &defaultSource, bool enableConsole, - bool enableFile, const std::string &filename) { } + void initialize(LogLevel, const std::string &, bool, bool, const std::string &) { } void shutdown() { } - void setLogLevel(LogLevel level) { } - void setConsoleOutput(std::ostream &stream) { } - bool setFileOutput(const std::string &filename) { return false; } + void setLogLevel(LogLevel) { } + void setConsoleOutput(std::ostream &) { } + bool setFileOutput(const std::string &) { return false; } void disableConsoleOutput() { } void disableFileOutput() { } - void setTimeFormat(const std::string &format) { } + void setTimeFormat(const std::string &) { } bool isInitialized() { return false; } LogLevel getLogLevel() { return LogLevel::NONE; } - void debug(const std::string &message, const std::string &source, bool flush) { } - void info(const std::string &message, const std::string &source, bool flush) { } - void warning(const std::string &message, const std::string &source, bool flush) { } - void error(const std::string &message, const std::string &source, bool flush) { } + void debug(const std::string &, const std::string &, bool) { } + void info(const std::string &, const std::string &, bool) { } + void warning(const std::string &, const std::string &, bool) { } + void error(const std::string &, const std::string &, bool) { } void flush() { } #else void initialize(LogLevel level, const std::string &defaultSource, bool enableConsole, diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 49305df..f955532 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -22,6 +22,8 @@ target_link_libraries(logcoe_tests testcoe ) +enable_strict_warnings(logcoe_tests) + add_custom_target(run_logcoe_tests COMMAND logcoe_tests DEPENDS logcoe_tests @@ -36,6 +38,8 @@ target_link_libraries(logcoe_strip_tests testcoe ) +enable_strict_warnings(logcoe_strip_tests) + add_custom_target(run_logcoe_strip_tests COMMAND logcoe_strip_tests DEPENDS logcoe_strip_tests diff --git a/tests/logcoe_thread_test.cpp b/tests/logcoe_thread_test.cpp index eee482e..0f94513 100644 --- a/tests/logcoe_thread_test.cpp +++ b/tests/logcoe_thread_test.cpp @@ -165,7 +165,7 @@ TEST_F(LogcoeThreadTest, ConcurrentLogLevelChange) std::vector threads; std::atomic start_flag(false); - threads.emplace_back([this, &start_flag]() + threads.emplace_back([&start_flag]() { while (!start_flag.load()) { @@ -185,7 +185,7 @@ TEST_F(LogcoeThreadTest, ConcurrentLogLevelChange) for (int level = 0; level < 3; level++) { - threads.emplace_back([this, level, &start_flag]() + threads.emplace_back([level, &start_flag]() { while (!start_flag.load()) { @@ -264,7 +264,7 @@ TEST_F(LogcoeThreadTest, ConcurrentOutputConfigChange) } }); - threads.emplace_back([this, &start_flag]() + threads.emplace_back([&start_flag]() { while (!start_flag.load()) { From 5185c5c7cc7eb4141067ed29ee6914348a0dc4bd Mon Sep 17 00:00:00 2001 From: nircoe Date: Sun, 27 Sep 2026 13:00:31 +0300 Subject: [PATCH 2/2] Remove redundant CI installs --- .github/workflows/ci-macos.yml | 5 ----- .github/workflows/ci-windows.yml | 12 ------------ 2 files changed, 17 deletions(-) diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index 71aec0c..e4eb86b 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -34,11 +34,6 @@ jobs: with: submodules: 'recursive' - - name: Install ninja-build - run: | - brew install ninja - shell: bash - - name: Configure CMake run: | cmake -B build -G "${{ matrix.cmake-generator }}" ${{ matrix.cmake-options }} -DLOGCOE_BUILD_TESTS=ON diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index 6ed9e07..c68ef41 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -40,18 +40,6 @@ jobs: with: submodules: 'recursive' - - name: Install Windows build tools - if: matrix.compiler != 'msvc' - run: | - choco install mingw - shell: bash - - - name: Install Ninja - if: matrix.compiler == 'msvc' - run: | - choco install ninja - shell: bash - - name: Setup MSVC dev environment if: matrix.compiler == 'msvc' uses: ilammy/msvc-dev-cmd@v1.13.0