Skip to content

Commit

Permalink
cmake: always enable warnings without -Werror
Browse files Browse the repository at this point in the history
Warnings are useful, let's enable them by default.
  • Loading branch information
Lekensteyn committed Feb 16, 2016
1 parent a909eb6 commit f4b2a4a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
9 changes: 7 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -285,12 +285,17 @@ if(HAVE_EPOLL AND HAVE_TIMERFD_CREATE)
set(ENABLE_TINY_NGHTTPD 1)
endif()

set(WARNCFLAGS)
set(WARNCXXFLAGS)
if(ENABLE_WERROR)
extract_valid_c_flags(WARNCFLAGS -Werror)
extract_valid_c_flags(WARNCXXFLAGS -Werror)
endif()
if(NOT CMAKE_C_COMPILER_ID STREQUAL "MSVC")
# For C compiler
extract_valid_c_flags(WARNCFLAGS
-Wall
-Wextra
-Werror
-Wmissing-prototypes
-Wstrict-prototypes
-Wmissing-declarations
Expand Down Expand Up @@ -338,11 +343,11 @@ if(ENABLE_WERROR)
extract_valid_cxx_flags(WARNCXXFLAGS
# For C++ compiler
-Wall
-Werror
-Wformat-security
)
endif()

set(EXTRACFLAG)
extract_valid_c_flags(EXTRACFLAG
-fvisibility=hidden
)
Expand Down
4 changes: 1 addition & 3 deletions cmake/ExtractValidFlags.cmake
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
# Convenience function that checks the availability
# of certain C or C++ compiler flags and returns the valid ones.
# of certain C or C++ compiler flags and appends valid ones.

include(CheckCCompilerFlag)
include(CheckCXXCompilerFlag)

function(extract_valid_c_flags varname)
set(valid_flags "")
foreach(flag IN LISTS ARGN)
string(REGEX REPLACE "[^a-zA-Z0-9_]+" "_" flag_var ${flag})
set(flag_var "C_FLAG_${flag_var}")
Expand All @@ -18,7 +17,6 @@ function(extract_valid_c_flags varname)
endfunction()

function(extract_valid_cxx_flags varname)
set(valid_flags "")
foreach(flag IN LISTS ARGN)
string(REGEX REPLACE "[^a-zA-Z0-9_]+" "_" flag_var ${flag})
set(flag_var "CXX_FLAG_${flag_var}")
Expand Down

0 comments on commit f4b2a4a

Please sign in to comment.