aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordimdim11 <dimdim11@yandex-team.com>2024-07-29 07:38:40 +0300
committerdimdim11 <dimdim11@yandex-team.com>2024-07-29 07:46:38 +0300
commit70fc43d0c538a29abdec624f3d3fcc4c72d1fd75 (patch)
tree59162b648cbdc6164547828f75eff84cf677ffe5
parent4115783962ed3b60ab37be8a96a212b21ebdce75 (diff)
downloadydb-70fc43d0c538a29abdec624f3d3fcc4c72d1fd75.tar.gz
Support only headers libraries
Support only headers libraries 022101915700da1c2b8e381aaaa1f21ca5604b37
-rw-r--r--build/export_generators/cmake/dir_targets.jinja6
-rw-r--r--build/export_generators/cmake/target_cmake_lists.jinja50
-rw-r--r--build/export_generators/cmake/target_links.jinja4
-rw-r--r--build/export_generators/cmake/target_options.jinja6
4 files changed, 55 insertions, 11 deletions
diff --git a/build/export_generators/cmake/dir_targets.jinja b/build/export_generators/cmake/dir_targets.jinja
index be0e5fe0e5..af7320e723 100644
--- a/build/export_generators/cmake/dir_targets.jinja
+++ b/build/export_generators/cmake/dir_targets.jinja
@@ -49,13 +49,13 @@
{%- endmacro -%}
-{%- macro TargetOptions(target_name, is_fake_module, target_options, only_option, exclude_options) -%}
+{%- macro TargetOptions(target_name, is_really_fake_module, target_options, only_option, exclude_options) -%}
{%- if (target_options.interfaces is defined) -%}
{{ RenderTargetOptions(target_name, ' INTERFACE', target_options.interfaces, only_option, exclude_options) }}
{%- endif -%}
{%- if (target_options.publics is defined) -%}
-{%- if is_fake_module -%}
+{%- if is_really_fake_module -%}
{%- set prefix = ' INTERFACE' -%}
{%- else -%}
{%- set prefix = ' PUBLIC' -%}
@@ -63,7 +63,7 @@
{{ RenderTargetOptions(target_name, prefix, target_options.publics, only_option, exclude_options) }}
{%- endif -%}
-{%- if not(is_fake_module) and (target_options.privates is defined) -%}
+{%- if not(is_really_fake_module) and (target_options.privates is defined) -%}
{{ RenderTargetOptions(target_name, ' PRIVATE', target_options.privates, only_option, exclude_options) }}
{%- endif -%}
{%- endmacro -%}
diff --git a/build/export_generators/cmake/target_cmake_lists.jinja b/build/export_generators/cmake/target_cmake_lists.jinja
index a6b84bbcf4..dc28fbfd81 100644
--- a/build/export_generators/cmake/target_cmake_lists.jinja
+++ b/build/export_generators/cmake/target_cmake_lists.jinja
@@ -2,14 +2,58 @@
{%- set name = current_target.name -%}
{%- set macro_args = current_target.macro_args -%}
+{%- if macro == 'add_library' -%}
+{%- set only_headers_like_sources_library = true -%}
+{%- set target_sources = [] -%}
+{%- if current_target.target_options.interfaces is defined -%}
+{%- set interfaces_target_sources = current_target.target_options.interfaces|selectattr('option', 'eq', 'target_sources') -%}
+{%- if interfaces_target_sources|length -%}
+{%- set target_sources = target_sources + interfaces_target_sources|map(attribute='args')|sum -%}
+{%- endif -%}
+{%- endif -%}
+{%- if current_target.target_options.publics is defined -%}
+{%- set publics_target_sources = current_target.target_options.publics|selectattr('option', 'eq', 'target_sources') -%}
+{%- if publics_target_sources|length -%}
+{%- set target_sources = target_sources + publics_target_sources|map(attribute='args')|sum -%}
+{%- endif -%}
+{%- endif -%}
+{%- if current_target.target_options.privates is defined -%}
+{%- set privates_target_sources = current_target.target_options.privates|selectattr('option', 'eq', 'target_sources') -%}
+{%- if privates_target_sources|length -%}
+{%- set target_sources = target_sources + privates_target_sources|map(attribute='args')|sum -%}
+{%- endif -%}
+{%- endif -%}
+{%- if target_sources|length -%}
+{%- for target_source in target_sources -%}
+{%- if not (target_source.endswith('.h') or target_source.endswith('.hh') or target_source.endswith('.hpp') or target_source.endswith('.i') or target_source.endswith('.inc') or target_source.endswith('.inc.d')) -%}
+{#- Any non-header clear flag only_headers_like_sources_library -#}
+{%- set only_headers_like_sources_library = false -%}
+{%- endif -%}
+{%- endfor -%}
+{%- else -%}
+{#- Without target sources flag only_headers_like_sources_library -#}
+{%- set only_headers_like_sources_library = false -%}
+{%- endif -%}
+{%- else -%}
+{%- set only_headers_like_sources_library = false -%}
+{%- endif -%}
+
+{%- set is_really_fake_module = (current_target.is_fake_module) and not(only_headers_like_sources_library) -%}
+
{{ macro }}({{ name }}
-{%- if current_target.is_fake_module %} INTERFACE{%- endif -%}
-{%- if macro_args|length > 0 %}
+{%- if current_target.is_fake_module -%}
+{%- if only_headers_like_sources_library %} STATIC{%- else %} INTERFACE{%- endif -%}
+{%- endif -%}
+{%- if macro_args|length > 0 -%}
{%- for arg in macro_args %}
{{ arg }}
-{% endfor -%}
+{%- endfor -%}
{%- endif -%}
)
+{% if (current_target.is_fake_module) and (only_headers_like_sources_library) %}
+set_property(TARGET {{ name }} PROPERTY LINKER_LANGUAGE CXX)
+{%- endif -%}
+
{% include "[generator]/target_properties.jinja" -%}
{%- include "[generator]/target_options.jinja" -%}
{%- include "[generator]/target_commands.jinja" -%}
diff --git a/build/export_generators/cmake/target_links.jinja b/build/export_generators/cmake/target_links.jinja
index 3b349c17a7..0680fcba69 100644
--- a/build/export_generators/cmake/target_links.jinja
+++ b/build/export_generators/cmake/target_links.jinja
@@ -6,7 +6,7 @@
{%- if add_interfaces|length -%}
{%- set interfaces = interfaces + add_interfaces -%}
{%- endif -%}
-{%- if current_target.is_fake_module -%}
+{%- if is_really_fake_module -%}
{%- set add_interfaces = current_target.link|map(attribute='publics')|sum -%}
{%- if add_interfaces|length -%}
{%- set interfaces = interfaces + add_interfaces -%}
@@ -33,7 +33,7 @@
{%- set allocators = allocators + current_target.allocators -%}
{%- else -%}
{#- not supported allocators -#}
-{%- if current_target.is_fake_module -%}
+{%- if is_really_fake_module -%}
{%- set interfaces = interfaces + current_target.allocators -%}
{%- else -%}
{%- set publics = publics + current_target.allocators -%}
diff --git a/build/export_generators/cmake/target_options.jinja b/build/export_generators/cmake/target_options.jinja
index b6e2570f04..e8cbeb8dd3 100644
--- a/build/export_generators/cmake/target_options.jinja
+++ b/build/export_generators/cmake/target_options.jinja
@@ -2,14 +2,14 @@
{%- set OPTIONS_ORDER_AFTER_LINKS = ['target_link_options'] -%}
{%- for OPTION in OPTIONS_ORDER_BEFORE_LINKS -%}
-{{ TargetOptions(name, current_target.is_fake_module, current_target.target_options, OPTION, []) }}
+{{ TargetOptions(name, is_really_fake_module, current_target.target_options, OPTION, []) }}
{%- endfor -%}
{%- include "[generator]/target_links.jinja" -%}
{%- for OPTION in OPTIONS_ORDER_AFTER_LINKS -%}
-{{ TargetOptions(name, current_target.is_fake_module, current_target.target_options, OPTION, []) }}
+{{ TargetOptions(name, is_really_fake_module, current_target.target_options, OPTION, []) }}
{%- endfor -%}
{#- Then all other options -#}
-{{ TargetOptions(name, current_target.is_fake_module, current_target.target_options, "", OPTIONS_ORDER_BEFORE_LINKS + OPTIONS_ORDER_AFTER_LINKS) }}
+{{ TargetOptions(name, is_really_fake_module, current_target.target_options, "", OPTIONS_ORDER_BEFORE_LINKS + OPTIONS_ORDER_AFTER_LINKS) }}