@ -46,6 +46,16 @@ if( NOT DEFINED EXTRACTRC_EXECUTABLE )
endif ( )
endif ( )
if ( NOT DEFINED EXTRACTATTR_EXECUTABLE )
find_program ( EXTRACTATTR_EXECUTABLE
N A M E S e x t r a c t a t t r
H I N T S " $ { T D E _ P R E F I X } / b i n "
)
if ( NOT EXTRACTATTR_EXECUTABLE )
tde_message_fatal ( "extractattr is required but not found" )
endif ( )
endif ( )
if ( NOT DEFINED XGETTEXT_EXECUTABLE )
find_program ( XGETTEXT_EXECUTABLE
N A M E S x g e t t e x t
@ -94,6 +104,10 @@ endfunction( )
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # #
# # # # # t d e _ a u t o _ a d d _ l 1 0 n _ s u b d i r e c t o r i e s
# # # # #
# # # # # T h e f u n c t i o n i s e q u i v a l e n t t o t d e _ a u t o _ a d d _ s u b d i r e c t o r i e s , b u t
# # # # # t h e C M a k e L 1 0 n . t x t f i l e i s u s e d i n s t e a d o f C M a k e L i s t s . t x t .
# # # # #
function ( tde_auto_add_l10n_subdirectories )
file ( GLOB _dirs RELATIVE ${ CMAKE_CURRENT_SOURCE_DIR } "${CMAKE_CURRENT_SOURCE_DIR}/*" )
@ -110,6 +124,35 @@ endfunction( )
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# # # # #
# # # # # t d e _ c r e a t e _ l 1 0 n _ t e m p l a t e
# # # # #
# # # # # M a c r o i s u s e d t o g e n e r a t e a t r a n s l a t i o n t e m p l a t e - P O T f i l e .
# # # # #
# # # # # S y n t a x :
# # # # # tde_create_l10n_template (
# # # # # C A T A L O G f i l e _ n a m e
# # # # # [ S O U R C E S s o u r c e _ s p e c [ s o u r c e _ s p e c ] ]
# # # # # [ K E Y W O R D S k e y w o r d [ k e y w o r d ] ]
# # # # # [ A T T R I B U T E S a t t r i b _ s p e c [ a t t r i b _ s p e c ] ]
# # # # # [ D E S T I N A T I O N d i r e c t o r y ]
# # # # # )
# # # # #
# # # # # W h e r e :
# # # # # C A T A L O G d e t e r m i n e s t h e t a r g e t f i l e name ( without pot suffix ) .
# # # # # S O U R C E S c a n b e s p e c i f i e d b y s e v e r a l o p t i o n s :
# # # # # a ) D o n o t s p e c i f y a n y t h i n g
# # # # # - a l l u s u a l s o u r c e f i l e s w i l l b e a u t o m a t i c a l l y s e a r c h e d .
# # # # # b ) E n t e r t h e d i r e c t o r y n a m e - f o r e x a m p l e , ' . ' o r ' s r c '
# # # # # - a l l t h e u s u a l s o u r c e f i l e s i n t h e s p e c i f i e d d i r e c t o r y
# # # # # a n d s u b d i r e c t o r i e s w i l l b e s e a r c h e d .
# # # # # c ) E n t e r t h e m a s k - f o r e x a m p l e ' * . c p p '
# # # # # - a l l f i l e s w i t h t h e s p e c i f i e d m a s k w i l l b e s e a r c h e d .
# # # # # d ) S p e c i f y t h e n a m e o f t h e i n d i v i d u a l f i l e .
# # # # # T h e m e t h o d s f r o m b ) t o d ) c a n b e c o m b i n e d .
# # # # # K E Y W O R D S d e t e r m i n e s a d d i t i o n a l k e y w o r d s f o r x g e t t e x t .
# # # # # A T T R I B U T E S d e t e r m i n e s f i l e s a n d s p e c i f i c a t i o n f o r e x t r a c t a t t r :
# # # # # s o u r c e _ s p e c : e l e m e n t , a t t r i b u t e [ , c o n t e x t ]
# # # # # D E S T I N A T I O N d e t e r m i n e s d i r e c t o r y t o s a v e t r a n s l a t i o n t e m p l a t e .
# # # # #
macro ( tde_create_l10n_template )
@ -120,6 +163,7 @@ macro( tde_create_l10n_template )
unset ( _desktops )
unset ( _dest )
unset ( _keywords )
unset ( _attributes )
unset ( _directive )
unset ( _var )
unset ( _pot )
@ -154,6 +198,13 @@ macro( tde_create_l10n_template )
set ( _directive 1 )
endif ( )
# f o u n d d i r e c t i v e " A T T R I B U T E S "
if ( "+${_arg}" STREQUAL "+ATTRIBUTES" )
unset ( _attributes )
set ( _var _attributes )
set ( _directive 1 )
endif ( )
# c o l l e c t d a t a
if ( _directive )
unset ( _directive )
@ -176,7 +227,7 @@ macro( tde_create_l10n_template )
message ( STATUS "Create translation template ${_potFilename}" )
# v e r i f y s o u r c e s
if ( NOT _sources )
if ( NOT _sources AND NOT _attributes )
# a d d c u r r e n t d i r e c t o r y
list ( APPEND _sources "." )
endif ( )
@ -211,13 +262,13 @@ macro( tde_create_l10n_template )
list ( SORT _add_files )
list ( APPEND _files ${ _add_files } )
# a d d a si n g l e f i l e
# a d d a in d i v i d u a l f i l e
elseif ( EXISTS ${ CMAKE_CURRENT_SOURCE_DIR } / ${ _src } )
list ( APPEND _files ${ _src } )
endif ( )
endforeach ( )
if ( NOT _files )
if ( NOT _files AND NOT _attributes )
tde_message_fatal ( "no source files found" )
endif ( )
@ -235,14 +286,44 @@ macro( tde_create_l10n_template )
endif ( )
endforeach ( )
# p r e p a r e e x t r a c t e d - r c . c p p
if ( _rcs OR _attributes )
file ( WRITE ${ CMAKE_CURRENT_SOURCE_DIR } /extracted-rc.cpp "" )
list ( APPEND _files extracted-rc.cpp )
endif ( )
# p r o c e s s r e s o u r c e f i l e s
if ( _rcs )
execute_process (
C O M M A N D $ { E X T R A C T R C _ E X E C U T A B L E } $ { _ r c s }
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R }
O U T P U T _ F I L E $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / e x t r a c t e d - r c . c p p
O U T P U T _ VA R I A B L E _ s o u r c e s _ r c
)
list ( APPEND _files extracted-rc.cpp )
file ( APPEND ${ CMAKE_CURRENT_SOURCE_DIR } /extracted-rc.cpp ${ _sources_rc } )
endif ( )
# e x t r a c t a t t r i b u t e s
if ( _attributes )
foreach ( _attrib ${ _attributes } )
if ( ${ _attrib } MATCHES "^([^:]+):(.+)$" )
string ( REGEX REPLACE "^([^:]+):(.+)$" "\\1" _attrib_glob ${ _attrib } )
string ( REGEX REPLACE "^([^:]+):(.+)$" "\\2" _attrib_spec ${ _attrib } )
file ( GLOB_RECURSE _attrib_files
R E L A T I V E $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R }
$ { C M A K E _ C U R R E N T _ S O U R C E _ D I R } / $ { _ a t t r i b _ g l o b }
)
if ( _attrib_files )
list ( SORT _attrib_files )
execute_process (
C O M M A N D $ { E X T R A C T A T T R _ E X E C U T A B L E }
- - a t t r = $ { _ a t t r i b _ s p e c } $ { _ a t t r i b _ f i l e s }
W O R K I N G _ D I R E C T O R Y $ { C M A K E _ C U R R E N T _ S O U R C E _ D I R }
O U T P U T _ V A R I A B L E _ a t t r i b _ r c
)
file ( APPEND ${ CMAKE_CURRENT_SOURCE_DIR } /extracted-rc.cpp ${ _attrib_rc } )
endif ( )
endif ( )
endforeach ( )
endif ( )
# p i c k d e s k t o p f i l e s * . d e s k t o p a n d * . p r o t o c o l
@ -312,7 +393,7 @@ macro( tde_create_l10n_template )
if ( _pot )
# u p d a t e r e f e r e n c e s f o r r e s o u r c e s t o o r i g i n a l f i l e s a n d l i n e n u m b e r s
if ( _rcs )
if ( _rcs OR _attributes )
file ( STRINGS "${CMAKE_CURRENT_SOURCE_DIR}/extracted-rc.cpp" _extractedRC )
list ( LENGTH _extractedRC _extractedRC_len )
set ( _rcPos 0 )
@ -346,7 +427,7 @@ macro( tde_create_l10n_template )
endif ( _pot )
# c l e a n u p
if ( _rcs )
if ( _rcs OR _attributes )
file ( REMOVE ${ CMAKE_CURRENT_SOURCE_DIR } /extracted-rc.cpp )
endif ( )