1

I have installed the current Qt 5.8 inside a users home directory and now try to use it since three days. Cmake always uses the system wide Qt installation and kdevelop does the same. No CodeCompletion on the new stuff and so on... I tried to install it system wide in /opt/Qt but nothing changed. So can please anyone tell me what environment variables do I have to change to integrate the current Qt Version in my Development System?

Many Thanks

By the way - it is a kdevelop 5.0 running on a Debian Linux testing

  • Possible duplicate of [cmake does not find qt 5.1.1](http://stackoverflow.com/questions/18722329/cmake-does-not-find-qt-5-1-1) – Velkan Mar 27 '17 at 06:31
  • thanks for this, if you could link for a workaround for code completion that would be fine ... cmake works fine now but kdevelop still dont know the new libs – Johannes Brunner Mar 27 '17 at 06:49

2 Answers2

1

From cmake does not find qt 5.1.1 question:

You need to set the CMAKE_MODULE_PATH to the Qt installation where the *.cmake files are located. This CMake variable is used to select which Qt installation to use for compiling. There is also a`CMAKE_PREFIX_PATH environment variable.

See http://doc.qt.io/qt-5/cmake-manual.html

The code completion: in project settings add to include paths something like:

/.../.../5.8/gcc_64/include/QtGui/
/.../.../5.8/gcc_64/include/QtCore/
/.../.../5.8/gcc_64/include/QtQuick/
...
Community
  • 1
  • 1
Velkan
  • 7,067
  • 6
  • 43
  • 87
  • 1
    CMAKE_PREFIX_PATH is an environment variable, not a cmake variable. If you want to switch easily between multiple Qt versions, you can use Kdevelops environment groups to do so: Setup one environment group for each qt version in settings -> environment with the CMAKE_PREFIX_PATH set (e.g. `~/Qt/5.8`) and switch between them in the project config (advanced!) – at-2500 Apr 05 '17 at 14:19
  • @at-2500, you're right about the CMAKE_PREFIX_PATH, I've probably meant CMAKE_MODULE_PATH. – Velkan Apr 05 '17 at 14:26
  • +1. Using KDevelop's environment groups is the way to go here. That's what I use personally as well. For running your applications, you may need to set additional Qt-related environment variables, such as `QT_PLUGIN_PATH`, `QML2_IMPORT_PATH`, etc. – kfunk May 22 '17 at 13:53
0

Edit: The following is only correct for Qt4 and not for Qt5!

The default qt version found by cmake is the one assoziated with the qmake binary in your $PATH. Run which qmake in order to find out which one it is. It will probably be the system-wide one. The fastest way to coerce cmake into finding your custom version is then adding your Qt's bin folder to the $PATH as the first entry and running kdevelop from that command line: PATH=/opt/Qt/5.8/bin:$PATH kdevelop. Code completion should then also work, as AFAIK kdevelop uses the include folders evaluated by cmake for code completion.

You might want to consider switching to QtCreator, which fixes this problem by listing all Qt versions as "Kits" which you can select in the project settings.

at-2500
  • 563
  • 4
  • 9
  • Since 5.0 CMake no longer looks after the `qmake` binary, but instead checks the CMake config modules installed by Qt5. `CMAKE_PREFIX_PATH` is the canonical way to make sure CMake detects the right config module. Modifying PATH is merely a hack which works out of luck (also cf.https://cmake.org/cmake/help/v3.0/command/find_package.html -"Search paths") – kfunk Apr 05 '17 at 10:20
  • Indeed, you are correct. I will mention this in my answer. – at-2500 Apr 05 '17 at 14:02