aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsennikovmv <sennikovmv@yandex-team.com>2024-03-11 17:59:31 +0300
committersennikovmv <sennikovmv@yandex-team.com>2024-03-11 18:13:41 +0300
commita3cbcd5e6fe1a85d7f7697f23049c4cb09c565da (patch)
tree3734402f9d22f26bb96674e2f5b29eed203743b8
parenta7a431a1c2a6704ba0cf2dbfe9e1c198945e8a9e (diff)
downloadydb-a3cbcd5e6fe1a85d7f7697f23049c4cb09c565da.tar.gz
Cmake export over Jinja-templates
e2b1c43de6c025f92fd57b8201dd9b85278d0762
-rw-r--r--build/export_generators/hardcoded-cmake/dir_cmake_lists.jinja35
-rw-r--r--build/export_generators/hardcoded-cmake/generator.toml5
-rw-r--r--build/export_generators/hardcoded-cmake/target_cmake_lists.jinja51
3 files changed, 91 insertions, 0 deletions
diff --git a/build/export_generators/hardcoded-cmake/dir_cmake_lists.jinja b/build/export_generators/hardcoded-cmake/dir_cmake_lists.jinja
new file mode 100644
index 0000000000..ec0d217d41
--- /dev/null
+++ b/build/export_generators/hardcoded-cmake/dir_cmake_lists.jinja
@@ -0,0 +1,35 @@
+{% include prologue ignore missing %}
+{% include '[generator]/disclaimer.jinja' -%}
+
+{% for package in packages -%}
+find_package({{ package[0] }} REQUIRED
+ {%- if package[1]|length > 0 %} COMPONENTS
+ {%- for component in package[1] %} {{ component }}
+ {%- endfor %}
+ {%- endif %})
+{% endfor -%}
+{% for incl in includes -%}
+include({{ incl }})
+{% endfor -%}
+{% for subdir in subdirs -%}
+add_subdirectory({{ subdir }})
+{% endfor -%}
+{% for dir_macro in dir_macros %}
+ {{- dir_macro[0] }}({{"\n"}}
+ {%- for value in dir_macro[1] %} {{ value }}{{"\n"}}
+ {%- endfor %})
+
+{% endfor -%}
+{% for target in targets %}
+{%- set macro = target.macro -%}
+ {%- set name = target.name -%}
+ {%- set is_interface = target.is_interface -%}
+ {%- set macro_args = target.macro_args -%}
+ {%- set properties = target.properties -%}
+ {%- set attributes = target.attributes -%}
+ {%- set target_dir_macros = target.target_dir_macros -%}
+ {%- set target_macros = target.target_macros -%}
+ {%- set dependencies = target.dependencies -%}
+ {%- include '[generator]/target_cmake_lists.jinja' %}{{"\n"}}
+{%- endfor %}
+{% include epilogue ignore missing %}
diff --git a/build/export_generators/hardcoded-cmake/generator.toml b/build/export_generators/hardcoded-cmake/generator.toml
index 756c100a0b..a0f111ca91 100644
--- a/build/export_generators/hardcoded-cmake/generator.toml
+++ b/build/export_generators/hardcoded-cmake/generator.toml
@@ -22,7 +22,12 @@ platform_vars="list"
includes="sorted_set"
use_conan="bool"
+[attrs.dir]
+prologue="str"
+epilogue="str"
+
[attrs.target]
+is_interface="bool"
[[rules]]
attrs=["run_antlr"]
diff --git a/build/export_generators/hardcoded-cmake/target_cmake_lists.jinja b/build/export_generators/hardcoded-cmake/target_cmake_lists.jinja
new file mode 100644
index 0000000000..ef317d7b8c
--- /dev/null
+++ b/build/export_generators/hardcoded-cmake/target_cmake_lists.jinja
@@ -0,0 +1,51 @@
+{{ macro }}({{ name }}
+{%- if is_interface %} INTERFACE{% endif %}
+{%- if macro_args|length > 0 %}
+{%- for arg in macro_args %}
+ {{ arg }}
+{%- endfor -%}
+{% endif %})
+
+{% for property in properties -%}
+set_property(TARGET {{ name }} PROPERTY
+ {{ property[0] }}{% for value in property[1] %} {{ value }}
+{%- endfor %}
+)
+{% endfor -%}
+{% for attribute in attributes %}
+{%- if attribute[1].iface is defined %}
+{{ attribute[0] }}({{ name }} INTERFACE
+{% for val in attribute[1].iface %} {{ val }}
+{% endfor %})
+{%- endif %}
+{%- if attribute[1].pub is defined %}
+{{ attribute[0] }}({{ name }} PUBLIC
+{% for val in attribute[1].pub %} {{ val }}
+{% endfor %})
+{%- endif %}
+{%- if attribute[1].priv is defined %}
+{{ attribute[0] }}({{ name }} PRIVATE
+{% for val in attribute[1].priv %} {{ val }}
+{% endfor %})
+{%- endif %}
+{% endfor %}
+{% for dir_macro in target_dir_macros %}
+{{ dir_macro[0] }}(
+{% for value in dir_macro[1] %} {{ value }}
+{% endfor %})
+{% endfor %}
+{% for target_macro in target_macros %}
+{{ target_macro[0] }}({{ name }}
+{%- if target_macro[1]|length > 0 %}
+{% for value in target_macro[1] -%}
+ {{ value }}
+{% endfor %}
+{%- endif %})
+{% endfor %}
+{% if dependencies|length > 0 -%}
+if(NOT CMAKE_CROSSCOMPILING)
+ add_dependencies({{ name }}
+{% for dep in dependencies %} {{ dep }}
+{% endfor %})
+endif()
+{%- endif -%}