diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2022-01-06 12:01:37 +0100 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2022-01-07 01:17:39 +0100 |
commit | 0616a44e8ad0faa9c441212e281a61136c287f73 (patch) | |
tree | a2af59a275f8290aec1a75a577148f9da1b31988 /cmake | |
parent | 453902af4f4cdac11aecab4e173604a7bf7e5a54 (diff) |
Fix handling of QML_COMPILE_HASH
We need to check for the contents of the tag file, not its name. We need
to strip the contents before checking. We need to run git in the right
directory. We need to fail if we cannot find any QML_COMPILE_HASH.
Pick-to: 6.3 6.2
Task-number: QTBUG-99608
Change-Id: Ic42a073b196143f8576a84e7a4531b5f2927fb68
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Diffstat (limited to 'cmake')
-rw-r--r-- | cmake/QtDeclarativeSetup.cmake | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/cmake/QtDeclarativeSetup.cmake b/cmake/QtDeclarativeSetup.cmake index cd5ae32e14..5f7de2c2ee 100644 --- a/cmake/QtDeclarativeSetup.cmake +++ b/cmake/QtDeclarativeSetup.cmake @@ -4,18 +4,32 @@ function(qt_declarative_write_tag_header target_name) set(tag_contents "") if(EXISTS "${tag_file}") file(READ "${tag_file}" tag_contents) + string(STRIP "${tag_contents}" tag_contents) endif() - if(NOT tag_file STREQUAL "$Format:%H$") + if(NOT tag_contents STREQUAL "$Format:%H$") set(QML_COMPILE_HASH "${tag_contents}") - string(STRIP "${QML_COMPILE_HASH}" QML_COMPILE_HASH) elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../../.git") - execute_process( - COMMAND git rev-parse HEAD - OUTPUT_VARIABLE QML_COMPILE_HASH - OUTPUT_STRIP_TRAILING_WHITESPACE) + 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() + 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.") endif() string(LENGTH "${QML_COMPILE_HASH}" QML_COMPILE_HASH_LENGTH) - configure_file("qml_compile_hash_p.h.in" "${CMAKE_CURRENT_BINARY_DIR}/qml_compile_hash_p.h") + if(QML_COMPILE_HASH_LENGTH GREATER 0) + configure_file("qml_compile_hash_p.h.in" "${CMAKE_CURRENT_BINARY_DIR}/qml_compile_hash_p.h") + else() + message(FATAL_ERROR "QML compile hash is empty! " + "You need either a valid git repository or a non-empty .tag file.") + endif() endfunction() find_package(PythonInterp REQUIRED) |