11

I get these following errors during build of a file using CMake:

CMake Warning at CMakeLists.txt:33 (FIND_PACKAGE):

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

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

    Qt5CoreConfig.cmake
    qt5core-config.cmake

Anybody know how to solve this? Thanks in advance

rocambille
  • 15,398
  • 12
  • 50
  • 68
D.vijay
  • 163
  • 1
  • 1
  • 9

4 Answers4

13

You should find the cmake packages in your Qt installation in:

<install_prefix>/lib/cmake

Assuming <install_prefix> is the root path of your installation. Set the variable Qt5_DIR to <install_prefix>/lib/cmake/Qt5 in your configuration and cmake should be able to find all the modules

rocambille
  • 15,398
  • 12
  • 50
  • 68
  • @tivadj Should work. If you're encountering issues with your project, may I suggest to post an [MCVE](https://stackoverflow.com/help/mcve) as a new question ? – rocambille Jul 19 '17 at 10:38
  • `set(Qt5Core_DIR /usr/local/opt/qt/lib/cmake/Qt5Core)` or any other package configuration *_DIR variable as needed. In my example I set it to where Homebrew installed Qt (/usr/local/opt/qt). – Paul-Sebastian Manole Jan 18 '18 at 07:38
5

Maybe, you should try to add the proper path to the CMAKE_PREFIX_PATH variable in the environment or config.

export CMAKE_PREFIX_PATH=path_to/Qt/5.9/clang_64:$CMAKE_PREFIX_PATH

Replace path_to with your real path.

Peter Petrik
  • 9,701
  • 5
  • 41
  • 65
user3857893
  • 63
  • 1
  • 5
4

One possible cause for this error message is outdated CMake code like [1]

find_package(Qt5Core REQUIRED).

Then there is a good chance for solving the problem by changing to

find_package(Qt5 COMPONENTS REQUIRED Core).

[1] http://cmake.3232098.n2.nabble.com/debugging-CMAKE-PREFIX-PATH-td7596290.html

Joachim W
  • 7,290
  • 5
  • 31
  • 59
0

in many times its enough to have the PATH environment variable correctly set, so when typing qmake in terminal, it executes the right file. Once you have it, execute cmake in the command line