aboutsummaryrefslogtreecommitdiffstats
path: root/build/export_generators/hardcoded-cmake/conanfile.py.jinja
blob: dab8bb6937320464f2d552ada296371bb5d20585 (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
from conan import ConanFile

{%- if use_conan2 %}

from conan.tools.files import copy
from conan.tools.cmake import CMakeToolchain, CMakeDeps, cmake_layout

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

{%- if (conan_tool_packages|length) %}

    tool_requires =
{%-     for conan_tool_require in conan_tool_packages %} "{{ conan_tool_require }}"
{%-         if not loop.last -%},{%- endif -%}
{%-     endfor -%}
{%- endif -%}

{%- if (conan_packages|length) %}

    def requirements(self):
        requires = [
{%-     for conan_require in conan_packages %} "{{ conan_require }}"
{%-         if not loop.last -%},{%- endif -%}
{%-     endfor %} ]
        for require in requires:
            if ("linux-headers" in require) and (self.settings.os != "Linux"):
                continue
            self.requires(require)

{%- endif -%}

{%- if use_conan2 %}

    def generate(self):
        CMakeDeps(self).generate()
        CMakeToolchain(self).generate()

        for dep in self.dependencies.values():
            if dep.cpp_info.bindirs:
{%-         for conan_import in conan_imports -%}
{%-             set search_and_dstdir = rsplit(conan_import|trim, "->", 2) -%}
{%-             set search = search_and_dstdir[0]|trim -%}
{%-             set dstdir = search_and_dstdir[1]|trim -%}
{%-             set srcdir_and_mask = rsplit(search, ",", 2) -%}
{%-             set srcdir = srcdir_and_mask[0]|trim -%}
{%-             set mask = srcdir_and_mask[1]|trim %}
                copy(self, pattern="{{ mask }}", src=dep.cpp_info.bindirs[0], dst=self.build_folder + "../../../../{{ dstdir }}")
{%-         endfor %}

    def layout(self):
        cmake_layout(self)

{%- else %}

    generators = "cmake_find_package", "cmake_paths"

    def imports(self):
{%-     for conan_import in conan_imports -%}
{%-         set search_and_dstdir = rsplit(conan_import|trim, "->", 2) -%}
{%-         set search = search_and_dstdir[0]|trim -%}
{%-         set dstdir = search_and_dstdir[1]|trim -%}
{%-         set srcdir_and_mask = rsplit(search, ",", 2) -%}
{%-         set srcdir = srcdir_and_mask[0]|trim -%}
{%-         set mask = srcdir_and_mask[1]|trim %}
        self.copy(pattern="{{ mask }}", src="{{ srcdir }}", dst="{{ dstdir }}")
{%-     endfor %}

{%- endif %}