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 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 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.
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.
Since 4.8.0 is out, I've reinstalled Qt, and now I want to use cmake too. To make cmake work, I remember having to add the mingw bin folder (QtSDK\Desktop\Qt\4.7.3) to PATH back in Qt4.7.3, so I guessed that there would be a similar folder in QtSDK\Desktop\Qt\4.8.0 now but this is not the case. My question is, does anybody else have experience with setting up Qt and cmake? I could use some help right now, as I've googled for a bit and was unable to find any ways to make cmake work.
When trying to build, I get this well known message:
CMake Error at C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:91 (MESSAGE):
Could NOT find Qt4 (missing: QT_QMAKE_EXECUTABLE QT_INCLUDE_DIR)
Call Stack (most recent call first):
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindPackageHandleStandardArgs.cmake:252 (_FPHSA_FAILURE_MESSAGE)
C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindQt4.cmake:1171 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:3 (find_package)
You just need to set the path to qmake in QT_QMAKE_EXECUTABLE, and then cmake can use qmake -query to find all the other paths it needs (similar to pkg-config on Linux).
Steps for building a project using Qt and CMake usually are:
Check out / create project source folder
Create build folder outside the project folder
Start Qt command prompt / cmd and cd into build folder e.g. cd build\project
Run cmake or cmake-gui passing path to source folder e.g. cmake-gui ..\..\source\project
Set any variables, such as QT_QMAKE_EXECUTABLE and CMAKE_BUILD_TYPE
Run your build tool, or run cmake --build .
So, I found out what was the problem, and I think I should have known before. I simply added C:\QtSDK\Desktop\Qt\4.8.0\msvc2010\bin to my PATH variable. It may be useful to note that, in a default 4.8.0 install, qmake is located in C:\QtSDK\Desktop\Qt\4.8.0\msvc2010\bin as opposed to C:\QtSDK\Desktop\Qt\4.7.3\mingw\bin in 4.7.3. Notice the difference; msvc2010 vs mingw. It's actually glaringly obvious, as msvc2010 was the only folder in that directory.
I didn't try skyhisi's answer as it was no longer needed, but I'm guessing that it's another correct (if not better) way to make cmake work.
Just ran into the same problem... Take a look into findQt4.cmake
FIND_PROGRAM(QT_QMAKE_EXECUTABLE NAMES qmake qmake4 qmake-qt4 qmake-mac PATHS
"[HKEY_CURRENT_USER\\Software\\Trolltech\\Qt3Versions\\4.0.0;InstallDir]/bin"
"[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\4.0.0;InstallDir]/bin"
"[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\${qt_install_version};InstallDir]/bin"
$ENV{QTDIR}/bin
DOC "The qmake executable for the Qt installation to use")
You can either alter registry keys, or, I personally prefer deleting all those keys altogether and modify $ENV{QTDIR} variable. Good luck.
I had this problem for a slightly different reason. Maybe this will help someone else:
I uninstalled Qt 4.8.3 and then installed qt 4.8.4. Based on Slava's answer I discovered that CMake is getting the value of $(qt_install_version} from:
[HKEY_CURRENT_USER\\Software\\Trolltech\\Versions\\DefaultVersion]
This was still set to 4.8.3 even though all the other registry entries were updated to 4.8.4. Changing the value of the DefaultVersion key to 4.8.4 fixed the problem for me.
I had the same problem and I solved providing the path to qmake,
QT_QMAKE_EXECUTABLE /opt/qt-4.8.7/bin/qmake
On Mac, while the binaries are saved in /usr/local/Trolltech/Qt-4.8.7/bin
the required qmake required as value of QT_QMAKE_EXECUTABLE is, for my OS, stored in the path /opt/qt-4.8.7/bin/qmake . Hope this help as well.