Publishing 2019 R1 content
[platform/upstream/dldt.git] / inference-engine / cmake / cpplint_run.cmake
1 # Copyright (C) 2018-2019 Intel Corporation
2 #
3 # SPDX-License-Identifier: Apache-2.0
4 #
5
6 file(REMOVE "${OUTPUT_FILE}")
7
8 execute_process(
9     COMMAND
10         "${PYTHON_EXECUTABLE}"
11         "${CPPLINT_SCRIPT}"
12         "--linelength=160"
13         "--counting=detailed"
14         "--filter=-readability/fn_size"
15         "${INPUT_FILE}"
16     WORKING_DIRECTORY "${WORKING_DIRECTORY}"
17     RESULT_VARIABLE result
18     OUTPUT_VARIABLE output
19     ERROR_VARIABLE output)
20
21 # Display the cpplint output to console (to parse it form IDE)
22 message("${output}")
23
24 # Store cpplint output to file (replace problematic symbols)
25 string(REPLACE "\"" "&quot\;" output ${output})
26 string(REPLACE "<" "&lt\;" output ${output})
27 string(REPLACE ">" "&gt\;" output ${output})
28 string(REPLACE "'" "&apos\;" output ${output})
29 string(REPLACE "&" "&amp\;" output ${output})
30 file(WRITE "${OUTPUT_FILE}" ${output})
31
32 if(NOT SKIP_RETURN_CODE)
33     # Pass through the cpplint return code
34     if(NOT result EQUAL 0)
35         message(FATAL_ERROR "[cpplint] Code style check failed for : ${INPUT_FILE}")
36     endif()
37 endif()