summaryrefslogtreecommitdiffstats
path: root/cmake/modules/buildtools/FindClangTidy.cmake
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 18:07:22 +0000
commitc04dcc2e7d834218ef2d4194331e383402495ae1 (patch)
tree7333e38d10d75386e60f336b80c2443c1166031d /cmake/modules/buildtools/FindClangTidy.cmake
parentInitial commit. (diff)
downloadkodi-c04dcc2e7d834218ef2d4194331e383402495ae1.tar.xz
kodi-c04dcc2e7d834218ef2d4194331e383402495ae1.zip
Adding upstream version 2:20.4+dfsg.upstream/2%20.4+dfsg
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--cmake/modules/buildtools/FindClangTidy.cmake29
1 files changed, 29 insertions, 0 deletions
diff --git a/cmake/modules/buildtools/FindClangTidy.cmake b/cmake/modules/buildtools/FindClangTidy.cmake
new file mode 100644
index 0000000..c133175
--- /dev/null
+++ b/cmake/modules/buildtools/FindClangTidy.cmake
@@ -0,0 +1,29 @@
+#.rst:
+# FindClangTidy
+# -------------
+# Finds clang-tidy and sets it up to run along with the compiler for C and CXX.
+
+find_program(CLANG_TIDY_EXECUTABLE clang-tidy)
+
+if(CLANG_TIDY_EXECUTABLE)
+ execute_process(COMMAND "${CLANG_TIDY_EXECUTABLE}" --version
+ OUTPUT_VARIABLE CLANG_TIDY_VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE)
+ string(REGEX MATCH "[^\n]* version [^\n]*" CLANG_TIDY_VERSION "${CLANG_TIDY_VERSION}")
+ string(REGEX REPLACE ".* version (.*)" "\\1" CLANG_TIDY_VERSION "${CLANG_TIDY_VERSION}")
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(ClangTidy REQUIRED_VARS CLANG_TIDY_EXECUTABLE
+ VERSION_VAR CLANG_TIDY_VERSION)
+
+if(CLANGTIDY_FOUND)
+ if(CORE_SYSTEM_NAME STREQUAL android)
+ set(CLANG_TIDY_EXECUTABLE ${CLANG_TIDY_EXECUTABLE};--extra-arg-before=--target=${HOST})
+ endif()
+ # Supports Unix Makefiles and Ninja
+ set(CMAKE_C_CLANG_TIDY "${CLANG_TIDY_EXECUTABLE}" PARENT_SCOPE)
+ set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_EXECUTABLE}" PARENT_SCOPE)
+endif()
+
+mark_as_advanced(CLANG_TIDY_EXECUTABLE)