tde_create_translated_desktop: Use full name for target.

This solves the case where the desktop file name is not unique
throughout the project.

Signed-off-by: Slávek Banko <slavek.banko@axis.cz>
(cherry picked from commit fd7d9c535e)
v3.5.13-sru
Slávek Banko 5 years ago
parent ada3f01f8d
commit dbef499b21
No known key found for this signature in database
GPG Key ID: 608F5293A04BE668

@ -1520,6 +1520,12 @@ macro( tde_create_translated_desktop )
file( GLOB _translations RELATIVE "${_po_dir}" "${_po_dir}/*.po" ) file( GLOB _translations RELATIVE "${_po_dir}" "${_po_dir}/*.po" )
endif( ) endif( )
if( _translations ) if( _translations )
# prepare a full name for the target
get_filename_component( _target ${_src} ABSOLUTE )
file( RELATIVE_PATH _target "${CMAKE_SOURCE_DIR}" "${_target}" )
string( REPLACE "/" "+" _target "${_target}-translated" )
if( DESKTOP_MERGE_MSGFMT ) if( DESKTOP_MERGE_MSGFMT )
# create LINGUAS file for msgfmt # create LINGUAS file for msgfmt
@ -1532,28 +1538,25 @@ macro( tde_create_translated_desktop )
list( APPEND _keywords_arg "--keyword=\"${_keyword}\"" ) list( APPEND _keywords_arg "--keyword=\"${_keyword}\"" )
endforeach( ) endforeach( )
# merge translations # merge translations command
get_filename_component( _src ${_src} ABSOLUTE ) get_filename_component( _src ${_src} ABSOLUTE )
add_custom_command( add_custom_command(
OUTPUT ${_out_name} OUTPUT ${_out_name}
COMMAND ${MSGFMT_EXECUTABLE} --desktop --template ${_src} -d ${_po_dir} -o ${_out_name} ${_keywords_arg} COMMAND ${MSGFMT_EXECUTABLE} --desktop --template ${_src} -d ${_po_dir} -o ${_out_name} ${_keywords_arg}
DEPENDS ${_src} DEPENDS ${_src}
) )
add_custom_target( "${_out_name}-translated" ALL DEPENDS ${_out_name} )
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${_out_name} DESTINATION ${_dest} )
# cleanup LINGUAS file # cleanup LINGUAS file
get_filename_component( _linguas_path "${_po_dir}/LINGUAS" ABSOLUTE ) get_filename_component( _linguas_path "${_po_dir}/LINGUAS" ABSOLUTE )
file( RELATIVE_PATH _linguas_path "${CMAKE_SOURCE_DIR}" "${_linguas_path}" ) file( RELATIVE_PATH _linguas_path "${CMAKE_SOURCE_DIR}" "${_linguas_path}" )
string( REPLACE "/" "+" _linguas_cleanup_target "${_linguas_path}" ) string( REPLACE "/" "+" _linguas_cleanup_target "${_linguas_path}-cleanup" )
if( NOT TARGET ${_linguas_cleanup_target} ) if( NOT TARGET ${_linguas_cleanup_target} )
add_custom_target( ${_linguas_cleanup_target} ALL add_custom_target( ${_linguas_cleanup_target} ALL
COMMAND ${CMAKE_COMMAND} -E remove ${_po_dir}/LINGUAS COMMAND ${CMAKE_COMMAND} -E remove ${_po_dir}/LINGUAS
COMMENT "Cleanup ${_linguas_path} file..." COMMENT "Cleanup ${_linguas_path} file..."
) )
endif( NOT TARGET ${_linguas_cleanup_target} ) endif( )
add_dependencies( ${_linguas_cleanup_target} "${_target}" )
add_dependencies( ${_linguas_cleanup_target} "${_out_name}-translated" )
else( ) else( )
@ -1563,16 +1566,19 @@ macro( tde_create_translated_desktop )
string( REGEX REPLACE "(^|\n)${_keywords_match}=" "\\1_\\2=" _src_data "${_src_data}" ) string( REGEX REPLACE "(^|\n)${_keywords_match}=" "\\1_\\2=" _src_data "${_src_data}" )
file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/${_out_name}.in "${_src_data}" ) file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/${_out_name}.in "${_src_data}" )
# merge translations # merge translations command
add_custom_command( add_custom_command(
OUTPUT ${_out_name} OUTPUT ${_out_name}
COMMAND ${INTLTOOL_MERGE_EXECUTABLE} -d ${_po_dir} ${_out_name}.in ${_out_name} COMMAND ${INTLTOOL_MERGE_EXECUTABLE} -d ${_po_dir} ${_out_name}.in ${_out_name}
DEPENDS ${_src} DEPENDS ${_src}
) )
add_custom_target( "${_out_name}-translated" ALL DEPENDS ${_out_name} )
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${_out_name} DESTINATION ${_dest} )
endif( ) endif( )
# merge translations target
add_custom_target( "${_target}" ALL DEPENDS ${_out_name} )
install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${_out_name} DESTINATION ${_dest} )
else( ) else( )
# just install the original file without translations # just install the original file without translations

Loading…
Cancel
Save