Skip to content

Commit

Permalink
cmake: enable compiler warnings for C only
Browse files Browse the repository at this point in the history
  • Loading branch information
alfredh authored and sreimers committed Jan 14, 2025
1 parent f929020 commit 5f866a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ jobs:
- name: cmake
run: |
cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -Werror -DCMAKE_C_FLAGS="-Werror"
cmake -B build -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DCMAKE_C_FLAGS="-Werror" -DCMAKE_CXX_FLAGS="-Werror"
cmake --build build -t retest
- name: retest
Expand Down
7 changes: 6 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
if(MSVC)
add_compile_options("/W3")
else()
add_compile_options(

set(c_flags
-pedantic
-Wall
-Wbad-function-cast
Expand All @@ -79,6 +80,10 @@ else()
-Wuninitialized
-Wvla
)

add_compile_options(
"$<$<COMPILE_LANGUAGE:C>:${c_flags}>"
)
endif()

if(CMAKE_C_COMPILER_ID MATCHES "Clang")
Expand Down

0 comments on commit 5f866a9

Please sign in to comment.