|
@@ -1,18 +1,14 @@
|
|
|
find_package(ClangTools)
|
|
|
+# clang-tidy uses the compile_commands.json file for include dirs and other config
|
|
|
add_custom_target(clang-tidy ${CLANG_TIDY_PROGRAM}
|
|
|
- ${lib_sources}
|
|
|
-p=compile_commands.json
|
|
|
+ -format-style=file
|
|
|
--
|
|
|
- -I${PROJECT_SOURCE_DIR}/include
|
|
|
- -I${PROJECT_SOURCE_DIR}/plugins
|
|
|
- -I${PROJECT_SOURCE_DIR}/deps
|
|
|
- -I${PROJECT_SOURCE_DIR}/src
|
|
|
- -I${PROJECT_SOURCE_DIR}/src/server
|
|
|
- -I${PROJECT_SOURCE_DIR}/src/client
|
|
|
- -I${PROJECT_BINARY_DIR}/src_generated
|
|
|
+ ${lib_sources}
|
|
|
DEPENDS ${lib_sources}
|
|
|
COMMENT "Run clang-tidy on the library")
|
|
|
add_dependencies(clang-tidy open62541)
|
|
|
+set_target_properties(clang-tidy PROPERTIES FOLDER "CodeAnalysis")
|
|
|
|
|
|
add_custom_target(cpplint cpplint
|
|
|
${lib_sources}
|
|
@@ -28,3 +24,25 @@ add_custom_target(cpplint cpplint
|
|
|
${ua_architecture_headers}
|
|
|
${ua_architecture_sources}
|
|
|
COMMENT "Run cpplint code style checker on the library")
|
|
|
+set_target_properties(cpplint PROPERTIES FOLDER "CodeAnalysis")
|
|
|
+
|
|
|
+
|
|
|
+# adds new target "clang-format" to enforce clang-format rules
|
|
|
+find_program(CLANG_FORMAT_EXE NAMES "clang-format")
|
|
|
+if(CLANG_FORMAT_EXE)
|
|
|
+ file(GLOB_RECURSE FILES_TO_FORMAT
|
|
|
+ ${PROJECT_SOURCE_DIR}/arch/*.c
|
|
|
+ ${PROJECT_SOURCE_DIR}/plugins/*.c
|
|
|
+ ${PROJECT_SOURCE_DIR}/src/*.c
|
|
|
+ ${PROJECT_SOURCE_DIR}/arch/*.h
|
|
|
+ ${PROJECT_SOURCE_DIR}/include/*.h
|
|
|
+ ${PROJECT_SOURCE_DIR}/plugins/*.h
|
|
|
+ ${PROJECT_SOURCE_DIR}/src/*.h
|
|
|
+ )
|
|
|
+ add_custom_target(
|
|
|
+ clang-format COMMAND ${CLANG_FORMAT_EXE}
|
|
|
+ -style=file
|
|
|
+ -i
|
|
|
+ ${FILES_TO_FORMAT}
|
|
|
+ )
|
|
|
+endif()
|