From b75256bec53da556f24a6948096c824d9ee81d16 Mon Sep 17 00:00:00 2001 From: Michael Uleysky Date: Thu, 27 Apr 2023 19:39:45 +1000 Subject: [PATCH] Added gcc static analyzer support --- CMakeLists.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 724667f..b673298 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,6 +13,8 @@ if(${srcdir} STREQUAL ${bindir}) " Please remove them.") endif() +set(STATIC_ANALYZER OFF CACHE BOOL "Using GCC static analyzer if available") + project(odm C CXX) set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -28,6 +30,12 @@ if(COMPILER_SUPPORTS_DWARF4 AND (CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUIL add_compile_options(-gdwarf-4) endif() +# GCC static analyzer support check +CHECK_CXX_COMPILER_FLAG(-fanalyzer COMPILER_SUPPORTS_ANALYZER) +if(COMPILER_SUPPORTS_ANALYZER AND STATIC_ANALYZER) + add_compile_options(-fanalyzer) +endif() + add_library(teos STATIC GSW-C/gsw_oceanographic_toolbox.c GSW-C/gsw_saar.c) set_target_properties(teos PROPERTIES LINKER_LANGUAGE C)