From 57fd5853a7b56818fa137afe931feec18cf0942d Mon Sep 17 00:00:00 2001
From: peijiankang <peijiankang@kylinos.cn>
Date: Wed, 30 Aug 2023 11:09:46 +0800
Subject: [PATCH] update Qt5LinguistToolsMacros.cmake

---
 src/linguist/Qt5LinguistToolsMacros.cmake | 46 ++++-------------------
 1 file changed, 7 insertions(+), 39 deletions(-)

diff --git a/src/linguist/Qt5LinguistToolsMacros.cmake b/src/linguist/Qt5LinguistToolsMacros.cmake
index 6a45e57..09f5845 100644
--- a/src/linguist/Qt5LinguistToolsMacros.cmake
+++ b/src/linguist/Qt5LinguistToolsMacros.cmake
@@ -42,17 +42,6 @@ function(QT5_CREATE_TRANSLATION _qm_files)
     set(_lupdate_files ${_LUPDATE_UNPARSED_ARGUMENTS})
     set(_lupdate_options ${_LUPDATE_OPTIONS})
 
-    list(FIND _lupdate_options "-extensions" _extensions_index)
-    if(_extensions_index GREATER -1)
-        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})
@@ -64,27 +53,15 @@ function(QT5_CREATE_TRANSLATION _qm_files)
             list(APPEND _my_sources ${_abs_FILE})
         endif()
     endforeach()
-    set(stamp_file_dir "${CMAKE_CURRENT_BINARY_DIR}/.lupdate")
-    if(NOT EXISTS "${stamp_file_dir}")
-        file(MAKE_DIRECTORY "${stamp_file_dir}")
-    endif()
     foreach(_ts_file ${_my_tsfiles})
-        get_filename_component(_ts_name ${_ts_file} NAME)
         if(_my_sources)
           # make a list file to call lupdate on, so we don't make our commands too
           # long for some systems
+          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)
@@ -95,15 +72,13 @@ function(QT5_CREATE_TRANSLATION _qm_files)
 
           file(WRITE ${_ts_lst_file} "${_lst_file_srcs}")
         endif()
-        set(stamp_file "${stamp_file_dir}/${_ts_name}.stamp")
-        add_custom_command(OUTPUT ${stamp_file}
+        add_custom_command(OUTPUT ${_ts_file}
             COMMAND ${Qt5_LUPDATE_EXECUTABLE}
             ARGS ${_lupdate_options} "@${_ts_lst_file}" -ts ${_ts_file}
-            COMMAND ${CMAKE_COMMAND} -E touch "${stamp_file}"
-            DEPENDS ${_dependencies}
-            VERBATIM)
+            DEPENDS ${_my_sources}
+            BYPRODUCTS ${_ts_lst_file} VERBATIM)
     endforeach()
-    qt5_add_translation(${_qm_files} __QT_INTERNAL_DEPEND_ON_TIMESTAMP_FILE ${_my_tsfiles})
+    qt5_add_translation(${_qm_files} ${_my_tsfiles})
     set(${_qm_files} ${${_qm_files}} PARENT_SCOPE)
 endfunction()
 
@@ -120,7 +95,7 @@ endif()
 
 
 function(QT5_ADD_TRANSLATION _qm_files)
-    set(options __QT_INTERNAL_DEPEND_ON_TIMESTAMP_FILE)
+    set(options)
     set(oneValueArgs)
     set(multiValueArgs OPTIONS)
 
@@ -130,7 +105,6 @@ function(QT5_ADD_TRANSLATION _qm_files)
     foreach(_current_FILE ${_lrelease_files})
         get_filename_component(_abs_FILE ${_current_FILE} ABSOLUTE)
         get_filename_component(qm ${_abs_FILE} NAME)
-        set(ts_stamp_file "${CMAKE_CURRENT_BINARY_DIR}/.lupdate/${qm}.stamp")
         # everything before the last dot has to be considered the file name (including other dots)
         string(REGEX REPLACE "\\.[^.]*$" "" FILE_NAME ${qm})
         get_source_file_property(output_location ${_abs_FILE} OUTPUT_LOCATION)
@@ -141,16 +115,10 @@ function(QT5_ADD_TRANSLATION _qm_files)
             set(qm "${CMAKE_CURRENT_BINARY_DIR}/${FILE_NAME}.qm")
         endif()
 
-        if(_LRELEASE___QT_INTERNAL_DEPEND_ON_TIMESTAMP_FILE)
-            set(qm_dep "${ts_stamp_file}")
-        else()
-            set(qm_dep "${_abs_FILE}")
-        endif()
-
         add_custom_command(OUTPUT ${qm}
             COMMAND ${Qt5_LRELEASE_EXECUTABLE}
             ARGS ${_LRELEASE_OPTIONS} ${_abs_FILE} -qm ${qm}
-            DEPENDS ${qm_dep} VERBATIM
+            DEPENDS ${_abs_FILE} VERBATIM
         )
         list(APPEND ${_qm_files} ${qm})
     endforeach()
-- 
2.33.0

