dir_packages.jinja 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. {%- macro RenderPackages(target) -%}
  2. {%- set packages = [] -%}
  3. {%- if target.packages|length -%}
  4. {%- set packages = packages + target.packages -%}
  5. {%- endif -%}
  6. {%- if 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. {%- set runs_packages = target.custom_runs|selectattr('cmake_packages')|map(attribute='cmake_packages')|sum -%}
  18. {%- if runs_packages|length -%}
  19. {%- if packages|length -%}
  20. {#- Skip duplicating packages -#}
  21. {%- set runs_packages = runs_packages|rejectattr('name', 'in', packages|map(attribute='name')) -%}
  22. {%- if runs_packages|length -%}
  23. {%- set packages = packages + runs_packages -%}
  24. {%- endif -%}
  25. {%- else -%}
  26. {%- set packages = packages + runs_packages -%}
  27. {%- endif -%}
  28. {%- endif -%}
  29. {%- if packages|length -%}
  30. {%- set simple_packages = packages|rejectattr('components') -%}
  31. {%- set complex_packages = packages|selectattr('components') -%}
  32. {%- if simple_packages|length -%}
  33. {%- for package_name in simple_packages|map(attribute='name')|unique %}
  34. find_package({{ package_name }} REQUIRED)
  35. {% endfor -%}
  36. {%- endif -%}
  37. {%- if complex_packages|length -%}
  38. {%- for package in complex_packages %}
  39. find_package({{ package.name }} REQUIRED
  40. {%- if package.components|length %} COMPONENTS
  41. {%- for component in package.components %}
  42. {{ component }}
  43. {% endfor -%}
  44. {%- endif -%}
  45. )
  46. {% endfor -%}
  47. {%- endif -%}
  48. {%- endif -%}
  49. {%- endmacro -%}
  50. {%- if target is defined -%}
  51. {{ RenderPackages(target) }}
  52. {%- endif -%}
  53. {%- if extra_targets|length -%}
  54. {%- for extra_target in extra_targets -%}
  55. {{ RenderPackages(extra_target) }}
  56. {%- endfor -%}
  57. {%- endif -%}