tde_create_translated_desktop: Prevent FTBFS on generated desktop files

Fix FTBFS when translations are missing and the desktop file passed to
tde_create_translated_desktop() is build-time generated.

See TDE/tde-packaging-gentoo #196 for details.

Signed-off-by: Alexander Golubev <fatzer2@gmail.com>
pull/69/head
Alexander Golubev 4 years ago
parent 111a08942a
commit f0a5bcc760

@ -1986,7 +1986,6 @@ macro( tde_create_translated_desktop )
if( EXISTS "${_po_dir}" AND IS_DIRECTORY "${_po_dir}" ) if( EXISTS "${_po_dir}" AND IS_DIRECTORY "${_po_dir}" )
file( GLOB _translations RELATIVE "${_po_dir}" "${_po_dir}/*.po" ) file( GLOB _translations RELATIVE "${_po_dir}" "${_po_dir}/*.po" )
endif( ) endif( )
if( _translations )
# prepare a full name for the target # prepare a full name for the target
get_filename_component( _target ${_basename} ABSOLUTE ) get_filename_component( _target ${_basename} ABSOLUTE )
@ -1995,6 +1994,11 @@ macro( tde_create_translated_desktop )
if( NOT TARGET ${_target} ) if( NOT TARGET ${_target} )
# use absolute path for src
get_filename_component( _src ${_src} ABSOLUTE )
if( _translations )
if( DESKTOP_MERGE_MSGFMT ) if( DESKTOP_MERGE_MSGFMT )
# Decide which translations to build; the ones selected in the # Decide which translations to build; the ones selected in the
@ -2012,7 +2016,6 @@ macro( tde_create_translated_desktop )
endforeach( ) endforeach( )
# merge translations command # merge translations command
get_filename_component( _src ${_src} ABSOLUTE )
add_custom_command( add_custom_command(
OUTPUT ${_basename}${_binsuffix} OUTPUT ${_basename}${_binsuffix}
COMMAND ${CMAKE_COMMAND} -E env "LINGUAS=${_linguas}" ${MSGFMT_EXECUTABLE} --desktop --template ${_src} -d ${_po_dir} -o ${_basename}${_binsuffix} ${_keywords_arg} COMMAND ${CMAKE_COMMAND} -E env "LINGUAS=${_linguas}" ${MSGFMT_EXECUTABLE} --desktop --template ${_src} -d ${_po_dir} -o ${_basename}${_binsuffix} ${_keywords_arg}
@ -2026,7 +2029,6 @@ macro( tde_create_translated_desktop )
string( REPLACE ";" "|" _keywords_match "(${_keywords_desktop})" ) string( REPLACE ";" "|" _keywords_match "(${_keywords_desktop})" )
# merge translations command # merge translations command
get_filename_component( _src ${_src} ABSOLUTE )
add_custom_command( add_custom_command(
OUTPUT ${_basename}${_binsuffix} OUTPUT ${_basename}${_binsuffix}
COMMAND ${PERL_EXECUTABLE} -p -e "'s/^${_keywords_match}[ ]*=[ ]*/_\\1=/'" < ${_src} > ${_basename}.in COMMAND ${PERL_EXECUTABLE} -p -e "'s/^${_keywords_match}[ ]*=[ ]*/_\\1=/'" < ${_src} > ${_basename}.in
@ -2038,15 +2040,20 @@ macro( tde_create_translated_desktop )
endif( ) endif( )
# merge translations target # merge translations target
add_custom_target( "${_target}" ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_basename}${_binsuffix} )
endif()
else( ) else( )
# just write the original file without translations # just copy the original file without translations
file( READ ${_src} _src_data ) add_custom_command(
file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/${_basename}${_binsuffix} "${_src_data}" ) OUTPUT ${_basename}${_binsuffix}
COMMAND ${CMAKE_COMMAND} -E copy ${_src} ${_basename}${_binsuffix}
DEPENDS ${_src}
COMMENT "Skiping translation and copying source file to ${_sourcename}"
)
endif( )
add_custom_target( "${_target}" ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_basename}${_binsuffix} )
endif( ) endif( )

Loading…
Cancel
Save