forked from Eyescale/CMake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommonCheckTargets.cmake
34 lines (28 loc) · 1.01 KB
/
CommonCheckTargets.cmake
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# Copyright (c) 2015 [email protected]
#
# Provide the function common_check_targets to add check targets (clangcheck,
# cppcheck, cpplint) to the given target.
#
# CMake options:
# - COMMON_ENABLE_STATIC_TESTS to enable the checks
option(COMMON_ENABLE_STATIC_TESTS "Enable static code analysis test targets" OFF)
include(GetSourceFilesFromTarget)
include(CommonClangCheck)
include(CommonCPPCheck)
include(CommonCPPLint)
function(common_check_targets _name)
if(NOT COMMON_ENABLE_STATIC_TESTS)
return()
endif()
# Qt moc & qrc files, C and Objective-C files
set(_exclude_pattern ".*moc_|.*qrc_.*\\.c.*|.*\\.mm.*$")
# Get the list of files once for all check targets
get_source_files(${_name} ${_exclude_pattern})
if(NOT ${_name}_FILES)
return()
endif()
common_clangcheck(${_name} FILES ${${_name}_FILES})
common_cppcheck(${_name} FILES ${${_name}_FILES}
POSSIBLE_ERROR FAIL_ON_WARNINGS)
common_cpplint(${_name} FILES ${${_name}_FILES} CATEGORY_FILTER_OUT readability/streams)
endfunction()