aboutsummaryrefslogtreecommitdiffstats
path: root/cmake/QtDeclarativeSetup.cmake
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-01-06 12:01:37 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2022-01-07 02:42:47 +0000
commit1a0277e925c0500a09968dec95dccdb67f0ddee8 (patch)
tree2af5a7e1eb6620cc0028717c45cd77aef2399424 /cmake/QtDeclarativeSetup.cmake
parentae1f2a6cd4e877e50d185db857c9aaa70aee8b86 (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. Task-number: QTBUG-99608 Change-Id: Ic42a073b196143f8576a84e7a4531b5f2927fb68 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io> (cherry picked from commit 0616a44e8ad0faa9c441212e281a61136c287f73) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'cmake/QtDeclarativeSetup.cmake')
-rw-r--r--cmake/QtDeclarativeSetup.cmake28
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)