瀏覽代碼

clang-tidy: Make .clang-tidy a build-time dependency

Currently a change to the clang-tidy configuration remains unnoticed for
incremental builds in the way that it won't trigger a rebuild. This can be
considered a missing dependency that this patch fixes by introducing a
compile time definition (-DCLANG_TIDY_SHA1) that triggers a rebuild upon
change. Currently this only applies to the target CMakeLib.

Signed-off-by: Matthias Maennich <[email protected]>
Matthias Maennich 8 年之前
父節點
當前提交
ffefdb2c08
共有 2 個文件被更改,包括 8 次插入0 次删除
  1. 6 0
      CMakeLists.txt
  2. 2 0
      Source/CMakeLists.txt

+ 6 - 0
CMakeLists.txt

@@ -250,6 +250,12 @@ if(CMake_RUN_CLANG_TIDY)
     message(FATAL_ERROR "CMake_RUN_CLANG_TIDY is ON but clang-tidy is not found!")
     message(FATAL_ERROR "CMake_RUN_CLANG_TIDY is ON but clang-tidy is not found!")
   endif()
   endif()
   set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")
   set(CMAKE_CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")
+
+  # provide definitions for targets that require a rebuild once .clang-tidy changes
+  file(SHA1 ${CMAKE_CURRENT_SOURCE_DIR}/.clang-tidy clang_tidy_sha1)
+  set(CLANG_TIDY_DEFINITIONS "CLANG_TIDY_SHA1=${clang_tidy_sha1}")
+  unset(clang_tidy_sha1)
+
 endif()
 endif()
 configure_file(.clang-tidy .clang-tidy COPYONLY)
 configure_file(.clang-tidy .clang-tidy COPYONLY)
 
 

+ 2 - 0
Source/CMakeLists.txt

@@ -779,6 +779,8 @@ if(WIN32 AND NOT UNIX)
   target_link_libraries(CMakeLib rpcrt4 crypt32)
   target_link_libraries(CMakeLib rpcrt4 crypt32)
 endif()
 endif()
 
 
+target_compile_definitions(CMakeLib PUBLIC ${CLANG_TIDY_DEFINITIONS})
+
 #
 #
 # CTestLib
 # CTestLib
 #
 #