“conanfile.txt“: the recipe

发布于:2024-01-24 ⋅ 阅读:(59) ⋅ 点赞:(0)

Requires

The required dependencies should be specified in the [requires] section. Here is an example:

[requires]
mypackage/1.0.0@company/stable

mypackage is the name of the package which is usually the same as the project/library.

1.0.0 is the version which usually matches that of the packaged project/library. This can be any string; it does not have to be a number, so, for example, it could indicate if this is a “develop” or “master” version. Packages can be overwritten, so it is also OK to have packages like “nightly” or “weekly”, that are regenerated periodically.

company is the owner of this package. It is basically a namespace that allows different users to have their own packages for the same library with the same name.

stable is the channel. Channels provide another way to have different variants of packages for the same library and use them interchangeably. They usually denote the maturity of the package as an arbitrary string such as “stable” or “testing”, but they can be used for any purpose such as package revisions (e.g., the library version has not changed, but the package recipe has evolved).

What’s More

  1. user/channel is optional
    If the package was created and uploaded without specifying the user and channel you can omit the user/channel when specifying a reference:
[requires]
packagename/1.2.0
  1. Overriding requirements

You can specify multiple requirements and override transitive “require’s requirements”. In our example, Conan installed the Poco package and all its requirements transitively:
• openssl/1.0.2t
• zlib/1.2.11

Here is the recipe of the text book Hello World example:

conanfile.txt

[requires]
poco/1.9.4

[generators]
cmake

One can see from the above that all the requirements this example Conan project needs is poco/1.9.4. However, poco/1.9.4 also needs other dependencies. Here one can update some dependency of poco/1.9.4 by add a line in the above [requires] filed, like this:

[requires]
poco/1.9.4
openssl/1.0.2u

The second line will override the openssl/1.0.2t required by POCO with the currently non-existent openssl/1.0.2u. That is, the openssl/1.0.2u added overrides the version that defined in the poco/1.9.4 package.
Another example in which we may want to try some new zlib alpha features: we could replace the zlib requirement with one from another user or channel:

[requires]
poco/1.9.4
openssl/1.0.2u
zlib/1.2.11@otheruser/alpha

Generators

todo…

References

  1. Conan Documentation --Release 1.58.0
本文含有隐藏内容,请 开通VIP 后查看

网站公告

今日签到

点亮在社区的每一天
去签到