Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

using find_package() of cmake in QtCreator



  • I am using Qt Creator to work on a project that is using cmake. I want to use find_package() function of cmake to find Qt5Core and other Qt related libraries. My problem is when I use find_package(Qt5Core) library, QtCreator adds a entry in projects pane that is a relative path to .cmake config files. I try to show this with pictures. I use a simple program to do this.

    This is QtCreator before using find_package() in root cmake file:
    alt text

    This is QtCreator after using find_package() in root cmake file:
    alt text

    I hope that this is clear explanation. How can I disable this feature in QtCreator?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    You should add which version of Qt Creator and Qt you are using.



  • Thanks for your reply.
    I was using Qt 5.9.0 and QtCreator 4.3.0 which is the latest Qt. Then I test this on other computer by installing QtCreator 4.3.0 (becuase this version of QtCreator is the best) and installing Qt libraries from repository. But nothing changed and I had that problem too.
    This annoying problem occurs in older versions of QtCreator too.

    This is a picture of QtCreator 3.5.1 that has this problem too:
    alt text

    By the way I am using Kubuntu 16.04 LTS and 64bit machine.

    Also this is the minimal example that I used to show the problem. (here)


  • Lifetime Qt Champion

    When you say you are installing Qt from repository, do you mean from your distribution package management ?



  • Yes I mean installing from distribution package management.
    I also installed the latest Qt .run file from Qt.io website that had this problem.
    I make a project by creating the main.cc and CMakeLists.txt file that I uploaded and using QtCreator to open the CMakeLists.txt file.
    Did you test that? I had this problem on my older computer too.
    For some libraries like liblua5.2, when I use find_pakage(Lua) nothing adds to the projects pane but when I use find_package(Qt5Core) it adds path to .cmake config files.



  • Hi again
    When I install and use Qt4 libraries using cmake command: find_package(Qt4 COMPONENTS QTCORE QTGUI REQUIRED), everything works fine and nothing adds to the projects pane.
    I hope this helps to solve the problem in future version of qtcreator.
    Thanks.



  • Do you have the Qt5 you want to use set up as a 'Kit' in QtCreator? If you type 'which qmake' on the command line, what does it print out? I think setting the correct Kit will take care of it, but you can also try setting QTDIR to the appropriate Qt version's bin directory in your CMakeLists.txt file (e.g., SET(QTDIR "/home/myhomefolder/MyQt5/bin") ).


  • Lifetime Qt Champion

    Qt Creator 4.3.1 just got released with work that has been done on the cmake side. You should check it.



  • Hi
    I checked out QtCreator 4.3.1 but I think it's cmake support is a mess.
    QtCreator had a very robust cmake support in the past but I think those days are gone.

    Look what happens when I create a simple non-qt project using QtCreator:
    alt text

    alt text

    alt text

    alt text

    alt text

    Look at project view. Even for a simple cmake project there are many annoying entries that I don't want.
    I just want a simple project view that shows my folders and source files in tree like structure.
    When I import my cmake project which is a big project in Qtcreatro 4.3.1 I can't handle it. QtCreator shows me cmake targets and split headers and sources in "<Source Directory>" and "<Headers>" folders.


  • Qt Champions 2019

    @Bazinevis You can switch from "Projects" to "File System" view



  • I tried to use FileSystem view but it doesn't have tree structure like project view has. Every time I want to expand a folder I have to open that folder. Besides that using FileSystem view and switching between files is annoying.


Log in to reply