|
1 | | -{%- set packages = [] -%} |
2 | | -{%- if (target.packages is defined) and (target.packages|length) -%} |
3 | | -{%- set packages = packages + target.packages -%} |
4 | | -{%- endif -%} |
5 | | -{%- if (target.mpackages is defined) and (target.mpackages|length) -%} |
6 | | -{%- if packages|length -%} |
7 | | -{#- Skip duplicating packages -#} |
8 | | -{%- set mpackages = target.mpackages|rejectattr('name', 'in', packages|map(attribute='name')) -%} |
9 | | -{%- if mpackages|length -%} |
10 | | -{%- set packages = packages + mpackages -%} |
11 | | -{%- endif -%} |
12 | | -{%- else -%} |
13 | | -{%- set packages = packages + target.mpackages -%} |
14 | | -{%- endif -%} |
15 | | -{%- endif -%} |
16 | | -{%- if packages|length -%} |
17 | | -{%- for package in packages -%} |
| 1 | +{%- macro RenderPackages(target) -%} |
| 2 | +{%- set packages = [] -%} |
| 3 | +{%- if (target.packages is defined) and (target.packages|length) -%} |
| 4 | +{%- set packages = packages + target.packages -%} |
| 5 | +{%- endif -%} |
| 6 | +{%- if (target.mpackages is defined) and (target.mpackages|length) -%} |
| 7 | +{%- if packages|length -%} |
| 8 | +{#- Skip duplicating packages -#} |
| 9 | +{%- set mpackages = target.mpackages|rejectattr('name', 'in', packages|map(attribute='name')) -%} |
| 10 | +{%- if mpackages|length -%} |
| 11 | +{%- set packages = packages + mpackages -%} |
| 12 | +{%- endif -%} |
| 13 | +{%- else -%} |
| 14 | +{%- set packages = packages + target.mpackages -%} |
| 15 | +{%- endif -%} |
| 16 | +{%- endif -%} |
| 17 | +{%- if packages|length -%} |
| 18 | +{%- for package in packages -%} |
18 | 19 | find_package({{ package.name }} REQUIRED |
19 | | -{%- if package.components|length %} COMPONENTS |
20 | | -{%- for component in package.components %} |
| 20 | +{%- if package.components|length %} COMPONENTS |
| 21 | +{%- for component in package.components %} |
21 | 22 | {{ component }} |
22 | | -{% endfor -%} |
23 | | -{%- endif -%} |
| 23 | +{% endfor -%} |
| 24 | +{%- endif -%} |
24 | 25 | ) |
25 | | -{% endfor -%} |
| 26 | +{% endfor -%} |
| 27 | +{%- endif -%} |
| 28 | +{%- endmacro -%} |
| 29 | + |
| 30 | +{%- if target is defined -%} |
| 31 | +{{ RenderPackages(target) }} |
| 32 | +{%- endif -%} |
| 33 | +{%- if extra_targets is defined -%} |
| 34 | +{%- for extra_target in extra_targets -%} |
| 35 | +{{ RenderPackages(extra_target) }} |
| 36 | +{%- endfor -%} |
26 | 37 | {%- endif -%} |
0 commit comments