diff --git a/.github/workflows/ubuntu.yml b/.github/workflows/ubuntu.yml index dc0964f4a..e791de67b 100644 --- a/.github/workflows/ubuntu.yml +++ b/.github/workflows/ubuntu.yml @@ -155,6 +155,7 @@ jobs: -DCMAKE_BUILD_TYPE=${{ matrix.type }} -DENABLE_CCACHE=ON -DCMAKE_POLICY_VERSION_MINIMUM=3.5 + -DENABLE_GCC_ANALYZER=ON -G Ninja run: | mkdir build install diff --git a/cmake/celix_project/CelixProject.cmake b/cmake/celix_project/CelixProject.cmake index 8f231a2dd..76a74c6bd 100644 --- a/cmake/celix_project/CelixProject.cmake +++ b/cmake/celix_project/CelixProject.cmake @@ -18,7 +18,7 @@ option(ENABLE_ADDRESS_SANITIZER "Enabled building with address sanitizer. Note for gcc libasan must be installed," OFF) option(ENABLE_UNDEFINED_SANITIZER "Enabled building with undefined behavior sanitizer." OFF) option(ENABLE_THREAD_SANITIZER "Enabled building with thread sanitizer." OFF) - +option (ENABLE_GCC_ANALYZER "Enable building with GCC static analyzer." OFF ) # Clear "Advanced" flag for sanitizer options mark_as_advanced(CLEAR ENABLE_ADDRESS_SANITIZER) mark_as_advanced(CLEAR ENABLE_UNDEFINED_SANITIZER) @@ -73,6 +73,37 @@ elseif (ENABLE_THREAD_SANITIZER) set(CMAKE_CXX_FLAGS "-fsanitize=thread ${CMAKE_CXX_FLAGS}") endif() +if (ENABLE_GCC_ANALYZER) + if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") + set(ANALYZER_FLAGS + "-fanalyzer" + "-Wno-analyzer-too-complex" + "-Wno-analyzer-double-fclose" + "-Wno-analyzer-double-free" + "-Wno-analyzer-deref-before-check" + "-Wno-analyzer-exposure-through-output-file" + "-Wno-analyzer-file-leak" + "-Wno-analyzer-free-of-non-heap" + "-Wno-analyzer-malloc-leak" + "-Wno-analyzer-possible-null-argument" + "-Wno-analyzer-possible-null-dereference" + "-Wno-analyzer-null-argument" + "-Wno-analyzer-null-dereference" + "-Wno-analyzer-stale-setjmp-buffer" + "-Wno-analyzer-tainted-array-index" + "-Wno-analyzer-unsafe-call-within-signal-handler" + "-Wno-analyzer-use-after-free" + "-Wno-analyzer-use-of-pointer-in-stale-stack-frame" + "-Wno-analyzer-use-of-uninitialized-value" + "-Wno-analyzer-fd-leak" + ) + add_compile_options(${ANALYZER_FLAGS}) + else() + message(WARNING "ENABLE_GCC_ANALYZER is only supported with GCC ") + endif() +endif() + + MACRO(celix_subproject) set(ARGS "${ARGN}") diff --git a/conanfile.py b/conanfile.py index bb1c63907..ab842482a 100644 --- a/conanfile.py +++ b/conanfile.py @@ -94,6 +94,7 @@ class CelixConan(ConanFile): "framework_curlinit": True, "enable_ccache": False, "enable_deprecated_warnings": False, + } options = { "celix_err_buffer_size": ["ANY"], @@ -387,7 +388,8 @@ def generate(self): if "libcurl" in lst: tc.cache_variables["BUILD_ERROR_INJECTOR_CURL"] = "ON" tc.cache_variables["CELIX_ERR_BUFFER_SIZE"] = str(self.options.celix_err_buffer_size) - # tc.cache_variables["CMAKE_PROJECT_Celix_INCLUDE"] = os.path.join(self.build_folder, "conan_paths.cmake") + + #tc.cache_variables["CMAKE_PROJECT_Celix_INCLUDE"] = os.path.join(self.build_folder, "conan_paths.cmake") # the following is workaround for https://github.com/conan-io/conan/issues/7192 if self.settings.os == "Linux": tc.cache_variables["CMAKE_EXE_LINKER_FLAGS"] = "-Wl,--unresolved-symbols=ignore-in-shared-libs"