Skip to content

Commit

Permalink
[cmake] add clang-tidy support
Browse files Browse the repository at this point in the history
  • Loading branch information
Rechi committed Oct 4, 2020
1 parent cdcee0d commit ea41be4
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 4 deletions.
10 changes: 6 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ include(ExternalProject)

# general
option(VERBOSE "Enable verbose output?" OFF)
option(ENABLE_CLANGTIDY "Enable clang-tidy support?" OFF)
option(ENABLE_DVDCSS "Enable libdvdcss support?" ON)
option(ENABLE_UPNP "Enable UPnP support?" ON)
option(ENABLE_AIRTUNES "Enable AirTunes support?" ON)
Expand Down Expand Up @@ -146,6 +147,7 @@ set(optional_deps Alsa
CCache
CEC
ClangFormat
ClangTidy
Dav1d
DBus
Iso9660pp
Expand All @@ -164,14 +166,14 @@ set(optional_deps Alsa
XSLT
${PLATFORM_OPTIONAL_DEPS})

# Required tools
find_package(TexturePacker REQUIRED)
find_package(JsonSchemaBuilder REQUIRED)

# Check optional deps first, since their availability can influence required ones, e.g. ffmpeg
core_optional_dep(${optional_deps})
core_require_dep(${required_deps})

# Required tools
find_package(TexturePacker REQUIRED)
find_package(JsonSchemaBuilder REQUIRED)

SET(PYTHON_VERSION 3.8)

if(ENABLE_MARIADBCLIENT AND NOT ENABLE_MARIADBCLIENT STREQUAL AUTO AND ENABLE_MYSQLCLIENT AND NOT ENABLE_MYSQLCLIENT STREQUAL AUTO)
Expand Down
26 changes: 26 additions & 0 deletions cmake/modules/FindClangTidy.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#.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)
# 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)
1 change: 1 addition & 0 deletions cmake/scripts/android/ArchSetup.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ endif()
list(APPEND SYSTEM_DEFINES -DHAS_ZEROCONF)

set(ENABLE_X11 OFF CACHE BOOL "" FORCE)
set(ENABLE_CLANGTIDY OFF CACHE BOOL "Enable clang-tidy support?" FORCE)
set(ENABLE_OPTICAL OFF CACHE BOOL "" FORCE)
set(ENABLE_MDNS OFF CACHE BOOL "" FORCE)

Expand Down
1 change: 1 addition & 0 deletions lib/libUPnP/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ target_include_directories(upnp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}
if(CORE_SYSTEM_NAME STREQUAL windows OR CORE_SYSTEM_NAME STREQUAL windowsstore)
target_include_directories(upnp PRIVATE Neptune/Source/System/Win32)
endif()
set_target_properties(upnp PROPERTIES CXX_CLANG_TIDY "")
set_target_properties(upnp PROPERTIES FOLDER lib)
source_group_by_folder(upnp)
set(core_DEPENDS upnp ${core_DEPENDS} CACHE STRING "" FORCE)
Expand Down

0 comments on commit ea41be4

Please sign in to comment.