@ -1,21 +1,31 @@
include ( CMakeParseArguments )
include ( CMakeColors )
function ( calamares_add_branding_subdirectory )
set ( SUBDIRECTORY ${ ARGV0 } )
# U s a g e calamares_add_branding ( NAME <name> [SUBDIRECTORY <dir>] )
#
# A d d s a b r a n d i n g c o m p o n e n t t o t h e b u i l d :
# - t h e c o m p o n e n t ' s t o p - l e v e l f i l e s a r e c o p i e d i n t o t h e b u i l d - d i r ;
# C M a k e L i s t s . t x t i s e x c l u d e d f r o m t h e g l o b .
# - t h e c o m p o n e n t ' s t o p - l e v e l f i l e s a r e i n s t a l l e d i n t o t h e c o m p o n e n t b r a n d i n g d i r
#
# T h e b r a n d i n g c o m p o n e n t l i v e s i n < d i r > i f g i v e n , o t h e r w i s e t h e
# c u r r e n t s o u r c e d i r e c t o r y . T h e b r a n d i n g c o m p o n e n t i s i n s t a l l e d
# w i t h t h e g i v e n < n a m e > , w h i c h i s u s u a l l y t h e n a m e o f t h e
# d i r e c t o r y c o n t a i n i n g t h e c o m p o n e n t , a n d w h i c h m u s t m a t c h t h e
# * c o m p o n e n t N a m e * i n ` b r a n d i n g . d e s c ` .
function ( calamares_add_branding )
set ( _CABT_SUBDIRECTORY "." )
cmake_parse_arguments ( _CABT "" "NAME;SUBDIRECTORY" "" ${ ARGN } )
if ( NOT _CABT_NAME )
message ( FATAL_ERROR "Branding component must have a NAME" )
endif ( )
if ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/CMakeLists.txt" )
add_subdirectory ( $ SUBDIRECTORY )
message ( "-- ${BoldYellow}Found ${CALAMARES_APPLICATION_NAME} branding component: ${BoldRed}${SUBDIRECTORY}${ColorReset}" )
set ( NAME ${ _CABT_NAME } )
set ( SUBDIRECTORY ${ _CABT_SUBDIRECTORY } )
elseif ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/branding.desc" )
set ( BRANDING_DIR share/calamares/branding )
set ( BRANDING_COMPONENT_DESTINATION ${ BRANDING_DIR } / ${ SUBDIRECTORY } )
if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/lang" )
message ( "-- ${BoldYellow}Warning:${ColorReset} branding component ${BoldRed}${SUBDIRECTORY}${ColorReset} has a translations subdirectory but no CMakeLists.txt." )
message ( "" )
return ( )
endif ( )
set ( BRANDING_COMPONENT_DESTINATION ${ BRANDING_DIR } / ${ NAME } )
# W e g l o b a l l t h e f i l e s i n s i d e t h e s u b d i r e c t o r y , a n d w e m a k e s u r e t h e y a r e
# s y n c e d w i t h t h e b i n d i r s t r u c t u r e a n d i n s t a l l e d .
@ -29,15 +39,61 @@ function( calamares_add_branding_subdirectory )
endif ( )
endforeach ( )
message ( "-- ${BoldYellow}Found ${CALAMARES_APPLICATION_NAME} branding component: ${BoldRed}${ SUBDIRECTORY }${ColorReset}" )
message ( "-- ${BoldYellow}Found ${CALAMARES_APPLICATION_NAME} branding component: ${BoldRed}${ NAME }${ColorReset}" )
if ( NOT CMAKE_BUILD_TYPE STREQUAL "Release" )
message ( " ${Green}TYPE:${ColorReset} branding component" )
# message ( " ${Green}FILES:${ColorReset} ${BRANDING_COMPONENT_FILES}" )
message ( " ${Green}BRANDING_COMPONENT_DESTINATION:${ColorReset} ${BRANDING_COMPONENT_DESTINATION}" )
message ( "" )
endif ( )
endfunction ( )
# U s a g e calamares_add_branding_translations ( NAME <name> [SUBDIRECTORY <dir>] )
#
# A d d s t h e t r a n s l a t i o n s f o r a b r a n d i n g c o m p o n e n t t o t h e b u i l d :
# - t h e c o m p o n e n t ' s l a n g / d i r e c t o r y i s s c a n n e d f o r . t s f i l e s
# - t h e c o m p o n e n t ' s t r a n s l a t i o n s a r e i n s t a l l e d i n t o t h e c o m p o n e n t b r a n d i n g d i r
#
# T r a n s l a t i o n f i l e s m u s t b e c a l l e d c a l a m a r e s - < n a m e > _ < l a n g > . t s . O p t i o n a l l y
# t h e l a n g / d i r i s f o u n d i n t h e g i v e n < d i r > i n s t e a d o f t h e c u r r e n t s o u r c e
# d i r e c t o r y .
function ( calamares_add_branding_translations )
set ( _CABT_SUBDIRECTORY "." )
cmake_parse_arguments ( _CABT "" "NAME;SUBDIRECTORY" "" ${ ARGN } )
if ( NOT _CABT_NAME )
message ( FATAL_ERROR "Branding component must have a NAME" )
endif ( )
set ( NAME ${ _CABT_NAME } )
set ( SUBDIRECTORY ${ _CABT_SUBDIRECTORY } )
set ( BRANDING_DIR share/calamares/branding )
set ( BRANDING_COMPONENT_DESTINATION ${ BRANDING_DIR } / ${ NAME } )
file ( GLOB BRANDING_TRANSLATION_FILES RELATIVE ${ CMAKE_CURRENT_SOURCE_DIR } "${SUBDIRECTORY}/lang/calamares-${NAME}_*.ts" )
if ( BRANDING_TRANSLATION_FILES )
qt5_add_translation ( QM_FILES ${ BRANDING_TRANSLATION_FILES } )
add_custom_target ( branding-translation- ${ NAME } ALL DEPENDS ${ QM_FILES } )
install ( FILES ${ QM_FILES } DESTINATION ${ BRANDING_COMPONENT_DESTINATION } /lang/ )
list ( LENGTH BRANDING_TRANSLATION_FILES _branding_count )
message ( " ${Green}BRANDING_TRANSLATIONS:${ColorReset} ${_branding_count} language(s)" )
endif ( )
endfunction ( )
# U s a g e calamares_add_branding_subdirectory ( <dir> )
#
# A d d s a b r a n d i n g c o m p o n e n t f r o m a s u b d i r e c t o r y :
# - i f t h e r e i s a C M a k e L i s t s . t x t , u s e t h a t
# - o t h e r w i s e a s s u m e a " s t a n d a r d " s e t u p w i t h t o p - l e v e l f i l e s a n d a l a n g / d i r f o r t r a n s l a t i o n s
#
function ( calamares_add_branding_subdirectory SUBDIRECTORY )
if ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/CMakeLists.txt" )
add_subdirectory ( ${ SUBDIRECTORY } )
elseif ( EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/branding.desc" )
calamares_add_branding ( NAME ${ SUBDIRECTORY } SUBDIRECTORY ${ SUBDIRECTORY } )
if ( IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/${SUBDIRECTORY}/lang" )
calamares_add_branding_translations ( NAME ${ SUBDIRECTORY } SUBDIRECTORY ${ SUBDIRECTORY } )
endif ( )
else ( )
message ( "-- ${BoldYellow}Warning:${ColorReset} tried to add branding component subdirectory ${BoldRed}${SUBDIRECTORY}${ColorReset} which has no branding.desc." )
message ( "" )
endif ( )
message ( "" )
endfunction ( )