aboutsummaryrefslogtreecommitdiff
path: root/modules/ECMPoQmTools.cmake
diff options
context:
space:
mode:
authorAlex Merry <alex.merry@kde.org>2015-11-08 23:10:59 +0000
committerAlex Merry <alex.merry@kde.org>2015-11-30 14:07:07 +0000
commitfb4d91996affdbcd3ffc19c7646fbf77b96bf1e5 (patch)
tree2f66eec33d3b7b96691fe5aa5f9fe96f2029229f /modules/ECMPoQmTools.cmake
parent1e8e0da3eb475bb8b78baa54cb0c34b913c2dc5d (diff)
downloadextra-cmake-modules-fb4d91996affdbcd3ffc19c7646fbf77b96bf1e5.tar.gz
extra-cmake-modules-fb4d91996affdbcd3ffc19c7646fbf77b96bf1e5.tar.bz2
Make sure we load translations on the main thread.
Because the old implementation (accidentally) worked when you put the ecm_create_qm_loader call in a different CMakeLists.txt file to the target the file was added to, some projects did this. This won't work with build-time-generated files, though, like moc files. So we (ab)use QTimer events to make the loading happen on the main thread. BUG: 346188 REVIEW: 126000
Diffstat (limited to 'modules/ECMPoQmTools.cmake')
-rw-r--r--modules/ECMPoQmTools.cmake17
1 files changed, 12 insertions, 5 deletions
diff --git a/modules/ECMPoQmTools.cmake b/modules/ECMPoQmTools.cmake
index 0af5b12f..2547df1a 100644
--- a/modules/ECMPoQmTools.cmake
+++ b/modules/ECMPoQmTools.cmake
@@ -28,8 +28,8 @@
#
# ecm_create_qm_loader(<source_files_var> <catalog_name>)
#
-# Generates a C++ file which ensures translations are automatically loaded at
-# startup. The path of the .cpp file is appended to ``<source_files_var>``.
+# Generates C++ code which ensures translations are automatically loaded at
+# startup. The generated files are appended to ``<source_files_var>``.
#
# It assumes that the .qm file for the language code ``<lang>`` is installed as
# ``<sharedir>/locale/<lang>/LC_MESSAGES/<catalog_name>.qm``, where
@@ -99,9 +99,16 @@ endfunction()
function(ecm_create_qm_loader out_var catalog_name)
- # catalog_name is used in ECMQmLoader.cpp.in
- configure_file(${ECM_MODULE_DIR}/ECMQmLoader.cpp.in ECMQmLoader-${catalog_name}.cpp @ONLY)
- set(${out_var} ${${out_var}} ${CMAKE_CURRENT_BINARY_DIR}/ECMQmLoader-${catalog_name}.cpp PARENT_SCOPE)
+ set(loader_base ${CMAKE_CURRENT_BINARY_DIR}/ECMQmLoader-${catalog_name})
+
+ set(QM_LOADER_CATALOG_NAME "${catalog_name}")
+
+ configure_file(
+ ${ECM_MODULE_DIR}/ECMQmLoader.cpp.in
+ "${loader_base}.cpp"
+ @ONLY
+ )
+ set(${out_var} "${${out_var}}" "${loader_base}.cpp" PARENT_SCOPE)
endfunction()