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. Installed Qt6 to Linux ... cmake ... Target "Qt6::Core" was not found
Forum Updated to NodeBB v4.3 + New Features

Installed Qt6 to Linux ... cmake ... Target "Qt6::Core" was not found

Scheduled Pinned Locked Moved Solved Installation and Deployment
6 Posts 5 Posters 19.4k 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.
  • J Offline
    J Offline
    Joachim W
    wrote on last edited by
    #1

    Ran qt-unified-linux-x64-4.2.0-online.run to install Qt6 to /usr/local/Qt6.

    Set Qt6_DIR to /usr/local/Qt6/6.2.3/gcc_64/.

    Updated my CMake scripts, replacing all occurences of Qt5 by Qt6.

    Running cmake. Fails at line

    find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
    

    with error message

    -- Could NOT find Qt6CoreTools (missing: Qt6CoreTools_DIR)
    CMake Warning at /usr/local/Qt6/6.2.3/gcc_64/lib/cmake/Qt6/Qt6Config.cmake:177 (find_package):
      Found package configuration file:
    
        /usr/local/Qt6/6.2.3/gcc_64/lib/cmake/Qt6Core/Qt6CoreConfig.cmake
    
      but it set Qt6Core_FOUND to FALSE so package "Qt6Core" is considered to be
      NOT FOUND.  Reason given by package:
    
      Target "Qt6::Core" was not found.
    
    Call Stack (most recent call first):
      CMakeLists.txt:52 (find_package)
    

    and similar messages for components Gui and Widgets.

    1 Reply Last reply
    2
    • A Offline
      A Offline
      AlQuemist
      wrote on last edited by
      #4

      Assuming that Qt6 is installed in /usr/local/opt/Qt/6.2.3, the following method succeeds to find Qt6 and its required components:

      • CMakeLists.txt:
      cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
      project(testQt6)
      set(CMAKE_CXX_STANDARD 17)
      find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
      
      • CMake command:
      cmake -B build -DCMAKE_PREFIX_PATH="/usr/local/Qt/6.2.3/gcc_64/lib/cmake"
      

      Tested with CMake 3.22 and Qt 6.2.3 with 'Desktop gcc 64-bit' component installed, on Linux/Debian 11.

      1 Reply Last reply
      1
      • kkoehneK Offline
        kkoehneK Offline
        kkoehne
        Moderators
        wrote on last edited by
        #2

        This looks dubious. Does that also reproduce with a minimal example, or when configuring an example from Qt?

        Director R&D, The Qt Company

        1 Reply Last reply
        0
        • J Offline
          J Offline
          Joachim W
          wrote on last edited by Joachim W
          #3

          Confirm with minimal example:

          $ cat CMakeLists.txt
          
          cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
          
          project(libFooBar)
          
          set(CMAKE_CXX_STANDARD 17)
          
          find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
          
          $ export Qt6_DIR=/usr/local/Qt6/6.2.3/gcc_64/
          
          $ cmake .
          -- The C compiler identification is GNU 11.2.0
          -- The CXX compiler identification is GNU 11.2.0
          -- Detecting C compiler ABI info
          -- Detecting C compiler ABI info - done
          -- Check for working C compiler: /usr/lib/ccache/cc - skipped
          -- Detecting C compile features
          -- Detecting C compile features - done
          -- Detecting CXX compiler ABI info
          -- Detecting CXX compiler ABI info - done
          -- Check for working CXX compiler: /usr/lib/ccache/c++ - skipped
          -- Detecting CXX compile features
          -- Detecting CXX compile features - done
          -- Looking for pthread.h
          -- Looking for pthread.h - found
          -- Performing Test CMAKE_HAVE_LIBC_PTHREAD
          -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
          -- Check if compiler accepts -pthread
          -- Check if compiler accepts -pthread - yes
          -- Found Threads: TRUE  
          -- Performing Test HAVE_STDATOMIC
          -- Performing Test HAVE_STDATOMIC - Success
          -- Found WrapAtomic: TRUE  
          -- Could NOT find Qt6CoreTools (missing: Qt6CoreTools_DIR)
          CMake Warning at /usr/local/Qt6/6.2.3/gcc_64/lib/cmake/Qt6/Qt6Config.cmake:177 (find_package):
            Found package configuration file:
          
              /usr/local/Qt6/6.2.3/gcc_64/lib/cmake/Qt6Core/Qt6CoreConfig.cmake
          
            but it set Qt6Core_FOUND to FALSE so package "Qt6Core" is considered to be
            NOT FOUND.  Reason given by package:
          
            Target "Qt6::Core" was not found.
          
          Call Stack (most recent call first):
            CMakeLists.txt:7 (find_package)
          
          
          -- Found OpenGL: /usr/lib/x86_64-linux-gnu/libOpenGL.so   
          -- Found WrapOpenGL: TRUE  
          -- Could NOT find XKB (missing: XKB_LIBRARY XKB_INCLUDE_DIR) (Required is at least version "0.5.0")
          -- Found WrapVulkanHeaders: /usr/include  
          -- Could NOT find Qt6GuiTools (missing: Qt6GuiTools_DIR)
          ...
          

          (corrected; previous version had CMake output obtained with other Qt6_DIR)

          1 Reply Last reply
          0
          • A Offline
            A Offline
            AlQuemist
            wrote on last edited by
            #4

            Assuming that Qt6 is installed in /usr/local/opt/Qt/6.2.3, the following method succeeds to find Qt6 and its required components:

            • CMakeLists.txt:
            cmake_minimum_required(VERSION 3.15 FATAL_ERROR)
            project(testQt6)
            set(CMAKE_CXX_STANDARD 17)
            find_package(Qt6 REQUIRED COMPONENTS Core Gui Widgets)
            
            • CMake command:
            cmake -B build -DCMAKE_PREFIX_PATH="/usr/local/Qt/6.2.3/gcc_64/lib/cmake"
            

            Tested with CMake 3.22 and Qt 6.2.3 with 'Desktop gcc 64-bit' component installed, on Linux/Debian 11.

            1 Reply Last reply
            1
            • H Offline
              H Offline
              Harlock21
              wrote on last edited by
              #5

              I am using the latest cmake 3.24.0 rc2 , qt 6.3.1 and can confirm that the issue still persists.
              My cmake command is:
              cmake .. -DCMAKE_PREFIX_PATH=/home/michal/Qt/6.3.1/gcc_64/lib/cmake/Qt6

              Is there any solution for that? can it be the cmake rc ?

              1 Reply Last reply
              0
              • C Offline
                C Offline
                Croitor Alexandru
                wrote on last edited by
                #6

                Finding Qt just by setting Qt6_DIR currently does not work.
                That is tracked in https://bugreports.qt.io/browse/QTBUG-97615 and will be fixed in a future Qt version, but only for desktop platforms.

                For cross-compiled Qt, that won't be sufficient. For details, check https://forum.qt.io/topic/137551/cmake-finds-cross-compiled-qt6-config-files-but-qt6_found-is-set-to-false/5

                1 Reply Last reply
                1

                • Login

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