dir_packages.jinja 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637
  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 %}
  19. find_package({{ package.name }} REQUIRED
  20. {%- if package.components|length %} COMPONENTS
  21. {%- for component in package.components %}
  22. {{ component }}
  23. {% endfor -%}
  24. {%- endif -%}
  25. )
  26. {% endfor -%}
  27. {%- endif -%}
  28. {%- endmacro -%}
  29. {%- if target is defined -%}
  30. {{ RenderPackages(target) }}
  31. {%- endif -%}
  32. {%- if extra_targets|length -%}
  33. {%- for extra_target in extra_targets -%}
  34. {{ RenderPackages(extra_target) }}
  35. {%- endfor -%}
  36. {%- endif -%}