target_links.jinja 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. {%- set interfaces = [] -%}
  2. {%- set publics = [] -%}
  3. {%- set privates = [] -%}
  4. {%- set allocators = [] -%}
  5. {%- set add_interfaces = current_target.link|map(attribute='interfaces')|sum -%}
  6. {%- if add_interfaces|length -%}
  7. {%- set interfaces = interfaces + add_interfaces -%}
  8. {%- endif -%}
  9. {%- if current_target.is_fake_module -%}
  10. {%- set add_interfaces = current_target.link|map(attribute='publics')|sum -%}
  11. {%- if add_interfaces|length -%}
  12. {%- set interfaces = interfaces + add_interfaces -%}
  13. {%- endif -%}
  14. {%- else -%}
  15. {%- set add_publics = current_target.link|map(attribute='publics')|sum -%}
  16. {%- if add_publics|length -%}
  17. {%- set publics = publics + add_publics -%}
  18. {%- endif -%}
  19. {%- if (current_target.macro == "add_global_library_for") and (target.link|length) -%}
  20. {%- set add_publics = target.link|map(attribute='publics')|sum -%}
  21. {%- if add_publics|length -%}
  22. {%- set publics = publics + add_publics -%}
  23. {%- endif -%}
  24. {%- endif -%}
  25. {%- set add_privates = current_target.link|map(attribute='privates')|sum -%}
  26. {%- if add_privates|length -%}
  27. {%- set privates = privates + add_privates -%}
  28. {%- endif -%}
  29. {%- endif -%}
  30. {%- if (current_target.allocators is defined) and (current_target.allocators|length) -%}
  31. {%- if (current_target.macro == "add_executable") or (current_target.macro == "add_library" and ("SHARED" in current_target.macro_args)) -%}
  32. {#- support allocators -#}
  33. {%- set allocators = allocators + current_target.allocators -%}
  34. {%- else -%}
  35. {#- not supported allocators -#}
  36. {%- if current_target.is_fake_module -%}
  37. {%- set interfaces = interfaces + current_target.allocators -%}
  38. {%- else -%}
  39. {%- set publics = publics + current_target.allocators -%}
  40. {%- endif -%}
  41. {%- endif -%}
  42. {%- endif -%}
  43. {%- if interfaces|length %}
  44. target_link_libraries({{ name }} INTERFACE
  45. {%- for interface in interfaces %}
  46. {{ interface }}
  47. {%- endfor %}
  48. )
  49. {% endif -%}
  50. {%- if publics|length %}
  51. target_link_libraries({{ name }} PUBLIC
  52. {%- for public in publics %}
  53. {{ public }}
  54. {%- endfor %}
  55. )
  56. {% endif -%}
  57. {%- if privates|length %}
  58. target_link_libraries({{ name }} PRIVATE
  59. {%- for private in privates %}
  60. {{ private }}
  61. {%- endfor %}
  62. )
  63. {% endif -%}
  64. {%- if allocators|length %}
  65. target_allocator({{ name }}
  66. {%- for allocator in allocators %}
  67. {{ allocator }}
  68. {%- endfor %}
  69. )
  70. {% endif -%}