Skip to content

Commit d60e004

Browse files
committed
Enable all compiler warnings
1 parent cb89bdb commit d60e004

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,15 @@ add_library(libblisp_obj OBJECT
1717
lib/chip/blisp_chip_bl70x.c)
1818

1919
target_include_directories(libblisp_obj PRIVATE ${CMAKE_SOURCE_DIR}/include/)
20+
if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
21+
target_compile_options(libblisp_obj PRIVATE -Wall -Wextra -Wpedantic)
22+
else()
23+
# MSVC does not support 'extra' and 'pedantic' levels to warnings.
24+
# `/Wall` seems to generate way too many non-actionable output marked as warnings.
25+
# We settle for `/W4`.
26+
# https://learn.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level?view=msvc-170
27+
target_compile_options(libblisp_obj PRIVATE -W4)
28+
endif()
2029

2130
set_property(TARGET libblisp_obj PROPERTY POSITION_INDEPENDENT_CODE 1)
2231

tools/blisp/CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,16 @@ target_link_libraries(blisp PRIVATE
2323
argtable3::argtable3
2424
libblisp_static file_parsers)
2525

26+
if (NOT CMAKE_C_COMPILER_ID MATCHES "MSVC")
27+
target_compile_options(libblisp_obj PRIVATE -Wall -Wextra -Wpedantic)
28+
else()
29+
# MSVC does not support 'extra' and 'pedantic' levels to warnings.
30+
# `/Wall` seems to generate way too many non-actionable output marked as warnings.
31+
# We settle for `/W4`.
32+
# https://learn.microsoft.com/en-us/cpp/build/reference/compiler-option-warning-level?view=msvc-170
33+
target_compile_options(libblisp_obj PRIVATE -W4)
34+
endif()
35+
2636
if (WIN32)
2737
target_link_libraries(blisp PRIVATE Setupapi.lib)
2838
elseif (APPLE)

0 commit comments

Comments
 (0)