I have already installed Qt5. I get the following error when I run cmake on the build files of an application.
CMake Error at CMakeLists.txt:12 (find_package):
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.
I understand I need to specify a path. Can any 1 please help me with the exact command of what I need to write and in which file do I need to change this? I am a newbie so please answer in detail and not refer any links. I can find the location of Qt5Config.cmake.
Thanks in advance.
Related
I tried to use the QtQuickCompiler the first time, so I looked in the Qt docs. (https://doc.qt.io/QtQuickCompiler/qquickcompiler-building-with-cmake.html). But if I call find_package(Qt6QuickCompiler) it shows me,
By not providing "FindQt6QuickCompiler.cmake" in CMAKE_MODULE_PATH this
project has asked CMake to find a package configuration file provided by
"Qt6QuickCompiler", but CMake did not find one.
Could not find a package configuration file provided by "Qt6QuickCompiler"
with any of the following names:
Qt6QuickCompilerConfig.cmake
qt6quickcompiler-config.cmake
Add the installation prefix of "Qt6QuickCompiler" to CMAKE_PREFIX_PATH or
set "Qt6QuickCompiler_DIR" to a directory containing one of the above
files. If "Qt6QuickCompiler" provides a separate development package or
SDK, be sure it has been installed.
After this I searched the Qt directory, but I did not find it. Is there no QtQuickCompiler as of Qt6? Or what am I doing wrong?
I downloaded the source code from git:https://github.com/MITK/MITK, but when I tried to config the code in QT, it always shows the following issues:
/Users/cjz/CCode/MITK/CMakeLists.txt:211: error: 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" (requested version 5.6.0) 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.
I checked on the Internet and was told that I should set CMAKE_PREFIX_PATH=qtbase
since my qt was installed at "/Users/cjz/Qt5.9.2", I set CMAKE_PREFIX_PATH=/Users/cjz/Qt5.9.2
but the problem remains the same.
I also tried cmake .. -DCMAKE_PREFIX_PATH=/Users/cjz/Qt5.9/
but it did not work either.
I totoally have no idea how to adress this problem, anyone helps me? thank you.
Follow Qt documentation for installing from sources? here : General Installation Information
For Linux, Follow this guide:
Qt for Linux/X11 - Building from Source
I just recently upgraded to Qt 5.7 and I am trying to build a project that needs to find several packages. I am on a mac also recently upgraded to el capitan. I have set CMAKE_PREFIX_PATH in my .bash_profile and I have checked the environment to verify that it is correct. When I do a cmake . on the folder my project is in (previously this was how I built) it gives me several errors such as:
CMake Warning at CMakeLists.txt:79 (FIND_PACKAGE):
By not providing "FindQt5Widgets.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"Qt5Widgets", but CMake did not find one.
Could not find a package configuration file provided by "Qt5Widgets" with
any of the following names:
Qt5WidgetsConfig.cmake
qt5widgets-config.cmake
Add the installation prefix of "Qt5Widgets" to CMAKE_PREFIX_PATH or set
"Qt5Widgets_DIR" to a directory containing one of the above files. If
"Qt5Widgets" provides a separate development package or SDK, be sure it has
been installed.
However I have already verified that the path is correct and that the files do indeed exist. I have tried several variations of cmake_prefix_path, for instance:
CMAKE_PREFIX_PATH=/Users/mnicholson/Qt/5.7/clang_64/
as well as
CMAKE_PREFIX_PATH=/Users/mnicholson/Qt/5.7/clang_64/lib/cmake/
but neither seems to work despite the fact that the cmake files are there. With older versions of qt setting the path worked, however since upgrading from 5.5 to 5.6 and then to 5.7 I'm baffled... HELP!! Is this a qt5.7 problem? El capitan?
Thanks!
Try find_package PATHS option. Something like
find_package(Qt5Widgets
CONFIG
PATHS /Users/mnicholson/Qt/5.7/clang_64/lib/cmake/Qt5Widgets
NO_DEFAULT_PATH)
I'm trying to create a CMakeLists.txt file which tries finding Qt5, and if that fails, tries falling back to a Qt4 installation. The script works so far, but I'll always get a warning if Qt5 is not installed.
Note that FindQt5.cmake is supplied by Qt5 and will not be available if only Qt4 is installed.
The basic structure is like this:
cmake_minimum_required(VERSION 2.8.11)
message("-- Searching for Qt5")
find_package(Qt5 COMPONENTS Core Xml Network)
if (Qt5_FOUND)
message("-- Searching for Qt5 - found version ${Qt5Core_VERSION}")
else (Qt5_FOUND)
message("-- Searching for Qt5 - not found")
# ...
endif (Qt5_FOUND)
The warning message in case Qt5 is not installed (or not set up properly) is the following:
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.
Is there a way to suppress this warning?
I'll also accept other ways to detect if Qt5 is installed or not.
In order to suppress the warning, the QUIET keyword can be used:
find_package(Qt5 COMPONENTS Core Xml Network QUIET)
find_package has CONFIG and MODULE arguments to tell cmake how to search for the package.
http://www.cmake.org/cmake/help/v3.0/command/find_package.html
http://www.cmake.org/cmake/help/v3.0/manual/cmake-packages.7.html
Add the CONFIG keyword.
I'm trying to cmake a project which calls
find_package(Shiboken REQUIRED)
cmake complains about
CMake Error at CMakeLists.txt:5 (find_package):
By not providing "FindShiboken.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Shiboken",
but CMake did not find one.
Could not find a package configuration file provided by "Shiboken" with any
of the following names:
ShibokenConfig.cmake
shiboken-config.cmake
Add the installation prefix of "Shiboken" to CMAKE_PREFIX_PATH or set
"Shiboken_DIR" to a directory containing one of the above files. If
"Shiboken" provides a separate development package or SDK, be sure it has
been installed.
I do have Shiboken compiled and installed to C:\Program Files\shiboken. And I can see there are cmake files like ShibokenConfig.cmake, ShibokenConfig-python2.7.cmake, ShibokenConfigVersion.cmake under folder C:\Program Files\shiboken\lib\cmake\Shiboken-1.1.2
how do I let the cmake know it should search for ShibokenConfig.cmake in that folder?
One of Shiboken's contributors answered my question through email and I confirmed it's working.
The solution:
cmake .. -G"MinGW Makefiles" -DShiboken_DIR=C:\shiboken\lib\cmake\Shiboken-1.1.2
Noteļ¼ I copied C:\Program Files\shiboken to C:\shiboken because cmake complains about "C:\Program Files" (maybe caused by the space in it).