Generic Conan recipes for C/C++ and Python projects.
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']
If your project
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']
Why do I need to copy the
name
andversion
attributes from the base class?Conan parses the recipe looking for the
name
andversion
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 classCMakeConanFile
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.