summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2021-01-25 19:48:52 +0100
committerSlávek Banko <slavek.banko@axis.cz>2021-01-27 16:15:45 +0100
commit068abb71055d872a07692e3660f856970aaa0578 (patch)
treee12750d7e85fe3d9c69005b3ab65178418240de4 /modules
parent3c690a351995f3a466df6355c1b25dd784cabbe8 (diff)
downloadtde-cmake-068abb71055d872a07692e3660f856970aaa0578.tar.gz
tde-cmake-068abb71055d872a07692e3660f856970aaa0578.zip
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 a5baa2c1ab82309a59ba67db8fd0530f097fd36e)
Diffstat (limited to 'modules')
-rw-r--r--modules/TDEMacros.cmake33
1 files changed, 24 insertions, 9 deletions
diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake
index 9d1a2e2..ee0af48 100644
--- a/modules/TDEMacros.cmake
+++ b/modules/TDEMacros.cmake
@@ -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}
)