PDA

View Full Version : error "variable set to NOTFOUND" in compiling a Qt project wtih CMake



jamadagni
25th June 2013, 04:16
Hello. In connection with a project I am working on, I found some related Qt-based code at https://code.google.com/p/cornucopia-lib/

So I cloned the hg repo, and did:


mkdir build
cd build
cmake ..

but I got the following errors:


CMake Error: The following variables are used in this project, but
they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the
CMake files:
QT_QTSCRIPT_INCLUDE_DIR (ADVANCED)
used as include directory in directory
/home/samjnaa/sr/_repos/hg/cornucopia-lib/DemoUI
QT_QTSVG_INCLUDE_DIR (ADVANCED)
used as include directory in directory
/home/samjnaa/sr/_repos/hg/cornucopia-lib/DemoUI
used as include directory in directory
/home/samjnaa/sr/_repos/hg/cornucopia-lib/Tools
-- Configuring incomplete, errors occurred!

I wrote to the author about this but he was not sure what the problem was. So I hope someone here can indicate to me how I can fix these errors.

I am running Kubuntu Raring 64-bit with Qt 4.8.4 and CMake 2.8.10.

Thank you!

ChrisW67
25th June 2013, 06:39
The CMake Qt find module uses the Qt4 qmake: is it in the PATH?

You could try this at the top of DemoUI/ CMakeLists.txt:


# CmakeLists.txt in DemoUI

FIND_PACKAGE(Qt4 COMPONENTS QtSvg QtScript REQUIRED)
SET(QT_USE_QTSVG TRUE)
SET(QT_USE_QTSCRIPT TRUE)
INCLUDE(${QT_USE_FILE})

...

jamadagni
25th June 2013, 10:17
The CMake Qt find module uses the Qt4 qmake: is it in the PATH?
Yes it is.


You could try this at the top of DemoUI/ CMakeLists.txt:


FIND_PACKAGE(Qt4 COMPONENTS QtSvg QtScript REQUIRED)

Thank you very much! This worked to remove this particular error, but now I am getting the following error:


Scanning dependencies of target DemoUI
[ 58%] Building CXX object DemoUI/CMakeFiles/DemoUI.dir/GroupSelWidget.cpp.o
In file included from /home/samjnaa/sr/_repos/hg/cornucopia-lib/DemoUI/GroupSelWidget.cpp:21:0:
/home/samjnaa/sr/_repos/hg/cornucopia-lib/DemoUI/GroupSelWidget.h:26:19: fatal error: QWidget: No such file or directory
#include <QWidget>
^
compilation terminated.
make[2]: *** [DemoUI/CMakeFiles/DemoUI.dir/GroupSelWidget.cpp.o] Error 1
make[1]: *** [DemoUI/CMakeFiles/DemoUI.dir/all] Error 2
make: *** [all] Error 2
But I have the Qt headers installed (indeed I'm sure it would have complained earlier if I had not):

$ dpkg -S QWidget
...
libqt4-dev: /usr/include/qt4/QtGui/QWidget
...

I am guessing that some CMake command is pointing to the wrong include directory or something. (Or perhaps the code needs to use "QtGui/" as in #include <QtGui/QWidget> but I'd prefer to hack the CMakeLists.txt if possible.) Please tell me what correction I have to do to get *this* working now?

saman_artorious
25th June 2013, 11:03
//#include <QtGui/QWidget>
#include <QtWidgets/QtWidgets>

ChrisW67
25th June 2013, 11:53
No, the module name is not needed in the include (especially not the Qt5 one saman_artorious suggests).
Add QtGui and maybe QtCore to the COMPONENTS in your CMakeLists.txt

jamadagni
25th June 2013, 13:33
No, the module name is not needed in the include (especially not the Qt5 one saman_artorious suggests).
Add QtGui and maybe QtCore to the COMPONENTS in your CMakeLists.txt

Hi thank you very much -- I definitely preferred to not touch the sources and your suggestion worked (yes I needed to include QtCore too -- apparently there was #include <QSet> in there). BTW presumably the authors' CMake script worked at the time of their upload -- any idea it does not work now?

ChrisW67
25th June 2013, 22:13
The problem would appear to be a change in the behaviour of the CMake Qt4 find module, not Qt.