QMake analogue cmake "find_package"

Is there any mechanism in qmake like cmake find_package ?

If I need to enable the library installed on my system, how can I avoid manually writing the path and library names? What is the best practice?

+5
source share
1 answer

If your library provides the pkgconfig.pc file, you can use link_pkgconfig in your .pro file as:

 CONFIG += link_pkgconfig PKGCONFIG += quazip 

If the library provides a command-line utility for obtaining compiler flags (for example, postgresql), then you can call it and assign the output to be added to the appropriate variable

 INCLUDEPATH += $$system(pg_config --includedir) 

If the library itself was also written in Qt, it is unlikely, but it is possible that it provides a Qt module, for example qwt. In this case, you can simply add to your .pro file:

 CONFIG += qwt 
+4
source

All Articles