From f3966dc010787a2ca9b341ab23dc0d44d8094028 Mon Sep 17 00:00:00 2001 From: Peter Evans Date: Mon, 18 Dec 2017 14:26:53 -0600 Subject: [PATCH] Enable static analysis through clang If you want to, just uncomment the line that adds the --analyze flag to CMAKE_C_FLAGS. --- CMakeLists.txt | 6 ++++++ tests/CMakeLists.txt | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 67abce6..3fcee79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,12 @@ project(erc) include(sources.cmake) +#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --analyze") + +if(CMAKE_C_FLAGS MATCHES "--analyze") + set(CMAKE_C_LINK_EXECUTABLE "echo 'Will not execute binary when running static analysis'") +endif() + if(APPLE) set(sdl_library /Library/Frameworks/SDL2.framework) set(sdl_headers /Library/Frameworks/SDL2.framework/Headers) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index eafc1e4..1508f20 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -4,6 +4,12 @@ project(erc-test) set(CMAKE_BUILD_TYPE Debug) +#set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --analyze") + +if(CMAKE_C_FLAGS MATCHES "--analyze") + set(CMAKE_C_LINK_EXECUTABLE "echo 'Will not execute binary when running static analysis'") +endif() + if(APPLE) set(opengl_library /System/Library/Frameworks/OpenGL.framework) endif()