Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

(How) can I suppress the warning that a package configuration file was not found?

Tags:

cmake

qt

qt5

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.

like image 401
Tim Meyer Avatar asked Mar 19 '23 08:03

Tim Meyer


1 Answers

In order to suppress the warning, the QUIET keyword can be used:

find_package(Qt5 COMPONENTS Core Xml Network QUIET)
like image 112
Tim Meyer Avatar answered Apr 03 '23 22:04

Tim Meyer