Skip to content

thejohnfreeman/autorecipes

Repository files navigation

autorecipes

Generic Conan recipes for C/C++ and Python projects.

Latest Bintray version Build status: Linux and OSX Build status: Windows

C/C++

If your project

  • uses CMake,
  • and installs a package configuration file
  • that defines the variable <PACKAGE_NAME>_COMPONENTS
  • with a list of components,
  • and for each of them defines a target <package_name>::<component>,

then you should be able to copy this recipe to package it for Conan:

from conans import python_requires

CMakeConanFile = python_requires('autorecipes/[*]@jfreeman/testing').cmake()

class Recipe(CMakeConanFile):
    name = CMakeConanFile.__dict__['name']
    version = CMakeConanFile.__dict__['version']

Python

If your project

  • uses Poetry,
  • with a pyproject.toml package metadata file as defined in PEP 518,

then you should be able to copy this recipe to package it for Conan:

from conans import python_requires

PythonConanFile = python_requires('autorecipes/[*]@jfreeman/testing').python()

class Recipe(PythonConanFile):
    name = PythonConanFile.__dict__['name']
    version = PythonConanFile.__dict__['version']

FAQ

  • Why do I need to copy the name and version attributes from the base class?

    Conan parses the recipe looking for the name and version attributes, instead of just executing it. Thus, we must copy the attributes to move past that check.

    Further, these attributes are descriptors. Accessing them with dot notation, like CMakeConanFile.name, evaluates them against the class CMakeConanFile instead of your recipe, but they need the most derived type to work correctly.

  • Can I override some attributes?

    Yes. These base classes just provide default values.

About

Generic Conan recipes for CMake and Python projects.

Resources

License

Stars

Watchers

Forks

Packages

No packages published