@ -6,7 +6,13 @@
#
#
# T h i s f i l e c o n t a i n s u t i l i t y w r a p p e r s f o r d e a l i n g w i t h t h e G e m s s y s t e m .
# T h i s f i l e c o n t a i n s u t i l i t y w r a p p e r s f o r d e a l i n g w i t h t h e G e m s s y s t e m .
define_property ( TARGET PROPERTY LY_PROJECT_NAME
B R I E F _ D O C S " N a m e o f t h e p r o j e c t , t h i s t a r g e t c a n u s e e n a b l e d g e m s f r o m "
F U L L _ D O C S " I f s e t , t h e w h e n i t e r a t i n g o v e r t h e e n a b l e d g e m s i n l y _ e n a b l e d _ g e m s _ d e l a y e d
o n l y a p r o j e c t w i t h t h a t n a m e c a n h a v e i t ' s e n a b l e d g e m l i s t a d d e d a s a d e p e n d e n c y t o t h i s t a r g e t .
I f t h e _ _ N O P R O J E C T _ _ p l a c e h o l d e r i s a s s o c i a t e d w i t h a l i s t e n a b l e d g e m s , t h e n i t a p p l i e s t o t h i s t a r g e t r e g a r d l e s s o f t h i s p r o p e r t y v a l u e " )
# l y _ c r e a t e _ a l i a s
# g i v e n a n a l i a s t o c r e a t e , a n d a l i s t o f o n e o r m o r e t a r g e t s ,
@ -34,7 +40,8 @@ function(ly_create_alias)
# e a s y v e r s i o n - i f i t s j u s t o n e t a r g e t a n d i t e x i s t a t t h e t i m e o f t h i s c a l l ,
# w e c a n d i r e c t l y g e t t h e t a r g e t , a n d m a k e b o t h a l i a s e s ,
# t h e n a m e s p a c e d a n d n o n n a m e s p a c e d o n e , p o i n t a t i t .
# t h e n a m e s p a c e a n d n o n n a m e s p a c e o n e , p o i n t a t i t .
set ( create_interface_target TRUE )
list ( LENGTH ly_create_alias_TARGETS number_of_targets )
if ( number_of_targets EQUAL 1 )
if ( TARGET ${ ly_create_alias_TARGETS } )
@ -43,11 +50,7 @@ function(ly_create_alias)
if ( NOT TARGET ${ ly_create_alias_NAME } )
add_library ( ${ ly_create_alias_NAME } ALIAS ${ de_aliased_target_name } )
endif ( )
# S t o r e o f f t h e a r g u m e n t s n e e d e d u s e d l y _ c r e a t e _ a l i a s i n t o a D I R E C T O R Y p r o p e r t y
# T h i s w i l l b e u s e d t o r e - c r e a t e t h e c a l l s i n t h e g e n e r a t e d C M a k e L i s t s . t x t i n t h e I N S T A L L s t e p
string ( REPLACE ";" " " create_alias_args "${ly_create_alias_NAME},${ly_create_alias_NAMESPACE},${ly_create_alias_TARGETS}" )
set_property ( DIRECTORY APPEND PROPERTY LY_CREATE_ALIAS_ARGUMENTS "${ly_create_alias_NAME},${ly_create_alias_NAMESPACE},${ly_create_alias_TARGETS}" )
return ( )
set ( create_interface_target FALSE )
endif ( )
endif ( )
@ -55,41 +58,48 @@ function(ly_create_alias)
# T o a c t u a l l y a c h i e v e t h i s w e h a v e t o c r e a t e a n i n t e r f a c e l i b r a r y w i t h t h o s e d e p e n d e n c i e s ,
# t h e n w e h a v e t o c r e a t e a n a l i a s t o t h a t t a r g e t .
# B y c o n v e n t i o n w e c r e a t e o n e w i t h o u t a n a m e s p a c e t h e n a l i a s t h e n a m e s p a c e d o n e .
if ( create_interface_target )
if ( TARGET ${ ly_create_alias_NAME } )
message ( FATAL_ERROR "Internal alias target already exists, cannot create an alias for it: ${ly_create_alias_NAME}\n"
" T h i s c o u l d b e a c o p y - p a s t e e r r o r , w h e r e s o m e p a r t o f t h e l y _ c r e a t e _ a l i a s c a l l w a s c h a n g e d b u t t h e o t h e r " )
endif ( )
if ( TARGET ${ ly_create_alias_NAME } )
message ( FATAL_ERROR "Internal alias target already exists, cannot create an alias for it: ${ly_create_alias_NAME}\n"
" T h i s c o u l d b e a c o p y - p a s t e e r r o r , w h e r e s o m e p a r t o f t h e l y _ c r e a t e _ a l i a s c a l l w a s c h a n g e d b u t t h e o t h e r " )
endif ( )
add_library ( ${ ly_create_alias_NAME } INTERFACE IMPORTED GLOBAL )
set_target_properties ( ${ ly_create_alias_NAME } PROPERTIES GEM_MODULE TRUE )
add_library ( ${ ly_create_alias_NAME } INTERFACE IMPORTED GLOBAL )
set_target_properties ( ${ ly_create_alias_NAME } PROPERTIES GEM_MODULE TRUE )
foreach ( target_name ${ ly_create_alias_TARGETS } )
if ( TARGET ${ target_name } )
ly_de_alias_target ( ${ target_name } de_aliased_target_name )
if ( NOT de_aliased_target_name )
message ( FATAL_ERROR "Target not found in ly_create_alias call: ${target_name} - check your spelling of the target name" )
foreach ( target_name ${ ly_create_alias_TARGETS } )
if ( TARGET ${ target_name } )
ly_de_alias_target ( ${ target_name } de_aliased_target_name )
if ( NOT de_aliased_target_name )
message ( FATAL_ERROR "Target not found in ly_create_alias call: ${target_name} - check your spelling of the target name" )
endif ( )
else ( )
set ( de_aliased_target_name ${ target_name } )
endif ( )
else ( )
set ( de_aliased_target_name ${ target_name } )
endif ( )
list ( APPEND final_targets ${ de_aliased_target_name } )
endforeach ( )
list ( APPEND final_targets ${ de_aliased_target_name } )
endforeach ( )
# a d d _ d e p e n d e n c i e s m u s t b e c a l l e d w i t h a t l e a s t o n e d e p e n d e n t t a r g e t
if ( final_targets )
ly_parse_third_party_dependencies ( "${final_targets}" )
ly_add_dependencies ( ${ ly_create_alias_NAME } ${ final_targets } )
endif ( )
# a d d _ d e p e n d e n c i e s m u s t b e c a l l e d w i t h a t l e a s t o n e d e p e n d e n t t a r g e t
if ( final_targets )
ly_parse_third_party_dependencies ( "${final_targets}" )
ly_add_dependencies ( ${ ly_create_alias_NAME } ${ final_targets } )
endif ( )
# n o w a d d t h e f i n a l a l i a s :
add_library ( ${ ly_create_alias_NAMESPACE } :: ${ ly_create_alias_NAME } ALIAS ${ ly_create_alias_NAME } )
# n o w a d d t h e f i n a l a l i a s :
add_library ( ${ ly_create_alias_NAMESPACE } :: ${ ly_create_alias_NAME } ALIAS ${ ly_create_alias_NAME } )
endif ( )
# S t o r e o f f t h e a r g u m e n t s u s e d b y l y _ c r e a t e _ a l i a s i n t o a D I R E C T O R Y p r o p e r t y
# T h i s w i l l b e u s e d t o r e - c r e a t e t h e c a l l s i n t h e g e n e r a t e d C M a k e L i s t s . t x t i n t h e I N S T A L L s t e p
# R e p l a c e t h e C M a k e l i s t s e p a r a t o r w i t h a s p a c e t o r e p l i c a t e t h e s p a c e s e p a r a t e d T A R G E T S a r g u m e n t s
string ( REPLACE ";" " " create_alias_args "${ly_create_alias_NAME},${ly_create_alias_NAMESPACE},${ly_create_alias_TARGETS}" )
# R e p l a c e t h e C M a k e l i s t s e p a r a t o r w i t h a s p a c e t o r e p l i c a t e t h e s p a c e s e p a r a t e d a r g u m e n t s
# A s i n g l e c r e a t e _ a l i a s _ a r g s v a r i a b l e e n c o d e s t w o v a l u e s . T h e a l i a s N A M E u s e d t o c h e c k i f t h e t a r g e t e x i s t s
# a n d t h e l y _ c r e a t e _ a l i a s a r g u m e n t s t o r e p l a c e t h i s f u n c t i o n c a l l
unset ( create_alias_args )
list ( APPEND create_alias_args "${ly_create_alias_NAME},"
N A M E $ { l y _ c r e a t e _ a l i a s _ N A M E }
N A M E S P A C E $ { l y _ c r e a t e _ a l i a s _ N A M E S P A C E }
T A R G E T S $ { l y _ c r e a t e _ a l i a s _ T A R G E T S } )
list ( JOIN create_alias_args " " create_alias_args )
set_property ( DIRECTORY APPEND PROPERTY LY_CREATE_ALIAS_ARGUMENTS "${create_alias_args}" )
# S t o r e t h e d i r e c t o r y p a t h i n t h e G L O B A L p r o p e r t y s o t h a t i t c a n b e a c c e s s e d
@ -100,13 +110,54 @@ function(ly_create_alias)
endif ( )
endfunction ( )
# l y _ s e t _ g e m _ v a r i a n t _ t o _ l o a d
# A s s o c i a t e s a k e y , v a l u e e n t r y o f C M a k e t a r g e t - > G e m v a r i a n t
# \ a r g : T A R G E T S - l i s t o f T a r g e t s t o a s s o c i a t e w i t h t h e G e m v a r i a n t
# \ a r g : V A R I A N T S - G e m v a r i a n t
function ( ly_set_gem_variant_to_load )
set ( options )
set ( oneValueArgs )
set ( multiValueArgs TARGETS VARIANTS )
cmake_parse_arguments ( ly_set_gem_variant_to_load "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ ARGN } )
if ( NOT ly_set_gem_variant_to_load_TARGETS )
message ( FATAL_ERROR "You must provide at least 1 target to ${CMAKE_CURRENT_FUNCTION} using the TARGETS keyword" )
endif ( )
# S t o r e a l i s t o f t a r g e t s
foreach ( target_name ${ ly_set_gem_variant_to_load_TARGETS } )
# A p p e n d t h e t a r g e t t o t h e l i s t o f t a r g e t s w i t h v a r i a n t s i f i t h a s n o t b e e n a d d e d
get_property ( ly_targets_with_variants GLOBAL PROPERTY LY_TARGETS_WITH_GEM_VARIANTS )
if ( NOT target_name IN_LIST ly_targets_with_variants )
set_property ( GLOBAL APPEND PROPERTY LY_TARGETS_WITH_GEM_VARIANTS "${target_name}" )
endif ( )
foreach ( variant_name ${ ly_set_gem_variant_to_load_VARIANTS } )
get_property ( target_gem_variants GLOBAL PROPERTY LY_GEM_VARIANTS_ "${target_name}" )
if ( NOT variant_name IN_LIST target_gem_variants )
set_property ( GLOBAL APPEND PROPERTY LY_GEM_VARIANTS_ "${target_name}" "${variant_name}" )
endif ( )
endforeach ( )
endforeach ( )
# S t o r e o f t h e a r g u m e n t s u s e d t o i n v o k e t h i s f u n c t i o n i n o r d e r t o r e p l i c a t e t h e c a l l i n t h e g e n e r a t e d C M a k e L i s t s . t x t
# i n t h e i n s t a l l l a y o u t
unset ( set_gem_variant_args )
list ( APPEND set_gem_variant_args
T A R G E T S $ { l y _ s e t _ g e m _ v a r i a n t _ t o _ l o a d _ T A R G E T S }
V A R I A N T S $ { l y _ s e t _ g e m _ v a r i a n t _ t o _ l o a d _ V A R I A N T S } )
# R e p l a c e t h e l i s t s e p a r a t o r w i t h s p a c e t o h a v e i t b e s t o r e d a s a s i n g l e p r o p e r t y e l e m e n t
list ( JOIN set_gem_variant_args " " set_gem_variant_args )
set_property ( DIRECTORY APPEND PROPERTY LY_SET_GEM_VARIANT_TO_LOAD_ARGUMENTS "${set_gem_variant_args}" )
endfunction ( )
# l y _ e n a b l e _ g e m s
# t h i s f u n c t i o n m a k e s s u r e t h a t t h e g i v e n g e m s , o r g e m s l i s t e d i n t h e v a r i a b l e E N A B L E D _ G E M S
# i n t h e G E M _ F I L E n a m e , a r e s e t a s r u n t i m e dependencies ( and thus loaded ) f o r t h e g i v e n t a r g e t s
# i n t h e c o n t e x t o f t h e g i v e n p r o j e c t .
# n o t e t h a t i t c a n ' t d o t h i s i m m e d i a t e l y , s o i t s a v e s t h e d a t a f o r l a t e r p r o c e s s i n g .
# N o t e : I f y o u d o n ' t s u p p l y a p r o j e c t n a m e , i t w i l l a p p l y i t a c r o s s t h e b o a r d t o a l l p r o j e c t s .
# t h i s i s u s e f u l i n t h e c a s e o f " l y _ a d d _ g e m s b e i n g c a l l e d f o r s o c a l l e d ' m a n d a t o r y g e m s ' i n s i d e t h e e n g i n e .
# t h i s i s u s e f u l i n t h e c a s e o f " l y _ en a b l e _ g e m s " b e i n g c a l l e d f o r s o c a l l e d ' m a n d a t o r y g e m s ' i n s i d e t h e e n g i n e .
# i f y o u s p e c i f y a g e m n a m e w i t h a n a m e s p a c e , i t w i l l b e u s e d , o t h e r w i s e i t w i l l a s s u m e G e m : :
function ( ly_enable_gems )
set ( options )
@ -115,23 +166,21 @@ function(ly_enable_gems)
cmake_parse_arguments ( ly_enable_gems "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ ARGN } )
if ( NOT ly_enable_gems_TARGETS )
message ( FATAL_ERROR "You must provide the targets to add gems to using the TARGETS keyword" )
endif ( )
if ( NOT ly_enable_gems_PROJECT_NAME )
message ( VERBOSE "Note: ly_enable_gems called with no PROJECT_NAME name, applying to all projects: \n"
" - V A R I A N T S $ { l y _ e n a b l e _ g e m s _ V A R I A N T S } \ n "
" - G E M S $ { l y _ e n a b l e _ g e m s _ G E M S } \ n "
" - T A R G E T S $ { l y _ e n a b l e _ g e m s _ T A R G E T S } \ n "
" - G E M S $ { l y _ e n a b l e _ g e m s _ G E M S } \ n "
" - G E M _ F I L E $ { l y _ e n a b l e _ g e m s _ G E M _ F I L E } " )
set ( ly_enable_gems_PROJECT_NAME "__NOPROJECT__" ) # s o t h a t t h e t o k e n i s n o t b l a n k
endif ( )
if ( NOT ly_enable_gems_VARIANTS )
message ( FATAL_ERROR "You must provide at least 1 variant of the gem modules (Editor, Server, Client, Builder) to "
" a d d t o y o u r t a r g e t s , u s i n g t h e V A R I A N T S k e y w o r d " )
# B a c k w a r d s - C o m p a t i b i l i t y - D e l e g a t e a n y T A R G E T S a n d V A R I A N T S a r g u m e n t s t o t h e l y _ s e t _ g e m _ v a r i a n t _ t o _ l o a d
# c o m m a n d . T h a t c o m m a n d i s u s e d t o a s s o c i a t e T A R G E T S w i t h t h e l i s t o f G e m V a r i a n t s t h e y d e s i r e t o u s e
if ( ly_enable_gems_TARGETS AND ly_enable_gems_VARIANTS )
message ( DEPRECATION "The TARGETS and VARIANTS arguments to \" ${ CMAKE_CURRENT_FUNCTION } \" is deprecated.\n "
" P l e a s e u s e t h e \ " l y _ s e t _ g e m _ v a r i a n t _ t o _ l o a d \ " f u n c t i o n d i r e c t l y t o a s s o c i a t e a T a r g e t w i t h a G e m V a r i a n t . \ n "
" T h i s f u n c t i o n w i l l f o r w a r d t h e T A R G E T S a n d V A R I A N T S a r g u m e n t s t o \ " l y _ s e t _ g e m _ v a r i a n t _ t o _ l o a d \ " f o r n o w , "
" b u t t h i s f u n c t i o n a l i t y w i l l b e r e m o v e d . " )
ly_set_gem_variant_to_load ( TARGETS ${ ly_enable_gems_TARGETS } VARIANTS ${ ly_enable_gems_VARIANTS } )
endif ( )
if ( ( NOT ly_enable_gems_GEMS AND NOT ly_enable_gems_GEM_FILE ) OR ( ly_enable_gems_GEMS AND ly_enable_gems_GEM_FILE ) )
@ -153,103 +202,126 @@ function(ly_enable_gems)
endif ( )
# a l l t h e a c t u a l w o r k h a s t o b e d o n e l a t e r .
foreach ( target_name ${ ly_enable_gems_TARGETS } )
foreach ( variant_name ${ ly_enable_gems_VARIANTS } )
set_property ( GLOBAL APPEND PROPERTY LY_DELAYED_ENABLE_GEMS "${ly_enable_gems_PROJECT_NAME},${target_name},${variant_name}" )
define_property ( GLOBAL PROPERTY LY_DELAYED_ENABLE_GEMS_ "${ly_enable_gems_PROJECT_NAME},${target_name},${variant_name}"
B R I E F _ D O C S " L i s t o f g e m n a m e s t o e v a l u a t e v a r i a n t s a g a i n s t " F U L L _ D O C S " N a m e s o f g e m s t h a t w i l l b e p a i r e d w i t h t h e v a r i a n t n a m e
t o d e t e r m i n e i f i t i s v a l i d t a r g e t t h a t s h o u l d b e a d d e d a s a n a p p l i c a t i o n d y n a m i c l o a d d e p e n d e n c y " )
set_property ( GLOBAL APPEND PROPERTY LY_DELAYED_ENABLE_GEMS_ "${ly_enable_gems_PROJECT_NAME},${target_name},${variant_name}" ${ ly_enable_gems_GEMS } )
endforeach ( )
endforeach ( )
set_property ( GLOBAL APPEND PROPERTY LY_DELAYED_ENABLE_GEMS "${ly_enable_gems_PROJECT_NAME}" )
define_property ( GLOBAL PROPERTY LY_DELAYED_ENABLE_GEMS_ "${ly_enable_gems_PROJECT_NAME}"
B R I E F _ D O C S " L i s t o f g e m n a m e s t o e v a l u a t e v a r i a n t s a g a i n s t " F U L L _ D O C S " N a m e s o f g e m s t h a t w i l l b e p a i r e d w i t h t h e v a r i a n t n a m e
t o d e t e r m i n e i f i t i s v a l i d t a r g e t t h a t s h o u l d b e a d d e d a s a n a p p l i c a t i o n d y n a m i c l o a d d e p e n d e n c y " )
set_property ( GLOBAL APPEND PROPERTY LY_DELAYED_ENABLE_GEMS_ "${ly_enable_gems_PROJECT_NAME}" ${ ly_enable_gems_GEMS } )
# S t o r e o f f t h e a r g u m e n t s u s e d b y l y _ e n a b l e _ g e m s i n t o a D I R E C T O R Y p r o p e r t y
# T h i s w i l l b e u s e d t o r e - c r e a t e t h e l y _ e n a b l e _ g e m s c a l l i n t h e g e n e r a t e d C M a k e L i s t s . t x t a t t h e I N S T A L L s t e p
# R e p l a c e t h e C M a k e l i s t s e p a r a t o r w i t h a s p a c e t o r e p l i c a t e t h e s p a c e s e p a r a t e d T A R G E T S a r g u m e n t s
if ( NOT ly_enable_gems_PROJECT_NAME STREQUAL "__NOPROJECT__" )
set ( replicated_project_name ${ ly_enable_gems_PROJECT_NAME } )
set ( replicated_project_name PROJECT_NAME ${ ly_enable_gems_PROJECT_NAME } )
endif ( )
# T h e G E M _ F I L E f i l e i s u s e d t o p o p u l a t e t h e G E M S a r g u m e n t v i a t h e E N A B L E D _ G E M S v a r i a b l e i n t h e f i l e .
# F u r t h e r m o r e t h e G E M _ F I L E i t s e l f i s n o t c o p i e d o v e r t o t h e i n s t a l l l a y o u t , s o m a k e i t s a r g u m e n t e n t r y b l a n k a n d u s e t h e l i s t o f G E M S
# s t o r e d i n l y _ e n a b l e _ g e m s _ G E M S
string ( REPLACE ";" " " enable_gems_args "${replicated_project_name},${ly_enable_gems_GEMS},,${ly_enable_gems_VARIANTS},${ly_enable_gems_TARGETS}" )
unset ( enable_gems_args )
list ( APPEND enable_gems_args
$ { r e p l i c a t e d _ p r o j e c t _ n a m e }
G E M S $ { l y _ e n a b l e _ g e m s _ G E M S } )
list ( JOIN enable_gems_args " " enable_gems_args )
set_property ( DIRECTORY APPEND PROPERTY LY_ENABLE_GEMS_ARGUMENTS "${enable_gems_args}" )
endfunction ( )
# c a l l t h i s b e f o r e r u n t i m e d e p e n d e n c i e s a r e u s e d t o a d d a n y r e l e v a n t t a r g e t s
# s a v e d b y t h e a b o v e f u n c t i o n
function ( ly_enable_gems_delayed )
get_property ( ly_delayed_enable_gems GLOBAL PROPERTY LY_DELAYED_ENABLE_GEMS )
foreach ( project_target_variant ${ ly_delayed_enable_gems } )
# w e e x p e c t a c o l o n s e p a r a t e d l i s t o f
# P R O J E C T _ N A M E , t a r g e t _ n a m e , v a r i a n t _ n a m e
string ( REPLACE "," ";" project_target_variant_list "${project_target_variant}" )
list ( LENGTH project_target_variant_list project_target_variant_length )
if ( project_target_variant_length EQUAL 0 )
continue ( )
endif ( )
if ( NOT project_target_variant_length EQUAL 3 )
message ( FATAL_ERROR "Invalid specification of gems, expected 'project','target','variant' and got ${project_target_variant}" )
endif ( )
list ( POP_BACK project_target_variant_list variant )
list ( POP_BACK project_target_variant_list target )
list ( POP_BACK project_target_variant_list project )
get_property ( gem_dependencies GLOBAL PROPERTY LY_DELAYED_ENABLE_GEMS_ "${project_target_variant}" )
if ( NOT gem_dependencies )
get_property ( gem_dependencies_defined GLOBAL PROPERTY LY_DELAYED_ENABLE_GEMS_ "${project_target_variant}" DEFINED )
if ( gem_dependencies_defined )
# s p e c i a l c a s e , i f t h e L Y _ D E L A Y E D _ E N A B L E _ G E M S _ " $ { p r o j e c t _ t a r g e t _ v a r i a n t } " p r o p e r t y i s D E F I N E D
# b u t e m p t y , a d d a n e n t r y t o t h e L Y _ D E L A Y E D _ L O A D _ D E P E N D E N C I E S t o h a v e t h e
# c m a k e _ d e p e n d e n c i e s . * . s e t r e g f i l e f o r the ( project, target ) t u p l e t o b e r e g e n e r a t e d
# T h i s i s n e e d e d i f t h e E N A B L E D _ G E M S l i s t f o r a p r o j e c t g o e s f r o m > 0 t o 0 . I n t h i s c a s e
# t h e c m a k e _ d e p e n d e n c i e s w o u l d h a v e a s t a l e l i s t o f g e m s t o l o a d u n l e s s i t i s r e g e n e r a t e d
get_property ( delayed_load_target_set GLOBAL PROPERTY LY_DELAYED_LOAD_ "${project},${target}" SET )
if ( NOT delayed_load_target_set )
set_property ( GLOBAL APPEND PROPERTY LY_DELAYED_LOAD_DEPENDENCIES "${project},${target}" )
set_property ( GLOBAL APPEND PROPERTY LY_DELAYED_LOAD_ "${project},${target}" "" )
endif ( )
endif ( )
# C o n t i n u e t o t h e n e x t i t e r a t i o n l o o p r e g a r d l e s s a s t h e r e a r e n o g e m d e p e n d e n c i e s
continue ( )
endif ( )
function ( ly_add_gem_dependencies_to_project_variants )
set ( options )
set ( oneValueArgs PROJECT_NAME TARGET VARIANT )
set ( multiValueArgs GEM_DEPENDENCIES )
cmake_parse_arguments ( ly_add_gem_dependencies "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ ARGN } )
if ( NOT ly_add_gem_dependencies_PROJECT_NAME )
message ( FATAL_ERROR "Missing required PROJECT_NAME argument which is used to determine gem load prefix" )
endif ( )
if ( NOT ly_add_gem_dependencies_TARGET )
message ( FATAL_ERROR "Missing required TARGET argument " )
endif ( )
if ( NOT ly_add_gem_dependencies_VARIANT )
message ( FATAL_ERROR "Missing required gem VARIANT argument needed to determine which gem variants to load for the target" )
endif ( )
if ( ${ project } STREQUAL "__NOPROJECT__" )
# s p e c i a l c a s e , a p p l y t o a l l
unset ( PREFIX_CLAUSE )
else ( )
set ( PREFIX_CLAUSE "PREFIX;${project}" )
if ( ${ ly_add_gem_dependencies_PROJECT_NAME } STREQUAL "__NOPROJECT__" )
# s p e c i a l c a s e , a p p l y t o a l l
unset ( PREFIX_CLAUSE )
else ( )
set ( PREFIX_CLAUSE "PREFIX;${ly_add_gem_dependencies_PROJECT_NAME}" )
endif ( )
# a p p l y t h e l i s t o f g e m t a r g e t s . A d d i n g a g e m r e a l l y j u s t m e a n s a d d i n g t h e a p p r o p r i a t e d e p e n d e n c y .
foreach ( gem_name ${ ly_add_gem_dependencies_GEM_DEPENDENCIES } )
set ( gem_target ${ gem_name } . ${ ly_add_gem_dependencies_VARIANT } )
# i f t h e t a r g e t e x i s t s , a d d i t .
if ( TARGET ${ gem_target } )
# D e a l i a s a c t u a l t a r g e t
ly_de_alias_target ( ${ gem_target } dealiased_gem_target )
ly_add_target_dependencies (
$ { P R E F I X _ C L A U S E }
T A R G E T S $ { l y _ a d d _ g e m _ d e p e n d e n c i e s _ T A R G E T }
D E P E N D E N T _ T A R G E T S $ { d e a l i a s e d _ g e m _ t a r g e t } )
endif ( )
endforeach ( )
endfunction ( )
# c a l l t h i s b e f o r e r u n t i m e d e p e n d e n c i e s a r e u s e d t o a d d a n y r e l e v a n t t a r g e t s
# s a v e d b y t h e a b o v e f u n c t i o n
function ( ly_enable_gems_delayed )
# Q u e r y t h e l i s t o f t a r g e t s t h a t a r e a s s o c i a t e d w i t h a g e m v a r i a n t
get_property ( targets_with_variants GLOBAL PROPERTY LY_TARGETS_WITH_GEM_VARIANTS )
# Q u e r y t h e p r o j e c t s t h a t h a v e m a d e c a l l s t o l y _ e n a b l e _ g e m s
get_property ( enable_gem_projects GLOBAL PROPERTY LY_DELAYED_ENABLE_GEMS )
foreach ( target ${ targets_with_variants } )
if ( NOT TARGET ${ target } )
message ( FATAL_ERROR "ly_enable_gems specified TARGET '${target}' but no such target was found." )
message ( FATAL_ERROR "ly_ set_gem_variant_to_load specified TARGET '${target}' but no such target was found.")
endif ( )
# a p p l y t h e l i s t o f g e m t a r g e t s . A d d i n g a g e m r e a l l y j u s t m e a n s a d d i n g t h e a p p r o p r i a t e d e p e n d e n c y .
foreach ( gem_name ${ gem_dependencies } )
# t h e g e m n a m e m a y a l r e a d y h a v e a n a m e s p a c e . I f i t d o e s , w e u s e t h a t o n e
ly_strip_target_namespace ( TARGET ${ gem_name } OUTPUT_VARIABLE unaliased_gem_name )
if ( ${ unaliased_gem_name } STREQUAL ${ gem_name } )
# i f s t r i p p i n g a n a m e s p a c e h a d n o e f f e c t , i t h a d n o n a m e s p a c e
# a n d w e s u p p l y t h e d e f a u l t G e m : : n a m e s p a c e .
set ( gem_name_with_namespace Gem:: ${ gem_name } )
else ( )
# if s t r i p p i n g t h e n a m e s p a c e h a d a n e f f e c t t h e n w e u s e t h e o r i g i n a l
# wi t h t h e n a m e s p a c e , i n s t e a d o f a s s u m i n g G e m : :
set( gem_name_with_namespace ${ gem_name } )
# Lo o k u p i f t h e t a r g e t i s s c o p e d t o a p r o j e c t
# I n t h a t c a s e t h e t a r g e t c a n o n l y u s e g e m t a r g e t s t h a t i s
# - n o t p r o j e c t s p e c i f i c : i . e " _ _ N O P R O J E C T _ _ "
# - o r s p e c i f i c t o t h e < L Y _ P R O J E C T _ N A M E > p r o j e c t
get_property ( target_project_association TARGET ${ target } PROPERTY LY_PROJECT_NAME )
foreach ( project ${ enable_gem_projects } )
if ( target_project_association AND
( NOT ( project STREQUAL "__NOPROJECT__" ) A N D NOT ( project STREQUAL target_project_association ) ) )
# Sk i p a d d i n g t h e g e m d e p e n d e n c i e s t o t h i s t a r g e t i f i t i s a s s o c i a t e d w i t h a p r o j e c t
# an d t h e c u r r e n t p r o j e c t d o e s n ' t m a t c h
continue( )
endif ( )
# i f t h e t a r g e t e x i s t s , a d d i t .
if ( TARGET ${ gem_name_with_namespace } . ${ variant } )
ly_add_target_dependencies (
$ { P R E F I X _ C L A U S E }
T A R G E T S $ { t a r g e t }
D E P E N D E N T _ T A R G E T S $ { g e m _ n a m e _ w i t h _ n a m e s p a c e } . $ { v a r i a n t }
)
get_property ( gem_dependencies GLOBAL PROPERTY LY_DELAYED_ENABLE_GEMS_ "${project}" )
if ( NOT gem_dependencies )
get_property ( gem_dependencies_defined GLOBAL PROPERTY LY_DELAYED_ENABLE_GEMS_ "${project}" DEFINED )
if ( gem_dependencies_defined )
# s p e c i a l c a s e , i f t h e L Y _ D E L A Y E D _ E N A B L E _ G E M S _ " $ { p r o j e c t _ t a r g e t _ v a r i a n t } " p r o p e r t y i s D E F I N E D
# b u t e m p t y , a d d a n e n t r y t o t h e L Y _ D E L A Y E D _ L O A D _ D E P E N D E N C I E S t o h a v e t h e
# c m a k e _ d e p e n d e n c i e s . * . s e t r e g f i l e f o r the ( project, target ) t u p l e t o b e r e g e n e r a t e d
# T h i s i s n e e d e d i f t h e E N A B L E D _ G E M S l i s t f o r a p r o j e c t g o e s f r o m > 0 t o 0 . I n t h i s c a s e
# t h e c m a k e _ d e p e n d e n c i e s w o u l d h a v e a s t a l e l i s t o f g e m s t o l o a d u n l e s s i t i s r e g e n e r a t e d
get_property ( delayed_load_target_set GLOBAL PROPERTY LY_DELAYED_LOAD_ "${project},${target}" SET )
if ( NOT delayed_load_target_set )
set_property ( GLOBAL APPEND PROPERTY LY_DELAYED_LOAD_DEPENDENCIES "${project},${target}" )
set_property ( GLOBAL APPEND PROPERTY LY_DELAYED_LOAD_ "${project},${target}" "" )
endif ( )
endif ( )
# C o n t i n u e t o t h e n e x t i t e r a t i o n l o o p r e g a r d l e s s a s t h e r e a r e n o g e m d e p e n d e n c i e s
continue ( )
endif ( )
# G a t h e r t h e G e m v a r i a n t s a s s o c i a t e d w i t h t h i s t a r g e t a n d i t e r a t e o v e r t h e m t o c o m b i n e t h e m w i t h t h e e n a b l e d
# g e m s f o r t h e e a c h p r o j e c t
get_property ( target_gem_variants GLOBAL PROPERTY LY_GEM_VARIANTS_ "${target}" )
foreach ( variant ${ target_gem_variants } )
ly_add_gem_dependencies_to_project_variants (
P R O J E C T _ N A M E $ { p r o j e c t }
T A R G E T $ { t a r g e t }
V A R I A N T $ { v a r i a n t }
G E M _ D E P E N D E N C I E S $ { g e m _ d e p e n d e n c i e s } )
endforeach ( )
endforeach ( )
endforeach ( )
endfunction ( )