Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce cmake variable MIOPEN_USE_CLANG_TIDY #3171

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 20 additions & 17 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -685,24 +685,27 @@ rocm_create_package(
)

include(EnableCompilerWarnings)
set(MIOPEN_TIDY_ERRORS ERRORS * -readability-inconsistent-declaration-parameter-name)
if(CMAKE_CXX_COMPILER MATCHES ".*clang\\+\\+")
set(MIOPEN_TIDY_CHECKS -modernize-use-override -readability-non-const-parameter)
# Enable tidy on hip
elseif(MIOPEN_BACKEND STREQUAL "HIP" OR MIOPEN_BACKEND STREQUAL "HIPNOGPU")
set(MIOPEN_TIDY_ERRORS ALL)
endif()
option(MIOPEN_USE_CLANG_TIDY "Use clang tidy to find problems" ON)
if(MIOPEN_USE_CLANG_TIDY)
set(MIOPEN_TIDY_ERRORS ERRORS * -readability-inconsistent-declaration-parameter-name)
if(CMAKE_CXX_COMPILER MATCHES ".*clang\\+\\+")
set(MIOPEN_TIDY_CHECKS -modernize-use-override -readability-non-const-parameter)
# Enable tidy on hip
elseif(MIOPEN_BACKEND STREQUAL "HIP" OR MIOPEN_BACKEND STREQUAL "HIPNOGPU")
set(MIOPEN_TIDY_ERRORS ALL)
endif()

include(ClangTidy)
enable_clang_tidy(
CHECKS
${MIOPEN_TIDY_CHECKS}
${MIOPEN_TIDY_ERRORS}
HEADER_FILTER
"\.hpp$"
EXTRA_ARGS
-DMIOPEN_USE_CLANG_TIDY
)
include(ClangTidy)
enable_clang_tidy(
CHECKS
${MIOPEN_TIDY_CHECKS}
${MIOPEN_TIDY_ERRORS}
HEADER_FILTER
"\.hpp$"
EXTRA_ARGS
-DMIOPEN_USE_CLANG_TIDY
)
endif()

include(CppCheck)
enable_cppcheck(
Expand Down
4 changes: 3 additions & 1 deletion addkernels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,6 @@ if(HAS_LIB_STD_FILESYSTEM)
target_link_libraries(addkernels PRIVATE stdc++fs)
endif()

clang_tidy_check(addkernels)
if(MIOPEN_USE_CLANG_TIDY)
clang_tidy_check(addkernels)
endif()
4 changes: 3 additions & 1 deletion speedtests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ endif()

function(add_speedtest_executable TEST_NAME)
add_executable (${TEST_NAME} EXCLUDE_FROM_ALL ${ARGN})
clang_tidy_check(${TEST_NAME})
if(MIOPEN_USE_CLANG_TIDY)
clang_tidy_check(${TEST_NAME})
endif()
target_link_libraries(${TEST_NAME} ${CMAKE_THREAD_LIBS_INIT})
# Cmake does not add flags correctly for gcc
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
Expand Down
4 changes: 3 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,9 @@ endif()

rocm_set_soversion(MIOpen ${MIOpen_SOVERSION})

clang_tidy_check(MIOpen)
if(MIOPEN_USE_CLANG_TIDY)
clang_tidy_check(MIOpen)
endif()

if(HAS_LIB_STD_FILESYSTEM)
target_link_libraries(MIOpen PRIVATE stdc++fs)
Expand Down
4 changes: 3 additions & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,9 @@ function(add_test_executable TEST_NAME)
if(WIN32)
target_compile_definitions(${TEST_NAME} PRIVATE NOMINMAX)
endif()
clang_tidy_check(${TEST_NAME})
if(MIOPEN_USE_CLANG_TIDY)
clang_tidy_check(${TEST_NAME})
endif()
target_link_libraries(${TEST_NAME} Threads::Threads)
# Cmake does not add flags correctly for gcc
if(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
Expand Down
4 changes: 3 additions & 1 deletion tools/sqlite2txt/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ if (NOT WIN32)
target_link_libraries(sqlite2txt dl)
endif()

clang_tidy_check(sqlite2txt)
if(MIOPEN_USE_CLANG_TIDY)
clang_tidy_check(sqlite2txt)
endif()