summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@qt.io>2020-10-26 17:24:59 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2020-11-04 13:44:48 +0000
commitc7d34b9090d5b08310e27be17f46b23a24d9d7cb (patch)
tree4c2e631b6632c6eba66f189b77f2b25b6c92355e
parentfb1c13fd5068a5679e548c52548975de0901fa28 (diff)
qt5_create_translation: Fix handling of directory dependencies
lupdate supports whole directories as sources. Anyhow, in this case we cannot just declare the directory as dependency; it will force lupdate to re-run every time and emit a warning: warning MSB8064: Custom build for item "..." succeeded, but specified dependency "<the directory specified as a source>" does not exist. This may cause incremental builds to work incorrectly. The patch checks if each specified source is a directory, and if so: * Generates globbing expressions for the list of extensions to be used. * Search the specified directory for matching files. * Add those files to the list of dependencies to give to CMake instead of the directory itself. The list of source file extensions is derived from lupdate defaults, but can be tweaked by a new '-extensions' argument. Original patch done by Chris Djali. Fixes: QTBUG-86192 Change-Id: Icc22be4f3ee096361ac319208261cdc8191d9adf Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> (cherry picked from commit 2834bebc9e6ba9bf0577db1d7da42a52e622adc6) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r--src/linguist/Qt5LinguistToolsMacros.cmake21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/linguist/Qt5LinguistToolsMacros.cmake b/src/linguist/Qt5LinguistToolsMacros.cmake
index ab271d56a..2e700bba9 100644
--- a/src/linguist/Qt5LinguistToolsMacros.cmake
+++ b/src/linguist/Qt5LinguistToolsMacros.cmake
@@ -41,6 +41,17 @@ function(QT5_CREATE_TRANSLATION _qm_files)
set(_lupdate_files ${_LUPDATE_UNPARSED_ARGUMENTS})
set(_lupdate_options ${_LUPDATE_OPTIONS})
+ if("-extensions" IN_LIST _lupdate_options)
+ list(FIND ${_lupdate_options} "-extensions" _extensions_index)
+ math(EXPR _extensions_index "${_extensions_index} + 1")
+ list(GET ${_lupdate_options} ${_extensions_index} _extensions_list)
+ string(REPLACE "," ";" _extensions_list "${_extensions_list}")
+ list(TRANSFORM _extensions_list STRIP)
+ list(TRANSFORM _extensions_list REPLACE "^\." "")
+ list(TRANSFORM _extensions_list PREPEND "*.")
+ else()
+ set(_extensions_list "*.java;*.jui;*.ui;*.c;*.c++;*.cc;*.cpp;*.cxx;*.ch;*.h;*.h++;*.hh;*.hpp;*.hxx;*.js;*.qs;*.qml;*.qrc")
+ endif()
set(_my_sources)
set(_my_tsfiles)
foreach(_file ${_lupdate_files})
@@ -59,8 +70,16 @@ function(QT5_CREATE_TRANSLATION _qm_files)
get_filename_component(_ts_name ${_ts_file} NAME)
set(_ts_lst_file "${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${_ts_name}_lst_file")
set(_lst_file_srcs)
+ set(_dependencies)
foreach(_lst_file_src ${_my_sources})
set(_lst_file_srcs "${_lst_file_src}\n${_lst_file_srcs}")
+ if(IS_DIRECTORY ${_lst_file_src})
+ list(TRANSFORM _extensions_list PREPEND "${_lst_file_src}/" OUTPUT_VARIABLE _directory_glob)
+ file(GLOB_RECURSE _directory_contents CONFIGURE_DEPENDS ${_directory_glob})
+ list(APPEND _dependencies ${_directory_contents})
+ else()
+ list(APPEND _dependencies "${_lst_file_src}")
+ endif()
endforeach()
get_directory_property(_inc_DIRS INCLUDE_DIRECTORIES)
@@ -74,7 +93,7 @@ function(QT5_CREATE_TRANSLATION _qm_files)
add_custom_command(OUTPUT ${_ts_file}
COMMAND ${Qt5_LUPDATE_EXECUTABLE}
ARGS ${_lupdate_options} "@${_ts_lst_file}" -ts ${_ts_file}
- DEPENDS ${_my_sources}
+ DEPENDS ${_dependencies}
BYPRODUCTS ${_ts_lst_file} VERBATIM)
endforeach()
qt5_add_translation(${_qm_files} ${_my_tsfiles})