summaryrefslogtreecommitdiff
path: root/CMakeScripts
diff options
context:
space:
mode:
authorAdam Kosiorek <a.kosiorek@samsung.com>2014-07-28 14:01:45 +0200
committerJeff Donahue <jeff.donahue@gmail.com>2014-08-17 01:07:17 -0700
commitf2f3b4c71210958125d4945442641e0305fbeba9 (patch)
treee4c9d16dbce4b956fa974d353e854cc7d921c03f /CMakeScripts
parentbad9d1ea0dddf2d639ca98d93a57692b92976de5 (diff)
downloadcaffeonacl-f2f3b4c71210958125d4945442641e0305fbeba9.tar.gz
caffeonacl-f2f3b4c71210958125d4945442641e0305fbeba9.tar.bz2
caffeonacl-f2f3b4c71210958125d4945442641e0305fbeba9.zip
Added lint target
Diffstat (limited to 'CMakeScripts')
-rw-r--r--CMakeScripts/lint.cmake48
1 files changed, 48 insertions, 0 deletions
diff --git a/CMakeScripts/lint.cmake b/CMakeScripts/lint.cmake
new file mode 100644
index 00000000..04df3409
--- /dev/null
+++ b/CMakeScripts/lint.cmake
@@ -0,0 +1,48 @@
+
+set(CMAKE_SOURCE_DIR ../)
+set(LINT_COMMAND ${CMAKE_SOURCE_DIR}/scripts/cpp_lint.py)
+set(SRC_FILE_EXTENSIONS h hpp hu c cpp cu cc)
+set(EXCLUDE_FILE_EXTENSTIONS pb.h pb.cc)
+set(LINT_DIRS include src/caffe examples tools python matlab)
+
+# find all files of interest
+foreach(ext ${SRC_FILE_EXTENSIONS})
+ foreach(dir ${LINT_DIRS})
+ file(GLOB_RECURSE FOUND_FILES ${CMAKE_SOURCE_DIR}/${dir}/*.${ext})
+ set(LINT_SOURCES ${LINT_SOURCES} ${FOUND_FILES})
+ endforeach()
+endforeach()
+
+# find all files that should be excluded
+foreach(ext ${EXCLUDE_FILE_EXTENSTIONS})
+ file(GLOB_RECURSE FOUND_FILES ${CMAKE_SOURCE_DIR}/*.${ext})
+ set(EXCLUDED_FILES ${EXCLUDED_FILES} ${FOUND_FILES})
+endforeach()
+
+# exclude generated pb files
+list(REMOVE_ITEM LINT_SOURCES ${EXCLUDED_FILES})
+
+execute_process(
+ COMMAND ${LINT_COMMAND} ${LINT_SOURCES}
+ ERROR_VARIABLE LINT_OUTPUT
+ ERROR_STRIP_TRAILING_WHITESPACE
+)
+
+string(REPLACE "\n" ";" LINT_OUTPUT ${LINT_OUTPUT})
+
+list(GET LINT_OUTPUT -1 LINT_RESULT)
+list(REMOVE_AT LINT_OUTPUT -1)
+string(REPLACE " " ";" LINT_RESULT ${LINT_RESULT})
+list(GET LINT_RESULT -1 NUM_ERRORS)
+if(NUM_ERRORS GREATER 0)
+ foreach(msg ${LINT_OUTPUT})
+ string(FIND ${msg} "Done" result)
+ if(result LESS 0)
+ message(STATUS ${msg})
+ endif()
+ endforeach()
+ message(FATAL_ERROR "Lint found ${NUM_ERRORS} errors!")
+else()
+ message(STATUS "Lint did not find any errors!")
+endif()
+