tde_create_translated_desktop: Avoid confusing paths when processing

a desktop file in a binary folder.

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

@ -1717,6 +1717,9 @@ macro( tde_create_translated_desktop )
endif( )
endforeach( )
# prepare the length of the binary path prefix
string( LENGTH "${CMAKE_BINARY_DIR}" CMAKE_BINARY_DIR_LEN )
# process source files
foreach( _src IN LISTS _srcs )
@ -1724,10 +1727,21 @@ macro( tde_create_translated_desktop )
get_filename_component( _basename ${_src} ABSOLUTE )
get_filename_component( _basedir ${_basename} PATH )
file( RELATIVE_PATH _sourcename "${CMAKE_SOURCE_DIR}" "${_basename}" )
file( RELATIVE_PATH _basename "${CMAKE_CURRENT_SOURCE_DIR}" "${_basename}" )
string( SUBSTRING "${_basename}" 0 ${CMAKE_BINARY_DIR_LEN} _basedir_prefix )
if( ${_basedir_prefix} STREQUAL "${CMAKE_BINARY_DIR}" )
file( RELATIVE_PATH _basename "${CMAKE_CURRENT_BINARY_DIR}" "${_basename}" )
set( _binsuffix ".out" )
else( )
file( RELATIVE_PATH _basename "${CMAKE_CURRENT_SOURCE_DIR}" "${_basename}" )
set( _binsuffix "" )
endif( )
# prepare the binary directory according to source directory
file( RELATIVE_PATH _binary_basedir "${CMAKE_CURRENT_SOURCE_DIR}" "${_basedir}" )
if( ${_basedir_prefix} STREQUAL "${CMAKE_BINARY_DIR}" )
file( RELATIVE_PATH _binary_basedir "${CMAKE_CURRENT_BINARY_DIR}" "${_basedir}" )
else( )
file( RELATIVE_PATH _binary_basedir "${CMAKE_CURRENT_SOURCE_DIR}" "${_basedir}" )
endif( )
set( _binary_basedir "${CMAKE_CURRENT_BINARY_DIR}/${_binary_basedir}" )
file( MAKE_DIRECTORY "${_binary_basedir}" )
@ -1770,6 +1784,7 @@ macro( tde_create_translated_desktop )
# if the translated desktop file is not installed, generate to the specified output name
if( "${_dest}" STREQUAL "-" )
set( _basename "${_out_name}" )
set( _binsuffix "" )
get_filename_component( _out_dir "${CMAKE_CURRENT_BINARY_DIR}/${_out_name}" PATH )
file( MAKE_DIRECTORY "${_out_dir}" )
endif( )
@ -1807,8 +1822,8 @@ macro( tde_create_translated_desktop )
# merge translations command
get_filename_component( _src ${_src} ABSOLUTE )
add_custom_command(
OUTPUT ${_basename}
COMMAND ${CMAKE_COMMAND} -E env "LINGUAS=${_linguas}" ${MSGFMT_EXECUTABLE} --desktop --template ${_src} -d ${_po_dir} -o ${_basename} ${_keywords_arg}
OUTPUT ${_basename}${_binsuffix}
COMMAND ${CMAKE_COMMAND} -E env "LINGUAS=${_linguas}" ${MSGFMT_EXECUTABLE} --desktop --template ${_src} -d ${_po_dir} -o ${_basename}${_binsuffix} ${_keywords_arg}
DEPENDS ${_src}
COMMENT "Merging translations into ${_sourcename}"
)
@ -1823,8 +1838,8 @@ macro( tde_create_translated_desktop )
# merge translations command
add_custom_command(
OUTPUT ${_basename}
COMMAND ${PERL_EXECUTABLE} ${INTLTOOL_MERGE_EXECUTABLE} -q -d ${_po_dir} ${_basename}.in ${_basename}
OUTPUT ${_basename}${_binsuffix}
COMMAND ${PERL_EXECUTABLE} ${INTLTOOL_MERGE_EXECUTABLE} -q -d ${_po_dir} ${_basename}.in ${_basename}${_binsuffix}
DEPENDS ${_src}
COMMENT "Merging translations into ${_sourcename}"
)
@ -1832,7 +1847,7 @@ macro( tde_create_translated_desktop )
endif( )
# merge translations target
add_custom_target( "${_target}" ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_basename} )
add_custom_target( "${_target}" ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/${_basename}${_binsuffix} )
endif()
@ -1840,14 +1855,14 @@ macro( tde_create_translated_desktop )
# just write the original file without translations
file( READ ${_src} _src_data )
file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/${_basename} "${_src_data}" )
file( WRITE ${CMAKE_CURRENT_BINARY_DIR}/${_basename}${_binsuffix} "${_src_data}" )
endif( )
# install traslated desktop file
if( NOT "${_dest}" STREQUAL "-" )
install(
FILES ${CMAKE_CURRENT_BINARY_DIR}/${_basename}
FILES ${CMAKE_CURRENT_BINARY_DIR}/${_basename}${_binsuffix}
RENAME ${_out_name}
DESTINATION ${_dest}
)

Loading…
Cancel
Save