From 7f665babf9d094e4803502d4e326775d31720821 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Fri, 15 Sep 2023 22:41:37 -0500 Subject: [PATCH] Enable GCC static analysis in CI --- CMakeLists.txt | 4 ++++ appveyor.yml | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6316e785..5e273cad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ project(moonlight-common-c LANGUAGES C) set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) option(USE_MBEDTLS "Use MbedTLS instead of OpenSSL" OFF) +option(CODE_ANALYSIS "Run code analysis during compilation" OFF) SET(CMAKE_C_STANDARD 11) @@ -39,6 +40,9 @@ elseif(MINGW) target_link_libraries(moonlight-common-c PRIVATE -lws2_32 -lwinmm) else() target_compile_options(moonlight-common-c PRIVATE -Wall -Wextra -Wno-unused-parameter -Werror) + if (CODE_ANALYSIS AND CMAKE_C_COMPILER_ID STREQUAL "GNU") + target_compile_options(moonlight-common-c PRIVATE -fanalyzer) + endif() endif() if (USE_MBEDTLS) diff --git a/appveyor.yml b/appveyor.yml index 0b5e6537..7acce85b 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -15,6 +15,7 @@ environment: - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu CC: gcc CXX: g++ + CMAKE_ARGS: -DCODE_ANALYSIS=ON - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu CC: clang CXX: clang++ @@ -23,7 +24,7 @@ environment: - APPVEYOR_BUILD_WORKER_IMAGE: Ubuntu CC: gcc CXX: g++ - CMAKE_ARGS: -DUSE_MBEDTLS=ON + CMAKE_ARGS: -DUSE_MBEDTLS=ON -DCODE_ANALYSIS=ON PREBUILD_CMD: sudo apt install -y libmbedtls-dev before_build: