target_links.jinja 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 is_really_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_shared_library") 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 is_really_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. {#- OpenSSL recipe under Conan2 uses another target name, patch it manually here, or else build fails -#}
  54. {%- if (use_conan2) and (public == "OpenSSL::OpenSSL") -%}
  55. {%- set public = "openssl::openssl" -%}
  56. {%- endif %}
  57. {{ public }}
  58. {%- endfor %}
  59. )
  60. {% endif -%}
  61. {%- if privates|length %}
  62. target_link_libraries({{ name }} PRIVATE
  63. {%- for private in privates %}
  64. {{ private }}
  65. {%- endfor %}
  66. )
  67. {% endif -%}
  68. {%- if allocators|length %}
  69. target_allocator({{ name }}
  70. {%- for allocator in allocators %}
  71. {{ allocator }}
  72. {%- endfor %}
  73. )
  74. {% endif -%}