aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/QtDeclarativeSetup.cmake
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-01-14 15:02:48 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-01-15 14:57:17 +0000
commit6ca613b23d2c73501803551ee66499c3a26a133d (patch)
tree443361882ddbc6560a6d815df39de2d6dd8ad2b8 /cmake/QtDeclarativeSetup.cmake
parentbfb3f8f71b5ae5eccca5fffbb0de2ab76db1e91f (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. Change-Id: Ifaf2c8145ab16d9f8d23570fa9acbb7a76ebda03 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit a1bba5cd3d5f8a88cd79e6f56149ab88d1abe8b8) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake/QtDeclarativeSetup.cmake')
-rw-r--r--cmake/QtDeclarativeSetup.cmake31
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")