Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. How to select qt location that needs to be used while compiling a project?
Forum Updated to NodeBB v4.3 + New Features

How to select qt location that needs to be used while compiling a project?

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
4 Posts 2 Posters 1.2k Views
  • 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.
  • S Offline
    S Offline
    shome
    wrote on last edited by
    #1

    OS: ubuntu 22.04, qt6

    I installed qt6.6.2 at /usr/local/Qt6 by following instructions at https://wiki.qt.io/Building_Qt_6_from_Git.

    I also installed qt from synaptic: qt6-base-dev and qt6-base-dev-tools.

    Now I try to compile a QT/C++ project which has a CMakelists.txt.

    How do I set which qt installation to use for compiling?

    cmake seems to be always picking up the custom installation at /usr/local/Qt6 than the one installed by synaptic

    I tried the following, but It is still using custom install at /usr/local/Qt6.

    • remove custom qt6 installation from cmake search path
    list(REMOVE_ITEM CMAKE_PREFIX_PATH "/usr/local/Qt6/lib/cmake/Qt6")
    list(REMOVE_ITEM CMAKE_PREFIX_PATH "/usr/local/Qt6/lib/cmake")
    list(REMOVE_ITEM CMAKE_PREFIX_PATH "/usr/local/Qt6")
    
    

    The error message that I get is:

    CMake Warning at /usr/share/cmake-3.22/Modules/CMakeFindDependencyMacro.cmake:47 (find_package):
      Could not find a configuration file for package "Qt6CoreTools" that is compatible with requested version "6.6.2".
    
      The following configuration files were considered but not accepted:
    
        /usr/lib/x86_64-linux-gnu/cmake/Qt6CoreTools/Qt6CoreToolsConfig.cmake, version: 6.2.4
        /lib/x86_64-linux-gnu/cmake/Qt6CoreTools/Qt6CoreToolsConfig.cmake, version: 6.2.4
    
    Call Stack (most recent call first):
      /usr/local/Qt6/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsDependencies.cmake:9 (find_dependency)
      /usr/local/Qt6/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsConfig.cmake:33 (include)
      /usr/local/Qt6/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:65 (find_package)
      /usr/local/Qt6/lib/cmake/Qt6Widgets/Qt6WidgetsDependencies.cmake:34 (_qt_internal_find_tool_dependencies)
      /usr/local/Qt6/lib/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake:40 (include)
      /usr/local/Qt6/lib/cmake/Qt6/Qt6Config.cmake:164 (find_package)
      CMakeLists.txt:22 (find_package)
    
    
    CMake Warning at /usr/local/Qt6/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:65 (find_package):
      Found package configuration file:
    
        /usr/local/Qt6/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsConfig.cmake
    
      but it set Qt6WidgetsTools_FOUND to FALSE so package "Qt6WidgetsTools" is
      considered to be NOT FOUND.  Reason given by package:
    
      Qt6WidgetsTools could not be found because dependency Qt6CoreTools could
      not be found.
    
    Call Stack (most recent call first):
      /usr/local/Qt6/lib/cmake/Qt6Widgets/Qt6WidgetsDependencies.cmake:34 (_qt_internal_find_tool_dependencies)
      /usr/local/Qt6/lib/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake:40 (include)
      /usr/local/Qt6/lib/cmake/Qt6/Qt6Config.cmake:164 (find_package)
      CMakeLists.txt:22 (find_package)
    
    
    CMake Warning at /usr/local/Qt6/lib/cmake/Qt6/Qt6Config.cmake:164 (find_package):
      Found package configuration file:
    
        /usr/local/Qt6/lib/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake
    
      but it set Qt6Widgets_FOUND to FALSE so package "Qt6Widgets" is considered
      to be NOT FOUND.  Reason given by package:
    
      Qt6Widgets could not be found because dependency Qt6WidgetsTools could not
      be found.
    
    

    So all that cmake searches is the custom installation at /usr/local/Qt6

    jsulmJ 1 Reply Last reply
    0
    • S shome

      OS: ubuntu 22.04, qt6

      I installed qt6.6.2 at /usr/local/Qt6 by following instructions at https://wiki.qt.io/Building_Qt_6_from_Git.

      I also installed qt from synaptic: qt6-base-dev and qt6-base-dev-tools.

      Now I try to compile a QT/C++ project which has a CMakelists.txt.

      How do I set which qt installation to use for compiling?

      cmake seems to be always picking up the custom installation at /usr/local/Qt6 than the one installed by synaptic

      I tried the following, but It is still using custom install at /usr/local/Qt6.

      • remove custom qt6 installation from cmake search path
      list(REMOVE_ITEM CMAKE_PREFIX_PATH "/usr/local/Qt6/lib/cmake/Qt6")
      list(REMOVE_ITEM CMAKE_PREFIX_PATH "/usr/local/Qt6/lib/cmake")
      list(REMOVE_ITEM CMAKE_PREFIX_PATH "/usr/local/Qt6")
      
      

      The error message that I get is:

      CMake Warning at /usr/share/cmake-3.22/Modules/CMakeFindDependencyMacro.cmake:47 (find_package):
        Could not find a configuration file for package "Qt6CoreTools" that is compatible with requested version "6.6.2".
      
        The following configuration files were considered but not accepted:
      
          /usr/lib/x86_64-linux-gnu/cmake/Qt6CoreTools/Qt6CoreToolsConfig.cmake, version: 6.2.4
          /lib/x86_64-linux-gnu/cmake/Qt6CoreTools/Qt6CoreToolsConfig.cmake, version: 6.2.4
      
      Call Stack (most recent call first):
        /usr/local/Qt6/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsDependencies.cmake:9 (find_dependency)
        /usr/local/Qt6/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsConfig.cmake:33 (include)
        /usr/local/Qt6/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:65 (find_package)
        /usr/local/Qt6/lib/cmake/Qt6Widgets/Qt6WidgetsDependencies.cmake:34 (_qt_internal_find_tool_dependencies)
        /usr/local/Qt6/lib/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake:40 (include)
        /usr/local/Qt6/lib/cmake/Qt6/Qt6Config.cmake:164 (find_package)
        CMakeLists.txt:22 (find_package)
      
      
      CMake Warning at /usr/local/Qt6/lib/cmake/Qt6/QtPublicDependencyHelpers.cmake:65 (find_package):
        Found package configuration file:
      
          /usr/local/Qt6/lib/cmake/Qt6WidgetsTools/Qt6WidgetsToolsConfig.cmake
      
        but it set Qt6WidgetsTools_FOUND to FALSE so package "Qt6WidgetsTools" is
        considered to be NOT FOUND.  Reason given by package:
      
        Qt6WidgetsTools could not be found because dependency Qt6CoreTools could
        not be found.
      
      Call Stack (most recent call first):
        /usr/local/Qt6/lib/cmake/Qt6Widgets/Qt6WidgetsDependencies.cmake:34 (_qt_internal_find_tool_dependencies)
        /usr/local/Qt6/lib/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake:40 (include)
        /usr/local/Qt6/lib/cmake/Qt6/Qt6Config.cmake:164 (find_package)
        CMakeLists.txt:22 (find_package)
      
      
      CMake Warning at /usr/local/Qt6/lib/cmake/Qt6/Qt6Config.cmake:164 (find_package):
        Found package configuration file:
      
          /usr/local/Qt6/lib/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake
      
        but it set Qt6Widgets_FOUND to FALSE so package "Qt6Widgets" is considered
        to be NOT FOUND.  Reason given by package:
      
        Qt6Widgets could not be found because dependency Qt6WidgetsTools could not
        be found.
      
      

      So all that cmake searches is the custom installation at /usr/local/Qt6

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @shome said in How to select qt location that needs to be used while compiling a project?:

      How do I set which qt installation to use for compiling?

      By specifying the -prefix parameter, see https://doc.qt.io/qt-5/configure-options.html

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

      S 1 Reply Last reply
      0
      • jsulmJ jsulm

        @shome said in How to select qt location that needs to be used while compiling a project?:

        How do I set which qt installation to use for compiling?

        By specifying the -prefix parameter, see https://doc.qt.io/qt-5/configure-options.html

        S Offline
        S Offline
        shome
        wrote on last edited by
        #3

        @jsulm from the https://doc.qt.io/qt-5/configure-options.html:
        Screenshot from 2024-03-13 13-43-57.png

        In my understanding, configuring with the prefix option is setting the location for installation when compiling Qt from source.

        How would I use it for compiling a QT based project that has a main.cpp and CMakelists.txt? I need to modify CMakeLists.txt to be able to the select the qt6 location. ie either the one installed by synaptic or the custom Qt installed at /usr/local/Qt6

        jsulmJ 1 Reply Last reply
        0
        • S shome

          @jsulm from the https://doc.qt.io/qt-5/configure-options.html:
          Screenshot from 2024-03-13 13-43-57.png

          In my understanding, configuring with the prefix option is setting the location for installation when compiling Qt from source.

          How would I use it for compiling a QT based project that has a main.cpp and CMakelists.txt? I need to modify CMakeLists.txt to be able to the select the qt6 location. ie either the one installed by synaptic or the custom Qt installed at /usr/local/Qt6

          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @shome Ah, I misread your question.
          You need to pass -DCMAKE_PREFIX_PATH=PATH_TO_QT_CMAKE_FOLDER to your cmake call. See https://github.com/KDAB/GammaRay/issues/213

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

          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