From 8cf356884f1d6cd583dd28ba638253b6e94e6878 Mon Sep 17 00:00:00 2001 From: aneejit1 Date: Mon, 15 Jun 2020 16:20:34 +0000 Subject: [PATCH] Remove use of LINGUAS file to prevent writes to the source directory This is for the resolution of bug 3133 Signed-off-by: aneejit1 --- modules/TDEMacros.cmake | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake index 33a8779..5fc1667 100644 --- a/modules/TDEMacros.cmake +++ b/modules/TDEMacros.cmake @@ -1918,9 +1918,13 @@ macro( tde_create_translated_desktop ) if( DESKTOP_MERGE_MSGFMT ) - # create LINGUAS file for msgfmt - string( REPLACE ".po;" "\n" _linguas "${_translations};" ) - file( WRITE ${_po_dir}/LINGUAS "${_linguas}" ) + # Decide which translations to build; the ones selected in the + # LINGUAS environment variable, or all that are available. + if( DEFINED ENV{LINGUAS} ) + set( _linguas "$ENV{LINGUAS}" ) + else( ) + string( REPLACE ".po;" " " _linguas "${_translations};" ) + endif( ) # prepare keywords for msgfmt set( _keywords_arg "--keyword=" ) @@ -1932,22 +1936,10 @@ macro( tde_create_translated_desktop ) get_filename_component( _src ${_src} ABSOLUTE ) add_custom_command( OUTPUT ${_basename} - COMMAND ${MSGFMT_EXECUTABLE} --desktop --template ${_src} -d ${_po_dir} -o ${_basename} ${_keywords_arg} + COMMAND ${CMAKE_COMMAND} -E env "LINGUAS=${_linguas}" ${MSGFMT_EXECUTABLE} --desktop --template ${_src} -d ${_po_dir} -o ${_basename} ${_keywords_arg} DEPENDS ${_src} ) - # cleanup LINGUAS file - get_filename_component( _linguas_path "${_po_dir}/LINGUAS" ABSOLUTE ) - file( RELATIVE_PATH _linguas_path "${CMAKE_SOURCE_DIR}" "${_linguas_path}" ) - string( REPLACE "/" "+" _linguas_cleanup_target "${_linguas_path}-cleanup" ) - if( NOT TARGET ${_linguas_cleanup_target} ) - add_custom_target( ${_linguas_cleanup_target} ALL - COMMAND ${CMAKE_COMMAND} -E remove ${_po_dir}/LINGUAS - COMMENT "Cleanup ${_linguas_path} file..." - ) - endif( ) - add_dependencies( ${_linguas_cleanup_target} "${_target}" ) - else( ) # create template for intltool-merge