-
Notifications
You must be signed in to change notification settings - Fork 382
Added PkgConfigDeps generator #2133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
437579a
7a225c6
f209afb
5310def
1093d23
4303c06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,3 +11,4 @@ conan.tools.gnu | |
| gnu/autotoolstoolchain | ||
| gnu/autotoolsgen | ||
| gnu/autotools | ||
| gnu/pkgconfigdeps | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| .. _conan_tools_pkgconfig: | ||
|
|
||
|
|
||
| conan.tools.gnu.pkgconfigdeps | ||
| ============================= | ||
|
|
||
| .. warning:: | ||
|
|
||
| These tools are **experimental** and subject to breaking changes. | ||
|
|
||
|
|
||
| PkgConfigDeps | ||
| ------------- | ||
|
|
||
| Available since: `1.38.0 <https://github.com/conan-io/conan/releases>`_ | ||
|
|
||
|
|
||
| The ``PkgConfigDeps`` is the dependencies generator for pkg-config. Generates pkg-config files named *<PKG-NAME>.pc* | ||
| (where ``<PKG-NAME`` is the name declared by dependencies in ``cpp_info.name`` or in ``cpp_info.names["pkg_config"]`` | ||
| if specified), containing a valid pkg-config file syntax. Indeed, it can also be defined using ``set_property`` and the | ||
| property ``pkg_config_name`` (available since Conan 1.36), for instance: | ||
|
|
||
| .. code-block:: python | ||
|
|
||
| self.cpp_info.components["mycomponent"].set_property("pkg_config_name", "mypkg-config-name") | ||
|
|
||
|
|
||
| .. note:: | ||
| In Conan 2.0 that will be the default way of setting those properties and also passing custom properties to generators. | ||
| Check the :ref:`cpp_info attributes reference <cpp_info_attributes_reference>` for more information. | ||
|
|
||
|
|
||
| The ``prefix`` variable is automatically adjusted to the ``package_folder``. | ||
|
|
||
|
|
||
| The ``PkgConfigDeps`` generator can be used by name in conanfiles: | ||
|
|
||
| .. code-block:: python | ||
| :caption: conanfile.py | ||
|
|
||
| class Pkg(ConanFile): | ||
| generators = "PkgConfigDeps" | ||
|
|
||
| .. code-block:: text | ||
| :caption: conanfile.txt | ||
|
|
||
| [generators] | ||
| PkgConfigDeps | ||
|
|
||
| And it can also be fully instantiated in the conanfile ``generate()`` method: | ||
|
|
||
| .. code:: python | ||
|
|
||
| from conans import ConanFile | ||
| from conan.tools.gnu import PkgConfigDeps | ||
|
|
||
| class App(ConanFile): | ||
| settings = "os", "arch", "compiler", "build_type" | ||
| requires = "zlib/1.2.11" | ||
|
|
||
| def generate(self): | ||
| pc = PkgConfigDeps(self) | ||
| pc.generate() | ||
|
|
||
| The ``PkgConfigDeps`` will generate the ``*.pc`` file after a ``conan install`` command: | ||
|
|
||
| .. code-block:: bash | ||
|
|
||
| $ conan install . | ||
| # Check the [PC_FILE_NAME].pc created in your current folder | ||
|
|
||
| Now, running this command using the previous ``conanfile.py``, you can check the ``zlib.pc`` file created into your current folder: | ||
|
|
||
| .. code-block:: text | ||
|
|
||
| prefix=/Users/YOUR_USER/.conan/data/zlib/1.2.11/_/_/package/647afeb69d3b0a2d3d316e80b24d38c714cc6900 | ||
| libdir=${prefix}/lib | ||
| includedir=${prefix}/include | ||
|
|
||
| Name: zlib | ||
| Description: Conan package: zlib | ||
| Version: 1.2.11 | ||
| Libs: -L"${libdir}" -lz -Wl,-rpath,"${libdir}" -F Frameworks | ||
| Cflags: -I"${includedir}" | ||
|
|
||
|
|
||
| Components | ||
| ++++++++++ | ||
|
|
||
| If a recipe uses :ref:`components<package_information_components>`, the files generated will be *<COMP-NAME>.pc* with their corresponding | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Isn't the name
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The thing is that I got this doc-lines about the Components from this one https://docs.conan.io/en/latest/reference/generators/pkg_config.html Anyway, I'm gonna check it 😉 |
||
| flags and require relations. | ||
|
|
||
| Additionally, a *<PKG-NAME>.pc* is generated to maintain compatibility for consumers with recipes that start supporting components. This | ||
| *<PKG-NAME>.pc* file will declare all the components of the package as requires while the rest of the fields will be empty, relying on | ||
| the propagation of flags coming from the components *<COMP-NAME>.pc* files. | ||
Uh oh!
There was an error while loading. Please reload this page.