aboutsummaryrefslogtreecommitdiffstats
path: root/build/export_generators/cmake/dir_targets.jinja
blob: af7320e723cb65f71f76c1e891ff5e0e86344305 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
{%- macro MacrosesWithMergeArgs(target_name, list_of_dict, macro_suffix, macro_field, args_field) -%}
{%-     set macros = list_of_dict|map(attribute=macro_field)|unique -%}
{%-     for macro in macros -%}
{%-         set args = list_of_dict|selectattr(macro_field, 'eq', macro)|map(attribute=args_field)|sum -%}
{%-         if args|length %}
{{ macro }}({{ target_name }}{{ macro_suffix }}
{%-             for arg in args %}
  {{ arg }}
{%-             endfor %}
)
{%          endif %}
{%-     endfor -%}
{%- endmacro -%}

{%- macro Macroses(target_name, list_of_dict, macro_field, args_field, excludes) -%}
{%-     set macros = list_of_dict|map(attribute=macro_field)|unique -%}
{%-     for macro in macros -%}
{%-         if (excludes|length == 0) or not (macro in excludes) -%}
{%-             set merge_args = list_of_dict|selectattr(macro_field, 'eq', macro)|selectattr('merge_args') -%}
{%-             if merge_args|length %}
{{ MacrosesWithMergeArgs(target_name, list_of_dict|selectattr(macro_field, 'eq', macro), '', macro_field, args_field) }}
{%-             else -%}
{%-                 set macroses = list_of_dict|selectattr(macro_field, 'eq', macro) -%}
{%-                 for macros in macroses %}
{{ macros.macro }}({{ target_name }}{{ macro_suffix }}
{%-                 if macros.args|length %}
{%-                     for arg in macros.args %}
  {{ arg }}
{%-                     endfor %}
{%                  endif -%}
)
{%                  endfor -%}
{%-             endif -%}
{%-         endif -%}
{%-     endfor -%}
{%- endmacro -%}

{%- macro RenderTargetOptions(target_name, prefix, options, only_option, exclude_options) -%}
{%-     if only_option != "" -%}
{%-         set selected_options = options|selectattr('option', 'eq', only_option) -%}
{%-     elif exclude_options|length -%}
{%-         set selected_options = options|rejectattr('option', 'in', exclude_options) -%}
{%-     else -%}
{%-         set selected_options = options -%}
{%-     endif -%}
{%-     if selected_options|length -%}
{{ MacrosesWithMergeArgs(target_name, selected_options, prefix, 'option', 'args') }}
{%-     endif -%}
{%- endmacro -%}


{%- macro TargetOptions(target_name, is_really_fake_module, target_options, only_option, exclude_options) -%}
{%-     if (target_options.interfaces is defined) -%}
{{ RenderTargetOptions(target_name, ' INTERFACE', target_options.interfaces, only_option, exclude_options) }}
{%-     endif -%}

{%-     if (target_options.publics is defined) -%}
{%-         if is_really_fake_module -%}
{%-             set prefix = ' INTERFACE' -%}
{%-         else -%}
{%-             set prefix = ' PUBLIC' -%}
{%-         endif -%}
{{ RenderTargetOptions(target_name, prefix, target_options.publics, only_option, exclude_options) }}
{%-     endif -%}

{%-     if not(is_really_fake_module) and (target_options.privates is defined) -%}
{{ RenderTargetOptions(target_name, ' PRIVATE', target_options.privates, only_option, exclude_options) }}
{%-     endif -%}
{%- endmacro -%}

{%- if target is defined -%}
{%-     set current_target = target -%}
{%-     include '[generator]/target_cmake_lists.jinja' -%}
{%- endif -%}
{%- if extra_targets is defined -%}
{%-     for current_target in extra_targets -%}
{%-         include '[generator]/target_cmake_lists.jinja' -%}
{%-     endfor -%}
{%- endif -%}