3930dc
From f315ca6a601e77220323bff4ac7782b54c862a0c Mon Sep 17 00:00:00 2001
3930dc
From: Milan Crha <mcrha@redhat.com>
3930dc
Date: Tue, 30 Oct 2018 15:50:58 +0100
3930dc
Subject: [PATCH] Make sure intltool-merge cache is created only once
3930dc
3930dc
Similar to https://gitlab.gnome.org/GNOME/evolution/issues/196
3930dc
when intltool-merge is called in parallel, it could either rewrite
3930dc
the ongoing attempt to build it or use an incomplete data, which
3930dc
results in broken output files (.desktop, .metainfo and so on).
3930dc
This change ensures the intltool-merge cache is created only once
3930dc
and any other requests which would use it will wait until it's created.
3930dc
---
3930dc
 cmake/modules/FindIntltool.cmake | 11 ++++++++++-
3930dc
 1 file changed, 10 insertions(+), 1 deletion(-)
3930dc
3930dc
diff --git a/cmake/modules/FindIntltool.cmake b/cmake/modules/FindIntltool.cmake
3930dc
index 2cda2549eb..8e223e9d7f 100644
3930dc
--- a/cmake/modules/FindIntltool.cmake
3930dc
+++ b/cmake/modules/FindIntltool.cmake
3930dc
@@ -176,9 +176,18 @@ macro(intltool_merge _in_filename _out_filename)
3930dc
 			DEPENDS ${_in}
3930dc
 		)
3930dc
 	else(_has_no_translations)
3930dc
+		if(NOT TARGET intltool-merge-cache)
3930dc
+			add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/po/.intltool-merge-cache
3930dc
+				COMMAND ${INTLTOOL_MERGE} ${_args} --quiet --cache="${CMAKE_BINARY_DIR}/po/.intltool-merge-cache" "${GETTEXT_PO_DIR}" "${_in}" "${_out}"
3930dc
+				DEPENDS ${_in}
3930dc
+			)
3930dc
+			add_custom_target(intltool-merge-cache ALL
3930dc
+				DEPENDS ${CMAKE_BINARY_DIR}/po/.intltool-merge-cache)
3930dc
+		endif(NOT TARGET intltool-merge-cache)
3930dc
+
3930dc
 		add_custom_command(OUTPUT ${_out}
3930dc
 			COMMAND ${INTLTOOL_MERGE} ${_args} --quiet --cache="${CMAKE_BINARY_DIR}/po/.intltool-merge-cache" "${GETTEXT_PO_DIR}" "${_in}" "${_out}"
3930dc
-			DEPENDS ${_in}
3930dc
+			DEPENDS ${_in} intltool-merge-cache
3930dc
 		)
3930dc
 	endif(_has_no_translations)
3930dc
 endmacro(intltool_merge)
3930dc
-- 
3930dc
2.18.1
3930dc