mirror of
https://github.com/warmcat/libwebsockets.git
synced 2025-03-09 00:00:04 +01:00
gcc: support -fanalyzer static analysis
Starting with gcc 10 (in fedora 32) there's a new static analyzer built into gcc you can enable with -fanalyzer. It doesn't slow compilation much, but it's a bit hit and miss, it only analyzes each compilation unit standalone so it reports issues that can never happen. Enable it if the option LWS_WITH_FANALYZER is enabled and cmake can see the actual compiler supports it.
This commit is contained in:
parent
be32d0554e
commit
e038332424
1 changed files with 8 additions and 1 deletions
|
@ -166,7 +166,7 @@ option(LWS_WITH_DETAILED_LATENCY "Record detailed latency stats for each read an
|
|||
option(LWS_WITH_UDP "Platform supports UDP" ON)
|
||||
option(LWS_WITH_SPAWN "Spawn subprocesses with piped stdin/out/stderr" OFF)
|
||||
option(LWS_WITH_FSMOUNT "Overlayfs and fallback mounting apis" OFF)
|
||||
|
||||
option(LWS_WITH_FANALYZER "Enable gcc -fanalyzer if compiler supports" OFF)
|
||||
|
||||
#
|
||||
# to use miniz, enable both LWS_WITH_ZLIB and LWS_WITH_MINIZ
|
||||
|
@ -1724,6 +1724,9 @@ endif()
|
|||
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG)
|
||||
include (CheckCCompilerFlag)
|
||||
CHECK_C_COMPILER_FLAG(-fvisibility=hidden LWS_HAVE_VISIBILITY)
|
||||
if (LWS_WITH_FANALYZER)
|
||||
CHECK_C_COMPILER_FLAG(-fanalyzer LWS_HAVE_FANALYZER)
|
||||
endif()
|
||||
if (LWS_HAVE_VISIBILITY)
|
||||
set(VISIBILITY_FLAG -fvisibility=hidden)
|
||||
endif()
|
||||
|
@ -1750,6 +1753,10 @@ if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX OR COMPILER_IS_CLANG)
|
|||
set(CMAKE_C_FLAGS "-Wtype-limits ${CMAKE_C_FLAGS}" )
|
||||
endif()
|
||||
|
||||
if (LWS_WITH_FANALYZER AND LWS_HAVE_FANALYZER)
|
||||
set(CMAKE_C_FLAGS "-fanalyzer ${CMAKE_C_FLAGS}" )
|
||||
endif()
|
||||
|
||||
if (UNIX AND NOT LWS_PLAT_FREERTOS)
|
||||
set(CMAKE_C_FLAGS "-Wall -Wsign-compare -Wstrict-aliasing -Wuninitialized -Werror ${VISIBILITY_FLAG} -Wundef ${GCOV_FLAGS} ${CMAKE_C_FLAGS} ${ASAN_FLAGS}" )
|
||||
else()
|
||||
|
|
Loading…
Add table
Reference in a new issue