summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoerg Bornemann <joerg.bornemann@qt.io>2024-02-14 16:49:22 +0100
committerJoerg Bornemann <joerg.bornemann@qt.io>2024-04-17 21:17:30 +0200
commit2cd79cc1c3f47a1b1ecdf3e6385a56b70ad54274 (patch)
tree6cc9311fa8c5058d5faa2b1f581e524547cc298a
parenta7b9ec7f6f465ce0d90edfe7154a4837b1fb9c00 (diff)
CMake: Add _qt_internal_get_i18n_catalogs_for_modules
This function finds the translations that belong to the Qt modules that are used by the project. "Used by the project" means just all modules that are pulled in via find_package for now. This code was in Qt6CoreDeploySupport.cmake before. Now, we can call it in other places too like Qt6LinguistToolsMacros.cmake. Task-number: QTBUG-110444 Change-Id: I338d54d93cf285190b1430608b32334692ae4c07 Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
-rw-r--r--src/corelib/Qt6CoreDeploySupport.cmake29
-rw-r--r--src/corelib/Qt6CoreMacros.cmake37
2 files changed, 37 insertions, 29 deletions
diff --git a/src/corelib/Qt6CoreDeploySupport.cmake b/src/corelib/Qt6CoreDeploySupport.cmake
index 2615eca4ea..2fc8f8bf1c 100644
--- a/src/corelib/Qt6CoreDeploySupport.cmake
+++ b/src/corelib/Qt6CoreDeploySupport.cmake
@@ -585,34 +585,7 @@ function(qt6_deploy_translations)
if(arg_CATALOGS)
set(catalogs ${arg_CATALOGS})
else()
- set(catalogs qtbase)
-
- # Find the translations that belong to the Qt modules that are used by the project.
- # "Used by the project" means just all modules that are pulled in via find_package for now.
- set(modules ${__QT_DEPLOY_ALL_MODULES_FOUND_VIA_FIND_PACKAGE})
-
- set(module_catalog_mapping
- "Bluetooth|Nfc" qtconnectivity
- "Help" qt_help
- "Multimedia(Widgets|QuickPrivate)?" qtmultimedia
- "Qml|Quick" qtdeclarative
- "SerialPort" qtserialport
- "WebEngine" qtwebengine
- "WebSockets" qtwebsockets
- )
- list(LENGTH module_catalog_mapping max_i)
- math(EXPR max_i "${max_i} - 1")
- foreach(module IN LISTS modules)
- foreach(i RANGE 0 ${max_i} 2)
- list(GET module_catalog_mapping ${i} module_rex)
- if(NOT module MATCHES "^${module_rex}")
- continue()
- endif()
- math(EXPR k "${i} + 1")
- list(GET module_catalog_mapping ${k} catalog)
- list(APPEND catalogs ${catalog})
- endforeach()
- endforeach()
+ set(catalogs ${__QT_DEPLOY_I18N_CATALOGS})
endif()
get_filename_component(qt_translations_dir "${__QT_DEPLOY_QT_INSTALL_TRANSLATIONS}" ABSOLUTE
diff --git a/src/corelib/Qt6CoreMacros.cmake b/src/corelib/Qt6CoreMacros.cmake
index 04b5c4f62e..3bcf790006 100644
--- a/src/corelib/Qt6CoreMacros.cmake
+++ b/src/corelib/Qt6CoreMacros.cmake
@@ -3497,6 +3497,40 @@ if(NOT QT_NO_CREATE_VERSIONLESS_FUNCTIONS)
endmacro()
endif()
+# Store in ${out_var} the i18n catalogs that belong to the passed Qt modules.
+# The catalog "qtbase" is always added to the result.
+#
+# Example:
+# _qt_internal_get_i18n_catalogs_for_modules(catalogs Quick Help)
+# catalogs -> qtbase;qtdeclarative;qt_help
+function(_qt_internal_get_i18n_catalogs_for_modules out_var)
+ set(result "qtbase")
+ set(modules "${ARGN}")
+ set(module_catalog_mapping
+ "Bluetooth|Nfc" qtconnectivity
+ "Help" qt_help
+ "Multimedia(Widgets|QuickPrivate)?" qtmultimedia
+ "Qml|Quick" qtdeclarative
+ "SerialPort" qtserialport
+ "WebEngine" qtwebengine
+ "WebSockets" qtwebsockets
+ )
+ list(LENGTH module_catalog_mapping max_i)
+ math(EXPR max_i "${max_i} - 1")
+ foreach(module IN LISTS modules)
+ foreach(i RANGE 0 ${max_i} 2)
+ list(GET module_catalog_mapping ${i} module_rex)
+ if(NOT module MATCHES "^(${module_rex})")
+ continue()
+ endif()
+ math(EXPR k "${i} + 1")
+ list(GET module_catalog_mapping ${k} catalog)
+ list(APPEND result ${catalog})
+ endforeach()
+ endforeach()
+ set("${out_var}" "${result}" PARENT_SCOPE)
+endfunction()
+
function(qt6_generate_deploy_script)
set(no_value_options "")
set(single_value_options
@@ -3586,9 +3620,10 @@ function(qt6_generate_deploy_script)
string(APPEND deploy_script "${config_infix}.cmake")
set(${arg_OUTPUT_SCRIPT} "${deploy_script}" PARENT_SCOPE)
+ _qt_internal_get_i18n_catalogs_for_modules(catalogs ${QT_ALL_MODULES_FOUND_VIA_FIND_PACKAGE})
set(boiler_plate "include(${QT_DEPLOY_SUPPORT})
include(\"\${CMAKE_CURRENT_LIST_DIR}/${arg_TARGET}-plugins${config_infix}.cmake\" OPTIONAL)
-set(__QT_DEPLOY_ALL_MODULES_FOUND_VIA_FIND_PACKAGE \"${QT_ALL_MODULES_FOUND_VIA_FIND_PACKAGE}\")
+set(__QT_DEPLOY_I18N_CATALOGS \"${catalogs}\")
")
list(TRANSFORM arg_CONTENT REPLACE "\\$" "\$")
file(GENERATE OUTPUT ${deploy_script} CONTENT "${boiler_plate}${arg_CONTENT}")