Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-97615

CMake cannot find packages when only Qt6_DIR and not CMAKE_PREFIX_PATH is set

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P3: Somewhat important
    • None
    • 6.2.0
    • Build System: CMake
    • None
    • Windows

    Description

      I try to use Qt6 with CMake, but I have to manually give paths to each Component "Tools"

      My minimal repro is the following CMake

      cmake_minimum_required(VERSION 3.19)
      project(couldNotFindTools)
      find_package(Qt6 COMPONENTS Core REQUIRED)

      When executing cmake (3.19.1) I get the following:

       

      E:\work\couldNotFindTools\build>cmake -D Qt6_DIR="e:/Qt/6.2.0/msvc2019_64/lib/cmake/Qt6" ..
      -- Building for: Visual Studio 16 2019
      -- Selecting Windows SDK version 10.0.18362.0 to target Windows 10.0.19043.
      -- The C compiler identification is MSVC 19.29.30037.0
      -- The CXX compiler identification is MSVC 19.29.30037.0
      -- Detecting C compiler ABI info
      -- Detecting C compiler ABI info - done
      -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64/cl.exe - 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: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30037/bin/Hostx64/x64/cl.exe - skipped
      -- Detecting CXX compile features
      -- Detecting CXX compile features - done
      -- Looking for pthread.h
      -- Looking for pthread.h - not found
      -- Found Threads: TRUE
      -- Check if linker can resolve circular dependencies - TRUE
      -- Performing Test HAVE_STDATOMIC
      -- Performing Test HAVE_STDATOMIC - Success
      -- Found WrapAtomic: TRUE
      -- Could NOT find Qt6CoreTools (missing: Qt6CoreTools_DIR)
      CMake Warning at E:/Qt/6.2.0/msvc2019_64/lib/cmake/Qt6/Qt6Config.cmake:176 (find_package):
      {{ Found package configuration file:}}

      E:/Qt/6.2.0/msvc2019_64/lib/cmake/Qt6Core/Qt6CoreConfig.cmake

      but it set Qt6Core_FOUND to FALSE so package "Qt6Core" is considered to be
        NOT FOUND.
      Call Stack (most recent call first):
        CMakeLists.txt:3 (find_package)

      CMake Error at CMakeLists.txt:3 (find_package):
      Found package configuration file:

      e:/Qt/6.2.0/msvc2019_64/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 "Core".

      Expected Config file at
      "E:/Qt/6.2.0/msvc2019_64/lib/cmake/Qt6Core/Qt6CoreConfig.cmake" exists

      -- Configuring incomplete, errors occurred!
      See also "E:/work/couldNotFindTools/build/CMakeFiles/CMakeOutput.log".
      See also "E:/work/couldNotFindTools/build/CMakeFiles/CMakeError.log".

       

      It runs as expected if I add -D Qt6CoreTools_DIR="e:/Qt/6.2.0/msvc2019_64/lib/cmake/Qt6CoreTools"

       

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              alexandru.croitor Alexandru Croitor
              vivien delmon Vivien Delmon
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes