diff options
| author | manuel <manuel@mausz.at> | 2020-10-19 00:52:24 +0200 |
|---|---|---|
| committer | manuel <manuel@mausz.at> | 2020-10-19 00:52:24 +0200 |
| commit | be933ef2241d79558f91796cc5b3a161f72ebf9c (patch) | |
| tree | fe3ab2f130e20c99001f2d7a81d610c78c96a3f4 /cmake/modules/FindCppcheck.cmake | |
| parent | 5f8335c1e49ce108ef3481863833c98efa00411b (diff) | |
| download | kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.gz kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.tar.bz2 kodi-pvr-build-be933ef2241d79558f91796cc5b3a161f72ebf9c.zip | |
sync with upstream
Diffstat (limited to 'cmake/modules/FindCppcheck.cmake')
| -rw-r--r-- | cmake/modules/FindCppcheck.cmake | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/cmake/modules/FindCppcheck.cmake b/cmake/modules/FindCppcheck.cmake new file mode 100644 index 0000000..d3b6e84 --- /dev/null +++ b/cmake/modules/FindCppcheck.cmake | |||
| @@ -0,0 +1,32 @@ | |||
| 1 | #.rst: | ||
| 2 | # FindCppcheck | ||
| 3 | # ------------ | ||
| 4 | # Finds cppcheck and sets it up to run along with the compiler for C and CXX. | ||
| 5 | |||
| 6 | find_program(CPPCHECK_EXECUTABLE cppcheck) | ||
| 7 | |||
| 8 | if(CPPCHECK_EXECUTABLE) | ||
| 9 | execute_process(COMMAND "${CPPCHECK_EXECUTABLE}" --version | ||
| 10 | OUTPUT_VARIABLE CPPCHECK_VERSION | ||
| 11 | OUTPUT_STRIP_TRAILING_WHITESPACE) | ||
| 12 | string(REGEX REPLACE "Cppcheck (.*)" "\\1" CPPCHECK_VERSION "${CPPCHECK_VERSION}") | ||
| 13 | endif() | ||
| 14 | |||
| 15 | include(FindPackageHandleStandardArgs) | ||
| 16 | find_package_handle_standard_args(Cppcheck REQUIRED_VARS CPPCHECK_EXECUTABLE | ||
| 17 | VERSION_VAR CPPCHECK_VERSION) | ||
| 18 | |||
| 19 | if(CPPCHECK_FOUND) | ||
| 20 | # CMake < 3.16 treats Objective-C (OBJC) files as C files and Objective-C++ (OBJCXX) files as C++ files, | ||
| 21 | # but cppcheck doesn't support Objective-C and Objective-C++. | ||
| 22 | # CMake >= 3.16 added support for Objective-C and Objective-C++ language, | ||
| 23 | # but doesn't support OBJC and OBJCXX for <LANG>_CLANG_TIDY. | ||
| 24 | file(WRITE "${CMAKE_BINARY_DIR}/cppcheck" "case \"$@\" in *.m|*.mm) exit 0; esac\nexec \"${CPPCHECK_EXECUTABLE}\" --quiet --relative-paths=\"${CMAKE_SOURCE_DIR}\" \"$@\"\n") | ||
| 25 | execute_process(COMMAND chmod +x "${CMAKE_BINARY_DIR}/cppcheck") | ||
| 26 | |||
| 27 | # Supports Unix Makefiles and Ninja | ||
| 28 | set(CMAKE_C_CPPCHECK "${CMAKE_BINARY_DIR}/cppcheck" PARENT_SCOPE) | ||
| 29 | set(CMAKE_CXX_CPPCHECK "${CMAKE_BINARY_DIR}/cppcheck" PARENT_SCOPE) | ||
| 30 | endif() | ||
| 31 | |||
| 32 | mark_as_advanced(CPPCHECK_EXECUTABLE) | ||
