conanfile.py.jinja 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. from conan import ConanFile
  2. {%- if use_conan2 %}
  3. from conan.tools.files import copy
  4. from conan.tools.cmake import CMakeToolchain, CMakeDeps, cmake_layout
  5. {%- endif %}
  6. class App(ConanFile):
  7. settings = "os", "compiler", "build_type", "arch"
  8. default_options = {
  9. {%- for conan_option in conan_options -%}
  10. {%- set option_and_value = rsplit(conan_option, "=", 2) %}"{{ option_and_value[0] }}": "{{ option_and_value[1] }}"
  11. {%- if not loop.last -%}, {% endif -%}
  12. {%- endfor -%}
  13. }
  14. {%- if (conan_tool_packages|length) %}
  15. tool_requires =
  16. {%- for conan_tool_require in conan_tool_packages %} "{{ conan_tool_require }}"
  17. {%- if not loop.last -%},{%- endif -%}
  18. {%- endfor -%}
  19. {%- endif -%}
  20. {%- if (conan_packages|length) %}
  21. def requirements(self):
  22. requires = [
  23. {%- for conan_require in conan_packages %} "{{ conan_require }}"
  24. {%- if not loop.last -%},{%- endif -%}
  25. {%- endfor %} ]
  26. for require in requires:
  27. if ("linux-headers" in require) and (self.settings.os != "Linux"):
  28. continue
  29. self.requires(require)
  30. {%- endif -%}
  31. {%- if use_conan2 %}
  32. def generate(self):
  33. CMakeDeps(self).generate()
  34. CMakeToolchain(self).generate()
  35. for dep in self.dependencies.values():
  36. if dep.cpp_info.bindirs:
  37. {%- for conan_import in conan_imports -%}
  38. {%- set search_and_dstdir = rsplit(conan_import|trim, "->", 2) -%}
  39. {%- set search = search_and_dstdir[0]|trim -%}
  40. {%- set dstdir = search_and_dstdir[1]|trim -%}
  41. {%- set srcdir_and_mask = rsplit(search, ",", 2) -%}
  42. {%- set srcdir = srcdir_and_mask[0]|trim -%}
  43. {%- set mask = srcdir_and_mask[1]|trim %}
  44. copy(self, pattern="{{ mask }}", src=dep.cpp_info.bindirs[0], dst=self.build_folder + "../../../../{{ dstdir }}")
  45. {%- endfor %}
  46. def layout(self):
  47. cmake_layout(self)
  48. {%- else %}
  49. generators = "cmake_find_package", "cmake_paths"
  50. def imports(self):
  51. {%- for conan_import in conan_imports -%}
  52. {%- set search_and_dstdir = rsplit(conan_import|trim, "->", 2) -%}
  53. {%- set search = search_and_dstdir[0]|trim -%}
  54. {%- set dstdir = search_and_dstdir[1]|trim -%}
  55. {%- set srcdir_and_mask = rsplit(search, ",", 2) -%}
  56. {%- set srcdir = srcdir_and_mask[0]|trim -%}
  57. {%- set mask = srcdir_and_mask[1]|trim %}
  58. self.copy(pattern="{{ mask }}", src="{{ srcdir }}", dst="{{ dstdir }}")
  59. {%- endfor %}
  60. {%- endif %}