qmake fails to resolve `pkg-config --cflags opencv`
In an opencv based project I use pkg-config to find the include and lib path of opencv to maintain portability.
I added my .pro file the following two lines:
INCLUDEPATH += `pkg-config --cflags opencv` LIBS += `pkg-config --libs opencv`
But it does not build, and the output window shows:
-I--cflags: unknown option
I went along the build process step-by-step manually, only to find that the generated Makefile contains:
INCPATH = -I../Workspace_Qt/untitled4 -I. -I`pkg-config -I--cflags -Iopencv` ...
And this generates the command in the output window:
g++ -c -pipe -g -std=gnu++0x -Wall -W -D_REENTRANT -fPIC -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I../Workspace_Qt/untitled4 -I. **-I`pkg-config -I--cflags -Iopencv` ...
...which is apparently wrong.
I checked the result of the other pkg-config invocation, to find it is correct:
LIBS = $(SUBLIBS) `pkg-config --libs opencv` ...
To reproduce the problem I stripped it and created a new QtWidget project. The problem was the same there.
I tested it with Qt5.6, Ubuntu 14.04. We tried the .pro files on OSX too, and it behaved the same - though we did not go into details there.
Is it possible that qmake ignores the ` in the resolution of INCPATH? People use this method all over the web, without any comment. Does anybody have any experience with pkg-config please?
What about using qmake support for pkg-config ?
CONFIG += link_pkgconfig PKGCONFIG += opencv
It works on Linux, but the same .pro file does not work on OSX.
On OSX we get a
Project ERROR: opencv development package not found.
Where's the opencv.pkg located in on your OS X machine ?