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.cmakeAdd 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.