Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

    Unsolved using find_package() of cmake in QtCreator

    Tools
    4
    11
    3617
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • B
      Bazinevis last edited by

      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?

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        Hi and welcome to devnet,

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

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply Reply Quote 0
        • B
          Bazinevis last edited by Bazinevis

          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)

          1 Reply Last reply Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

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

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply Reply Quote 0
            • B
              Bazinevis last edited by

              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.

              1 Reply Last reply Reply Quote 0
              • B
                Bazinevis last edited by Bazinevis

                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.

                M 1 Reply Last reply Reply Quote 0
                • M
                  mchinand @Bazinevis last edited by

                  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") ).

                  1 Reply Last reply Reply Quote 0
                  • SGaist
                    SGaist Lifetime Qt Champion last edited by

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

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply Reply Quote 0
                    • B
                      Bazinevis last edited by Bazinevis

                      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.

                      jsulm 1 Reply Last reply Reply Quote 0
                      • jsulm
                        jsulm Lifetime Qt Champion @Bazinevis last edited by

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

                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                        1 Reply Last reply Reply Quote 0
                        • B
                          Bazinevis last edited by

                          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.

                          1 Reply Last reply Reply Quote 0
                          • First post
                            Last post