aboutsummaryrefslogtreecommitdiffstats
path: root/build/export_generators/cmake/conanfile.py.jinja
blob: ca788509115a8f8b819c8872c30c5f9fe0f056fa (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
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"

    default_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 %}