From d60e0046a12b03c78abfffd7fbb225b345d209c7 Mon Sep 17 00:00:00 2001 From: "Berk D. Demir" Date: Wed, 9 Jul 2025 22:14:34 -0700 Subject: [PATCH] Enable all compiler warnings --- CMakeLists.txt | 9 +++++++++ tools/blisp/CMakeLists.txt | 10 ++++++++++ 2 files changed, 19 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 43462e8..3f6642a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -17,6 +17,15 @@ add_library(libblisp_obj OBJECT lib/chip/blisp_chip_bl70x.c) target_include_directories(libblisp_obj PRIVATE ${CMAKE_SOURCE_DIR}/include/) +if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC") + target_compile_options(libblisp_obj PRIVATE -Wall -Wextra -Wpedantic) +else() + # MSVC does not support 'extra' and 'pedantic' levels to warnings. + # `/Wall` seems to generate way too many non-actionable output marked as warnings. + # We settle for `/W4`. + # https://learn.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level?view=msvc-170 + target_compile_options(libblisp_obj PRIVATE -W4) +endif() set_property(TARGET libblisp_obj PROPERTY POSITION_INDEPENDENT_CODE 1) diff --git a/tools/blisp/CMakeLists.txt b/tools/blisp/CMakeLists.txt index 66cbb40..3af2488 100644 --- a/tools/blisp/CMakeLists.txt +++ b/tools/blisp/CMakeLists.txt @@ -23,6 +23,16 @@ target_link_libraries(blisp PRIVATE argtable3::argtable3 libblisp_static file_parsers) +if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC") + target_compile_options(libblisp_obj PRIVATE -Wall -Wextra -Wpedantic) +else() + # MSVC does not support 'extra' and 'pedantic' levels to warnings. + # `/Wall` seems to generate way too many non-actionable output marked as warnings. + # We settle for `/W4`. + # https://learn.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level?view=msvc-170 + target_compile_options(libblisp_obj PRIVATE -W4) +endif() + if (WIN32) target_link_libraries(blisp PRIVATE Setupapi.lib) elseif (APPLE)