From 9b3f5cd86e61e336bdc9e73696db760bff0786da Mon Sep 17 00:00:00 2001 From: akallabeth Date: Thu, 14 Nov 2024 13:33:14 +0100 Subject: [PATCH] [ci,coverity] define COVERITY_BUILD By defining this symbol the build will enable coverity related pragma definitions --- .github/workflows/coverity.yml | 1 + CMakeLists.txt | 5 +++++ winpr/CMakeLists.txt | 5 +++++ winpr/include/winpr/platform.h | 3 ++- 4 files changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/coverity.yml b/.github/workflows/coverity.yml index 629a78a94..845b10a58 100644 --- a/.github/workflows/coverity.yml +++ b/.github/workflows/coverity.yml @@ -79,6 +79,7 @@ jobs: -GNinja \ -C ci/cmake-preloads/config-coverity.txt \ -DALLOW_IN_SOURCE_BUILD=true \ + -DCOVERITY_BUILD=ON \ -B. \ -S. cov-build --dir cov-int cmake --build . diff --git a/CMakeLists.txt b/CMakeLists.txt index 8eae52bcf..0dd54d379 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,11 @@ if (NOT WIN32 AND NOT ANDROID) option(WITH_X11 "build X11 client/server" ${OPT_DEFAULT_VAL}) endif() +# Enable coverity related pragma definitions +if (COVERITY_BUILD) + add_compile_definitions(COVERITY_BUILD) +endif() + # Include our extra modules list(APPEND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/) diff --git a/winpr/CMakeLists.txt b/winpr/CMakeLists.txt index 6bdff7cf2..2f3006cd9 100644 --- a/winpr/CMakeLists.txt +++ b/winpr/CMakeLists.txt @@ -33,6 +33,11 @@ if (NOT FREERDP_UNIFIED_BUILD) include(CommonConfigOptions) include(ConfigOptions) + # Enable coverity related pragma definitions + if (COVERITY_BUILD) + add_compile_definitions(COVERITY_BUILD) + endif() + # Default to build shared libs option(EXPORT_ALL_SYMBOLS "Export all symbols form library" OFF) diff --git a/winpr/include/winpr/platform.h b/winpr/include/winpr/platform.h index 987aa9f53..a3c95366e 100644 --- a/winpr/include/winpr/platform.h +++ b/winpr/include/winpr/platform.h @@ -32,7 +32,8 @@ #define WINPR_DO_PRAGMA(x) __pragma(#x) #endif -#if !defined(__COVERITY__) +/* COVERITY_BUILD must be defined by build system */ +#if !defined(COVERITY_BUILD) #define WINPR_DO_COVERITY_PRAGMA(x) #else #define WINPR_DO_COVERITY_PRAGMA(x) WINPR_DO_PRAGMA(x)