#!/bin/bash

BUILDDIR=build-clazy

if [ ! -d $BUILDDIR ]; then
	mkdir -p $BUILDDIR
fi

cd $BUILDDIR

export CC=clang
export CXX=clang++


#https://github.com/KDE/clazy
# There are many checks and they are divided in levels:
# 
# level0: Very stable checks, 99.99% safe, no false-positives
# level1: Similar to level0, but sometimes (rarely) there might be some false-positives
# level2: Sometimes has false-positives (20-30%).
# level3: Not always correct, possibly very noisy, might require a knowledgeable developer to review, might have a very big rate of false-positives, might have bugs.

export CLAZY_CHECKS="level2,no-qenums,no-qt-macros"

cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_FLAGS="-Xclang -load -Xclang ClazyPlugin.so -Xclang -add-plugin -Xclang clazy -D_GNU_SOURCE -O2 -Wall -Wextra -Wundef -Wpointer-arith -Wcast-align -Wunreachable-code -fno-omit-frame-pointer -fstack-protector -fno-exceptions" -DCMAKE_CXX_FLAGS="-D_GNU_SOURCE -std=c++11 -O2 -Wall -Wextra -Wundef -Wpointer-arith -Wcast-align -Wunreachable-code -fno-omit-frame-pointer -fstack-protector -fno-exceptions" -DCMAKE_INSTALL_PREFIX=/usr && make -j 6
