summaryrefslogtreecommitdiffstats
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-25 21:40:16 +0100
commita5baa2c1ab82309a59ba67db8fd0530f097fd36e (patch)
treebbeb95b36740b1293071f24be17cbc57b41deb77
parent52001b90693f0c986d6aa2ceec69f9b8fa7b8699 (diff)
downloadtde-cmake-a5baa2c1ab82309a59ba67db8fd0530f097fd36e.tar.gz
tde-cmake-a5baa2c1ab82309a59ba67db8fd0530f097fd36e.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>
-rw-r--r--modules/TDEMacros.cmake33
1 files changed, 24 insertions, 9 deletions
diff --git a/modules/TDEMacros.cmake b/modules/TDEMacros.cmake
index 958f453..913c854 100644
--- a/modules/TDEMacros.cmake
+++ b/modules/TDEMacros.cmake
@@ -1904,6 +1904,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 )
@@ -1911,10 +1914,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}" )
@@ -1957,6 +1971,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( )
@@ -1994,8 +2009,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}"
)
@@ -2010,8 +2025,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}"
)
@@ -2019,7 +2034,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()
@@ -2027,14 +2042,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}
)