diff options
Diffstat (limited to 'cmake/QtDeclarativeSetup.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) |