(如何)我可以抑制未找到软件包配置文件的警告? [英] (How) can I suppress the warning that a package configuration file was not found?
问题描述
我正在尝试创建一个 CMakeLists.txt
文件,该文件尝试查找 Qt5
,如果失败,尝试回退到 Qt4
安装。脚本到目前为止可以运行,但是如果未安装 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.
请注意, FindQt5.cmake
由 Qt5
提供,并且仅当 Qt4 $时不可用c $ c>已安装。
Note that FindQt5.cmake
is supplied by Qt5
and will not be available if only Qt4
is installed.
基本结构如下:
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)
如果未安装(或未正确设置) Qt5
的警告消息如下:
The warning message in case Qt5
is not installed (or not set up properly) is the following:
通过不在CMAKE_MODULE_PATH中提供 FindQt5.cmake,该项目
已要求CMake查找软件包c
Qt5提供的配置文件,但是CMake找不到。
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.
找不到 Qt5提供的$ b $软件包配置文件b以下任何一个名称:
Could not find a package configuration file provided by "Qt5" with any of the following names:
Qt5Config.cmake
qt5 -config.cmake
Qt5Config.cmake
qt5-config.cmake
将 Qt5的安装前缀添加到CMAKE_PREFIX_PATH或将
Qt5_DIR设置到包含上述文件之一的目录中。 b $ b Qt5提供了单独的开发包或SDK,请确保已安装
。
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.
一种抑制此警告的方法?
我还将接受其他方法来检测是否安装了 Qt5
。
Is there a way to suppress this warning?
I'll also accept other ways to detect if Qt5
is installed or not.
推荐答案
为了消除警告,可以使用 QUIET
关键字:
In order to suppress the warning, the QUIET
keyword can be used:
find_package(Qt5 COMPONENTS Core Xml Network QUIET)
这篇关于(如何)我可以抑制未找到软件包配置文件的警告?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!