Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QtCreator + Conan + CMake
Forum Updated to NodeBB v4.3 + New Features

QtCreator + Conan + CMake

Scheduled Pinned Locked Moved Unsolved Qt Creator and other tools
9 Posts 2 Posters 2.2k Views 1 Watching
  • 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.
  • M Offline
    M Offline
    Matte86
    wrote on last edited by
    #1

    Hey guys,

    What is the envisioned workflow for working with QtCreator and Qt consumed via conan? I cannot find information online.

    I am able to build and execute via command line an application using Qt 6.3.1.
    Initially, I stumbled upon this same issue but followed the suggestions there to get everything working.

    I don't understand, however, what is the envisioned workflow to integrate all of this into QtCreator. I managed to import my test project from the existing build folder created via the command line. All the configurations seems to be properly imported, and the auto-detected kit also works. I am not able however to run the conan install step within the IDE (I get the error "Conan install: invalid command"). Also, I don't understand how could I enable the virtual env (source activate.sh) within QtCreator.

    Does someone have experience on this? Thanks a lot in advance!

    1 Reply Last reply
    0
    • cristian-adamC Offline
      cristian-adamC Offline
      cristian-adam
      wrote on last edited by
      #2

      Have a look at Qt Creator: CMake package-manager auto-setup.

      Qt Creator will inject a piece of CMake code that will use cmake-conan to run the conan install step before configuring the CMake project.

      1 Reply Last reply
      0
      • M Offline
        M Offline
        Matte86
        wrote on last edited by
        #3

        Thanks for the hint @cristian-adam !
        I followed your suggestion and now the conan install step runs successfully and the conan dependencies of my project build correctly. In my conan recipe I have the following requirements:

        def requirements(self):
                self.requires("qtbase/6.3.1@qt/everywhere")
                self.requires("qtdeclarative/6.3.1@qt/everywhere")
                self.requires("qtshadertools/6.3.1@qt/everywhere")
        

        I get however some errors while building my test application. In particular, the compiler complains that it does not find some headers like QQmlApplicationEngine and QQuickTextDocument.

        I checked and those files are available in my conan cache but from the compile command I see that QtQml.framework/Headers and QtQuick.framework/Headers are not passed as -isystem directories (only QtCore.framework/Headers and QtGui.framework/Headers are passed).

        Am I missing something in my cmake files? I would not know for which package / target to look for to be honest.

        1 Reply Last reply
        1
        • cristian-adamC Offline
          cristian-adamC Offline
          cristian-adam
          wrote on last edited by
          #4

          Documentation for QQmlApplicationEngine is stating that you need to have:

          find_package(Qt6 REQUIRED COMPONENTS Qml)
          target_link_libraries(mytarget PRIVATE Qt6::Qml)
          

          And for QQuickTextDocument you need:

          find_package(Qt6 REQUIRED COMPONENTS Quick)
          target_link_libraries(mytarget PRIVATE Qt6::Quick)
          

          Make sure you have the components mentioned in your find_package call.

          1 Reply Last reply
          1
          • M Offline
            M Offline
            Matte86
            wrote on last edited by Matte86
            #5

            That was indeed the initial version of my cmake files. With that configuration I was able to build and run the application via command line.

            The problem arises when I integrate everything into Qt Creator. Somehow the IDE cannot find those components so that call to find_package fails.

            This is the error I get:

            -- Could NOT find Qt6Qml (missing: Qt6Qml_DIR)
            CMake Error at ui-qml/CMakeLists.txt:9 (find_package):
              Found package configuration file:
            
                /Users/matt/.conan/data/qtbase/6.3.1/qt/everywhere/package/e82d3b03afbaff61d74c55b72301091c49f823e1/lib/cmake/Qt6/Qt6Config.cmake
            
              but it set Qt6_FOUND to FALSE so package "Qt6" is considered to be NOT
              FOUND.  Reason given by package:
            
              Failed to find Qt component "Qml".
            
              Expected Config file at
              "/Users/matt/.conan/data/qtbase/6.3.1/qt/everywhere/package/e82d3b03afbaff61d74c55b72301091c49f823e1/lib/cmake/Qt6Qml/Qt6QmlConfig.cmake"
              does NOT exist
            

            The Qt6QmlConfig.cmake file is expected in the qtbase package but in my conan cache is avaialble at

            /Users/matt/.conan/data/qtdeclarative/6.3.1/qt/everywhere/package/2dde3e9608192b6b5be2c3f127c052e58418d664/lib/cmake/Qt6Qml
            
            1 Reply Last reply
            0
            • cristian-adamC Offline
              cristian-adamC Offline
              cristian-adam
              wrote on last edited by
              #6

              I think this is a Qt conan recipe bug. You should have in your <build-dir>/conan-dependencies/conan_paths.cmake something like:

              set(CMAKE_PREFIX_PATH
              "/Users/matt/.conan/data/qtbase/6.3.1/qt/everywhere/package/e82d3b03afbaff61d74c55b72301091c49f823e1/"
              "/Users/matt/.conan/data/qtdeclarative/6.3.1/qt/everywhere/build/2dde3e9608192b6b5be2c3f127c052e58418d664" ${CMAKE_PREFIX_PATH} ${CMAKE_CURRENT_LIST_DIR})
              

              so that CMake, when doing a find_package, will search in all directories.

              Make sure you delete your <build-dir> and start from scratch, and if it doesn't help, then rung CMake wiht --debug-find so that it prints more details about the find_package calls.

              1 Reply Last reply
              0
              • M Offline
                M Offline
                Matte86
                wrote on last edited by Matte86
                #7

                My bad, the location in my conan cache of Qt6QmlConfig.cmake file was:

                "/Users/matt/.conan/data/qtdeclarative/6.3.1/qt/everywhere/**package**/2dde3e9608192b6b5be2c3f127c052e58418d664/lib/cmake/Qt6Qml"
                

                and not:

                "/Users/matt/.conan/data/qtdeclarative/6.3.1/qt/everywhere/**build**/2dde3e9608192b6b5be2c3f127c052e58418d664/lib/cmake/Qt6Qml"
                

                I checked in my conan_paths.cmake and all the paths seem to be there.
                By running CMake with additional debug info I get:

                CMake Debug Log at ui-qml/CMakeLists.txt:9 (find_package):
                  find_package considered the following paths for FindQt6.cmake:
                
                    /Users/matt/.conan/data/ninja/1.11.0/_/_/package/dcee4cca2e436edf288d615e9a3f84542aab8e03/FindQt6.cmake
                    /Users/matt/.conan/data/qtdeclarative/6.3.1/qt/everywhere/package/2dde3e9608192b6b5be2c3f127c052e58418d664/FindQt6.cmake
                    /Users/matt/.conan/data/qtimageformats/6.3.1/qt/everywhere/package/66b09352dfc791c1f370be1e3bc4d82923afb37c/FindQt6.cmake
                    /Users/matt/.conan/data/qtlanguageserver/6.3.1/qt/everywhere/package/66b09352dfc791c1f370be1e3bc4d82923afb37c/FindQt6.cmake
                    /Users/matt/.conan/data/qtshadertools/6.3.1/qt/everywhere/package/66b09352dfc791c1f370be1e3bc4d82923afb37c/FindQt6.cmake
                    /Users/matt/.conan/data/qtsvg/6.3.1/qt/everywhere/package/66b09352dfc791c1f370be1e3bc4d82923afb37c/FindQt6.cmake
                    /Users/matt/.conan/data/qtbase/6.3.1/qt/everywhere/package/e82d3b03afbaff61d74c55b72301091c49f823e1/FindQt6.cmake
                    /Users/matt/.conan/data/ninja/1.11.0/_/_/package/dcee4cca2e436edf288d615e9a3f84542aab8e03/FindQt6.cmake
                    /Users/matt/.conan/data/qtdeclarative/6.3.1/qt/everywhere/package/2dde3e9608192b6b5be2c3f127c052e58418d664/FindQt6.cmake
                    /Users/matt/.conan/data/qtimageformats/6.3.1/qt/everywhere/package/66b09352dfc791c1f370be1e3bc4d82923afb37c/FindQt6.cmake
                    /Users/matt/.conan/data/qtlanguageserver/6.3.1/qt/everywhere/package/66b09352dfc791c1f370be1e3bc4d82923afb37c/FindQt6.cmake
                    /Users/matt/.conan/data/qtshadertools/6.3.1/qt/everywhere/package/66b09352dfc791c1f370be1e3bc4d82923afb37c/FindQt6.cmake
                    /Users/matt/.conan/data/qtsvg/6.3.1/qt/everywhere/package/66b09352dfc791c1f370be1e3bc4d82923afb37c/FindQt6.cmake
                    /Users/matt/.conan/data/qtbase/6.3.1/qt/everywhere/package/e82d3b03afbaff61d74c55b72301091c49f823e1/FindQt6.cmake
                    /Users/matt/.conan/data/ninja/1.11.0/_/_/package/dcee4cca2e436edf288d615e9a3f84542aab8e03/FindQt6.cmake
                    /Users/matt/.conan/data/qtdeclarative/6.3.1/qt/everywhere/package/2dde3e9608192b6b5be2c3f127c052e58418d664/FindQt6.cmake
                    /Users/matt/.conan/data/qtimageformats/6.3.1/qt/everywhere/package/66b09352dfc791c1f370be1e3bc4d82923afb37c/FindQt6.cmake
                    /Users/matt/.conan/data/qtlanguageserver/6.3.1/qt/everywhere/package/66b09352dfc791c1f370be1e3bc4d82923afb37c/FindQt6.cmake
                    /Users/matt/.conan/data/qtshadertools/6.3.1/qt/everywhere/package/66b09352dfc791c1f370be1e3bc4d82923afb37c/FindQt6.cmake
                    /Users/matt/.conan/data/qtsvg/6.3.1/qt/everywhere/package/66b09352dfc791c1f370be1e3bc4d82923afb37c/FindQt6.cmake
                    /Users/matt/.conan/data/qtbase/6.3.1/qt/everywhere/package/e82d3b03afbaff61d74c55b72301091c49f823e1/FindQt6.cmake
                    /Users/matt/.conan/data/ninja/1.11.0/_/_/package/dcee4cca2e436edf288d615e9a3f84542aab8e03/FindQt6.cmake
                    /Users/matt/.conan/data/qtdeclarative/6.3.1/qt/everywhere/package/2dde3e9608192b6b5be2c3f127c052e58418d664/FindQt6.cmake
                    /Users/matt/.conan/data/qtimageformats/6.3.1/qt/everywhere/package/66b09352dfc791c1f370be1e3bc4d82923afb37c/FindQt6.cmake
                    /Users/matt/.conan/data/qtlanguageserver/6.3.1/qt/everywhere/package/66b09352dfc791c1f370be1e3bc4d82923afb37c/FindQt6.cmake
                    /Users/matt/.conan/data/qtshadertools/6.3.1/qt/everywhere/package/66b09352dfc791c1f370be1e3bc4d82923afb37c/FindQt6.cmake
                    /Users/matt/.conan/data/qtsvg/6.3.1/qt/everywhere/package/66b09352dfc791c1f370be1e3bc4d82923afb37c/FindQt6.cmake
                    /Users/matt/.conan/data/qtbase/6.3.1/qt/everywhere/package/e82d3b03afbaff61d74c55b72301091c49f823e1/FindQt6.cmake
                    /Users/matt/.conan/data/ninja/1.11.0/_/_/package/dcee4cca2e436edf288d615e9a3f84542aab8e03/FindQt6.cmake
                    /Users/matt/.conan/data/qtdeclarative/6.3.1/qt/everywhere/package/2dde3e9608192b6b5be2c3f127c052e58418d664/FindQt6.cmake
                    /Users/matt/.conan/data/qtimageformats/6.3.1/qt/everywhere/package/66b09352dfc791c1f370be1e3bc4d82923afb37c/FindQt6.cmake
                    /Users/matt/.conan/data/qtlanguageserver/6.3.1/qt/everywhere/package/66b09352dfc791c1f370be1e3bc4d82923afb37c/FindQt6.cmake
                    /Users/matt/.conan/data/qtshadertools/6.3.1/qt/everywhere/package/66b09352dfc791c1f370be1e3bc4d82923afb37c/FindQt6.cmake
                    /Users/matt/.conan/data/qtsvg/6.3.1/qt/everywhere/package/66b09352dfc791c1f370be1e3bc4d82923afb37c/FindQt6.cmake
                    /Users/matt/.conan/data/qtbase/6.3.1/qt/everywhere/package/e82d3b03afbaff61d74c55b72301091c49f823e1/FindQt6.cmake
                    /Users/matt/Desktop/Workspaces/qt6-qml-example/build_release_with_debug_info/conan-dependencies/FindQt6.cmake
                    /Users/matt/Desktop/Workspaces/qt6-qml-example/build_release_with_debug_info/conan-dependencies/FindQt6.cmake
                    /Applications/CMake.app/Contents/share/cmake-3.24/Modules/FindQt6.cmake
                
                  The file was not found.
                
                    /Users/matt/.conan/data/qtbase/6.3.1/qt/everywhere/package/e82d3b03afbaff61d74c55b72301091c49f823e1/lib/cmake/Qt6/Qt6Config.cmake
                
                1 Reply Last reply
                0
                • cristian-adamC Offline
                  cristian-adamC Offline
                  cristian-adam
                  wrote on last edited by
                  #8

                  The next CMake debugging level would be:

                  --trace-expand --trace-redirect=cmake-trace.log
                  

                  Do this for:

                  1. command line build
                  2. Qt Creator build

                  Qt Creator should work in the same way as from command line.

                  Also worth pointing out this blog article https://www.qt.io/blog/conan-package-manager-pilot-to-end-in-december

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    Matte86
                    wrote on last edited by
                    #9

                    Oh, that's sad news! I was so excited when I read Qt was adopting conan, I think it has great potential. Thanks @cristian-adam for the hints, I'll keep playing around.

                    1 Reply Last reply
                    0

                    • Login

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • Users
                    • Groups
                    • Search
                    • Get Qt Extensions
                    • Unsolved