问题
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
回答1:
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
回答2:
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.
回答3:
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
回答4:
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
来源:https://stackoverflow.com/questions/38746635/how-to-solve-qt5-packages-not-found-cmake-errors-in-mac