How to solve qt5 (packages not found) cmake errors in mac?

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.


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


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

Tags:

C++

Macos

Qt

Cmake

Qt5