简体   繁体   English

qt Qmake 为项目生成 pkgconfig

[英]qt Qmake generating pkgconfig for a project

I have been told that it is possible to generate a pkg-config file through qmake, but I have no idea how to do it.有人告诉我可以通过 qmake 生成 pkg-config 文件,但我不知道该怎么做。 I have been looking online for a while, and it seems as though it is something you just have to know how to do.我一直在网上寻找一段时间,似乎这是你只需要知道如何做的事情。 Can someone give me an example, or point me to some sort of guide/tutorial?有人可以给我一个例子,或者指向某种指南/教程吗?

If you want to generate a.pc file (in contrast to simply use pkg-config to find dependencies, which is well supported by qmake), you might be interested in the following.如果你想生成一个 .pc 文件(与简单地使用 pkg-config 查找依赖项相比,qmake 很好地支持),你可能对以下内容感兴趣。 Obviously, creating.pc files is a less visible, but existing feature of QMake.显然,创建 .pc 文件是 QMake 的一个不太明显但现有的功能。 You want to use CONFIG += create_pc , which depends on create_prl .您想使用CONFIG += create_pc ,这取决于create_prl If you don't want to install the.prl file, use no_install_prl , too.如果您不想安装 .prl 文件,也请使用no_install_prl Overall, this gives you:总体而言,这为您提供:

CONFIG += create_pc create_prl no_install_prl

QMAKE_PKGCONFIG_NAME = VigraQt
QMAKE_PKGCONFIG_DESCRIPTION = Qt4 bindings for the VIGRA library
QMAKE_PKGCONFIG_PREFIX = $$INSTALLBASE
QMAKE_PKGCONFIG_LIBDIR = $$target.path
QMAKE_PKGCONFIG_INCDIR = $$headers.path
QMAKE_PKGCONFIG_VERSION = $$VERSION

This is what I came up with for VigraQt .这就是我想出的VigraQt There's also QMAKE_PKGCONFIG_DESTDIR , which you may use to specify the location of the.pc files within the source directory.还有QMAKE_PKGCONFIG_DESTDIR ,您可以使用它来指定源目录中 .pc 文件的位置。 Finally, there are QMAKE_PKGCONFIG_VARIABLES , QMAKE_PKGCONFIG_REQUIRES , and QMAKE_PKGCONFIG_CFLAGS in addition to the above.最后,除了上述之外,还有QMAKE_PKGCONFIG_VARIABLESQMAKE_PKGCONFIG_REQUIRESQMAKE_PKGCONFIG_CFLAGS

(There is also create_libtool for.la files, which also depends on the.prl files.) (还有create_libtool for.la 文件,它也依赖于 .prl 文件。)

Is this what you are looking for? 是你要找的吗?

To generate pkg-config using qmake you have to add to (modify) your project file (*.pro file):要使用 qmake 生成 pkg-config,您必须添加(修改)您的项目文件(*.pro 文件):

unix {
    CONFIG += link_pkgconfig
    PKGCONFIG += <pc_file_without_extension>
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM