Search code examples
c++qtcmakeqt6

Failed to find Qt component "Widgets" config file at ""


I'm setting up a new computer as development machine and working with cmake that worked just fine on another computer.

I have installed Qt6 to my home directory, whereas on the old computer, it was installed into the /opt directory.

Here is what CMakeLists.txt file looks like:

 set(Qt_DIR "~/Qt/6.1.2/gcc_64/lib/cmake/")
 set(Qt_version 6)
 ...
 find_package(Qt${Qt_version} COMPONENTS Core Widgets   REQUIRED) 

That fails with following error message:

CMake Error at GUI/CMakeLists.txt:72 (find_package):
  Found package configuration file:

    /home/menkaur/Qt/6.1.2/gcc_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 "Widgets" config file at ""

The file ~/Qt/6.1.2/gcc_64/lib/cmake/Qt6Widgets/Qt6WidgetsConfig.cmake does exist

Is there some additional configuration that I'm supposed to have had done?


Solution

  • The Trolltech installer does not check for dependencies during installation, instead the dependencies are checked in find_package(qt_module). And if the dependencies are not found, then find_package(qt_module) will fail without error messages. Thus, you should make sure that the system has all the required development libraries.