123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- from conan import ConanFile
- {%- if use_conan2 %}
- import os
- from conan.tools.files import copy
- from conan.tools.cmake import CMakeToolchain, CMakeDeps, cmake_layout
- from conan.tools.env import Environment
- {%- endif %}
- class App(ConanFile):
- settings = "os", "compiler", "build_type", "arch"
- options = {
- {%- for conan_option in conan.options -%}
- {%- set option_and_value = rsplit(conan_option, "=", 2) %}"{{ option_and_value[0] }}": "{{ option_and_value[1] }}"
- {%- if not loop.last -%}, {% endif -%}
- {%- endfor -%}
- }
- {%- set has_conan_os_depends_requires = conan.os_depends|selectattr('requires')|map(attribute='requires')|sum|length -%}
- {%- if (conan.requires|length) or (has_conan_os_depends_requires) %}
- def requirements(self):
- {%- if (conan.requires|length) %}
- {%- for conan_require in conan.requires %}
- self.requires("{{ conan_require }}")
- {%- endfor -%}
- {%- endif -%}
- {%- if (has_conan_os_depends_requires) -%}
- {%- for conan_os_depend in conan.os_depends|selectattr('requires') %}
- {%- if (conan_os_depend.requires|length) %}
- if self.settings.os == "{{ conan_os_depend.os }}":
- {%- for conan_require in conan_os_depend.requires %}
- self.requires("{{ conan_require }}")
- {%- endfor -%}
- {%- endif -%}
- {%- endfor -%}
- {%- endif -%}
- {%- endif -%}
- {%- set has_conan_os_depends_tool_requires = conan.os_depends|selectattr('tool_requires')|map(attribute='tool_requires')|sum|length -%}
- {%- if (conan.tool_requires|length) or (has_conan_os_depends_tool_requires) %}
- def build_requirements(self):
- {%- if (conan.tool_requires|length) %}
- {%- for conan_tool_require in conan.tool_requires %}
- self.tool_requires("{{ conan_tool_require }}")
- {%- endfor -%}
- {%- endif -%}
- {%- if (has_conan_os_depends_tool_requires) -%}
- {%- for conan_os_depend in conan.os_depends|selectattr('tool_requires') %}
- {%- if (conan_os_depend.tool_requires|length) %}
- if self.settings.os == "{{ conan_os_depend.os }}":
- {%- for conan_tool_require in conan_os_depend.tool_requires %}
- self.tool_requires("{{ conan_tool_require }}")
- {%- endfor -%}
- {%- endif -%}
- {%- endfor -%}
- {%- endif -%}
- {%- endif -%}
- {%- set has_conan_os_depends_imports = conan.os_depends|selectattr('imports')|map(attribute='imports')|sum|length -%}
- {%- if use_conan2 %}
- def generate(self):
- CMakeDeps(self).generate()
- CMakeToolchain(self).generate()
- {%- for conan_generator in conan.generators %}
- {{ conan_generator }}(self).generate()
- {%- endfor %}
- for dep in self.dependencies.values():
- {%- if conan.imports|length -%}
- {%- set conan_imports = conan.imports -%}
- {%- set shift = "" -%}
- {%- include "[generator]/conan_imports.jinja" -%}
- {%- endif -%}
- {%- if (has_conan_os_depends_imports) -%}
- {%- for conan_os_depend in conan.os_depends|selectattr('imports') %}
- {%- if (conan_os_depend.imports|length) %}
- if self.settings.os == "{{ conan_os_depend.os }}":
- {%- set conan_imports = conan_os_depend.imports -%}
- {%- set shift = " " -%}
- {%- include "[generator]/conan_imports.jinja" -%}
- {%- endif -%}
- {%- endfor -%}
- {%- endif %}
- def layout(self):
- cmake_layout(self)
- {%- else %}
- generators = "cmake_find_package", "cmake_paths"
- def imports(self):
- {%- if conan.imports|length -%}
- {%- set conan_imports = conan.imports -%}
- {%- set shift = "" -%}
- {%- include "[generator]/conan_imports.jinja" -%}
- {%- endif -%}
- {%- if (has_conan_os_depends_imports) -%}
- {%- for conan_os_depend in conan.os_depends|selectattr('imports') %}
- {%- if (conan_os_depend.imports|length) %}
- if self.settings.os == "{{ conan_os_depend.os }}":
- {%- set conan_imports = conan_os_depend.imports -%}
- {%- set shift = " " -%}
- {%- include "[generator]/conan_imports.jinja" -%}
- {%- endif -%}
- {%- endfor -%}
- {%- endif -%}
- {%- endif -%}
- {%- include "[generator]/debug_conan.jinja" ignore missing %}
|