10

I'm running in visual studio code the following message occurs when building cmake

By not providing "FindQt5.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "Qt5", but CMake did not find one.

Could not find a package configuration file provided by "Qt5" with any of the following names:

Qt5Config.cmake
qt5-config.cmake

Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR" to a directory containing one of the above files. If "Qt5" provides a separate development package or SDK, be sure it has been installed.

enter image description here enter image description here

drescherjm
  • 10,365
  • 5
  • 44
  • 64
MarcosApps
  • 414
  • 2
  • 4
  • 15
  • You need to point QT_DIR to QTfolder\qtbase\lib\cmake – drescherjm Jan 05 '20 at 14:56
  • I'm starting now in the business how can I do this? analyze my CmakeList.txt that I separated in photos – MarcosApps Jan 05 '20 at 15:01
  • The bug is not in your CMakeLists.txt. That looks fine. – drescherjm Jan 05 '20 at 15:02
  • 2
    ***Add the installation prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR" to a directory containing one of the above files.*** Is the solution. Although if you are using the builtin CMake support in Visual Studio I am not sure how to change this CMake variable. I use CMake externally from Visual Studio for the last 12 years. – drescherjm Jan 05 '20 at 15:05
  • cmake -DCMAKE_PREFIX_PATH = / your / path or would be inside CMakeLIsts.txt on set ? – MarcosApps Jan 05 '20 at 16:07
  • You can and should set this external to your `CMakeList.txt` meaning you should not modify your `CMakeLists.txt` file to add paths that are specific to your current PC setup. The main point of using CMake is to make scripts to generate projects that work regardless of the machine or even OS involved. – drescherjm Jan 05 '20 at 17:00
  • If you are using `CMake` directly I recommend using cmake-gui. – drescherjm Jan 05 '20 at 17:01
  • got it now friend, thanks – MarcosApps Jan 05 '20 at 18:01

1 Answers1

6
sudo apt-get install qtbase5-dev
sudo apt-get install qtdeclarative5-dev

I installed the 2 gt package and added the add prefix of "Qt5" to CMAKE_PREFIX_PATH or set "Qt5_DIR" to a directory containing one of the above files. mentioned in comment above @drescherjm

cmake build normally

MarcosApps
  • 414
  • 2
  • 4
  • 15
  • 1
    your title is *CMake configure fails to find Qt5 on **windows*** but do you use apt-get from linux/ubuntu? I find it confusing. – eyllanesc Jan 05 '20 at 19:14
  • the title was edited by someone, too I find confusing, adjusted – MarcosApps Jan 05 '20 at 19:16
  • 1
    I am sorry about that. The question mentioned `Visual Studio` which I assumed was windows (although an OSX version exists). `Visual Studio Code` is the free cross platform IDE. – drescherjm Jan 05 '20 at 21:06