@@ -274,16 +274,48 @@ endif()
274274
275275if ("${CMAKE_CXX_COMPILER_ID} " STREQUAL "Clang" )
276276 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated-register -Wsign-compare" )
277+ execute_process (COMMAND
278+ find ${CMAKE_SOURCE_DIR} /dali ${CMAKE_SOURCE_DIR} /include
279+ -type f
280+ -regex ".*\\ .\\ (h\\ |hpp\\ |cuh\\ |inl\\ )$"
281+ OUTPUT_VARIABLE ALL_HEADERS
282+ OUTPUT_STRIP_TRAILING_WHITESPACE)
283+ #ECHO_OUTPUT_VARIABLE
284+ #COMMAND_ECHO STDOUT)
285+ # string(REGEX REPLACE "\n$" "|" ALL_HEADERS "${ALL_HEADERS}")
286+ # string(REPLACE "\n" ";" ALL_HEADERS_LIST ${ALL_HEADERS})
287+ # Remove the absolute path so we can apply filter file easily.
288+ string (REPLACE "${CMAKE_SOURCE_DIR} /" "" ALL_HEADERS ${ALL_HEADERS} )
289+ # string(REGEX REPLACE "\\." "\." ALL_HEADERS "${ALL_HEADERS}")
290+ message (STATUS "ALL_HEADERS is set to ${ALL_HEADERS} " )
291+ set (TEST_LIST "include/dali/core/tensor_shape\\ .h|include/dali/core/util\\ .h" )
292+
293+ file (READ ".clang-tidy-filter" CLANG_TIDY_LINE_FILTER)
294+ # make this a list
295+ string (REPLACE "\n " ";" CLANG_TIDY_LINE_FILTER ${CLANG_TIDY_LINE_FILTER} )
296+ foreach (FILTERED IN ITEMS ${CLANG_TIDY_LINE_FILTER} )
297+ string (REPLACE ${FILTERED} "" ALL_HEADERS ${ALL_HEADERS} )
298+ endforeach ()
299+ # nice and consistent argument order, we need to strip
300+ string (STRIP ${ALL_HEADERS} ALL_HEADERS)
301+
302+ # Format into the regex - make every line an alternative, swap . into \. and
303+ # We may have some empty newlines after the filtering
304+ string (REGEX REPLACE "(\n )+" "|" ALL_HEADERS ${ALL_HEADERS} )
305+ string (REPLACE "." "\\ ." ALL_HEADERS ${ALL_HEADERS} )
306+ message (STATUS "ALL_HEADERS is set to ${ALL_HEADERS} " )
307+
277308
278309 # Settings specific to builds where Clang is used for compiling CUDA code
279310 if (DALI_CLANG_ONLY)
280311 # Full power of clang-tidy
281312 # Remove some that appera in fp16 and tests, and try again
282- file (READ ".clang-tidy-filter.json" CLANG_TIDY_LINE_FILTER)
283313 set (CMAKE_CXX_CLANG_TIDY "clang-tidy"
284- "-warnings-as-errors=-*,bugprone-*,misc-*,modernize-*,clang-analyzer-*"
285- "-checks=-clang-analyzer-security.FloatLoopCounter,-clang-analyzer-core.DivideZero,-clang-analyzer-core.UndefinedBinaryOperatorResult"
286- "-header-filter=.*" )
314+ "-header-filter=${ALL_HEADERS} " )
315+ # "--extra-arg-before=--system-header-prefix=include/dali/util/half.hpp")
316+ # "-warnings-as-errors=-*,bugprone-*,misc-*,modernize-*,clang-analyzer-*"
317+ # "-checks=-clang-analyzer-security.FloatLoopCounter,-clang-analyzer-core.DivideZero,-clang-analyzer-core.UndefinedBinaryOperatorResult"
318+ # "-header-filter=.*")
287319 # Line filter filters too much
288320 # "-line-filter=${CLANG_TIDY_LINE_FILTER}")
289321 message (STATUS "CMAKE_CXX_CLANG_TIDY is set to ${CMAKE_CXX_CLANG_TIDY} " )
0 commit comments