diff --git a/CMakeLists.txt b/CMakeLists.txt index e53dd871c9..474308f48f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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( diff --git a/addkernels/CMakeLists.txt b/addkernels/CMakeLists.txt index 30c54ee491..8d73ac59ca 100644 --- a/addkernels/CMakeLists.txt +++ b/addkernels/CMakeLists.txt @@ -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() diff --git a/speedtests/CMakeLists.txt b/speedtests/CMakeLists.txt index 3a00a7013a..7566dc2542 100644 --- a/speedtests/CMakeLists.txt +++ b/speedtests/CMakeLists.txt @@ -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") diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ea6bbc77f0..7e7d4722a8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 434fdfe5df..acf6c8199f 100755 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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") diff --git a/tools/sqlite2txt/CMakeLists.txt b/tools/sqlite2txt/CMakeLists.txt index 3b3ba47801..f1e645edf9 100644 --- a/tools/sqlite2txt/CMakeLists.txt +++ b/tools/sqlite2txt/CMakeLists.txt @@ -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()