From 1af6930fc72fef21e2a01ff67d205b09546251c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Rombauts?= Date: Thu, 24 Oct 2013 06:58:38 +0200 Subject: [PATCH] Added a cppcheck rule to the "all" target - Travis: apt-get install cppcheck --- .travis.yml | 4 ++++ CMakeLists.txt | 7 +++++++ Makefile | 6 ++++-- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 99d1f06..1139982 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,6 +4,10 @@ compiler: - gcc - clang +before_install: + - sudo apt-get update -qq + - sudo apt-get install -qq cppcheck + # using a symbolic link to get the "make test" to work as if launched from the root directorys before_script: - mkdir build diff --git a/CMakeLists.txt b/CMakeLists.txt index 5607da0..dd8a038 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,13 @@ elseif (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) add_definitions (-rdynamic -fstack-protector-all -Wall -Wextra -pedantic -Weffc++ -Wformat-security -Winit-self -Wswitch-default -Wswitch-enum -Wfloat-equal -Wundef -Wshadow -Wcast-qual -Wconversion -Wlogical-op -Winline -Wsuggest-attribute=pure -Wsuggest-attribute=const -Wsuggest-attribute=noreturn) endif () +# add a cppcheck target to the "all" target +add_custom_target(cppcheck + ALL + COMMAND cppcheck -j 4 cppcheck --enable=style,portability,performance,information --quiet --template='{file}:{line}: warning: cppcheck: {message} [{severity}/{id}]' src + WORKING_DIRECTORY ${PROJECT_SOURCE_DIR} +) + ################################################################################ # add the subdirectory containing the CMakeLists.txt of the wrapper library add_subdirectory (src) diff --git a/Makefile b/Makefile index 89f8be6..1803265 100644 --- a/Makefile +++ b/Makefile @@ -39,7 +39,7 @@ SQLITE_EXAMPLE1_OBJECTS = \ ### Targets: ### -all: $(BUILD) $(BUILD)/example1 +all: $(BUILD) $(BUILD)/example1 cppcheck clean: rm -f $(BUILD)/*.o @@ -69,8 +69,10 @@ $(BUILD)/Statement.o: src/Statement.cpp $(BUILD)/Transaction.o: src/Transaction.cpp $(CXX) -c -o $@ $(SQLITE_CXXFLAGS) $(CPPDEPS) $< +cppcheck: + cppcheck -j 4 cppcheck --enable=style --quiet --template='{file}:{line}: warning: cppcheck: {message} [{severity}/{id}]' src -.PHONY: all clean +.PHONY: all clean cppcheck # Dependencies tracking: