diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-01-14 15:02:48 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-01-14 20:03:57 +0100 |
commit | a1bba5cd3d5f8a88cd79e6f56149ab88d1abe8b8 (patch) | |
tree | 8181d3e45ad47cb663592a1b6aa89b2808b055f9 /cmake | |
parent | c4f49a9e1f2c5a7819495f567f5ffe32d0eb468b (diff) |
CMake: If no git and no tag file are found, compute compile hash
In that case we can just hash all the source files in src/qml to get a
reasonable approximation of a compile hash.
Pick-to: 6.2 6.3
Change-Id: Ifaf2c8145ab16d9f8d23570fa9acbb7a76ebda03
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtDeclarativeSetup.cmake | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/cmake/QtDeclarativeSetup.cmake b/cmake/QtDeclarativeSetup.cmake index 5f7de2c2ee..82cfbd935f 100644 --- a/cmake/QtDeclarativeSetup.cmake +++ b/cmake/QtDeclarativeSetup.cmake @@ -6,23 +6,26 @@ function(qt_declarative_write_tag_header target_name) file(READ "${tag_file}" tag_contents) string(STRIP "${tag_contents}" tag_contents) endif() - if(NOT tag_contents STREQUAL "$Format:%H$") + find_program(git_path git) + + if(tag_contents AND NOT tag_contents STREQUAL "$Format:%H$") set(QML_COMPILE_HASH "${tag_contents}") - elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../.git") - find_program(git_path git) - if(git_path) - execute_process( - COMMAND ${git_path} rev-parse HEAD - OUTPUT_VARIABLE QML_COMPILE_HASH - OUTPUT_STRIP_TRAILING_WHITESPACE - WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") - else() - message(FATAL_ERROR "Cannot find a 'git' binary to retrieve QML compile hash in PATH!") - endif() + elseif(git_path AND EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../.git") + execute_process( + COMMAND ${git_path} rev-parse HEAD + OUTPUT_VARIABLE QML_COMPILE_HASH + OUTPUT_STRIP_TRAILING_WHITESPACE + WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") else() - message(FATAL_ERROR "Cannot find a source for the QML compile hash! " - "You need either a valid git repository or a non-empty .tag file.") + set(sources_hash "") + file(GLOB_RECURSE qtqml_source_files "${CMAKE_CURRENT_SOURCE_DIR}/*") + foreach(file IN LISTS qtqml_source_files) + file(SHA1 ${file} file_hash) + string(APPEND sources_hash ${file_hash}) + endforeach() + string(SHA1 QML_COMPILE_HASH "${sources_hash}") endif() + string(LENGTH "${QML_COMPILE_HASH}" QML_COMPILE_HASH_LENGTH) if(QML_COMPILE_HASH_LENGTH GREATER 0) configure_file("qml_compile_hash_p.h.in" "${CMAKE_CURRENT_BINARY_DIR}/qml_compile_hash_p.h") |