From af3a288e55c2dd9a581b921a9a9f9caf6500e4da Mon Sep 17 00:00:00 2001 From: Alex Neundorf Date: Sat, 8 May 2010 10:36:42 +0200 Subject: [PATCH] -add QUIET keyword to pkgconfig macros Synced from KDE svn: pkg_check_modules() and pkg_search_module() now both support a QUIET keyword. When given, no messages will be printed (except the REQUIRED ones) This also fixes #10469 (confusing output of FindLibXml2.cmake) Alex --- Modules/FindLibXml2.cmake | 2 +- Modules/FindPkgConfig.cmake | 27 +++++++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Modules/FindLibXml2.cmake b/Modules/FindLibXml2.cmake index e18dc2e921..67db32122b 100644 --- a/Modules/FindLibXml2.cmake +++ b/Modules/FindLibXml2.cmake @@ -24,7 +24,7 @@ # use pkg-config to get the directories and then use these values # in the FIND_PATH() and FIND_LIBRARY() calls FIND_PACKAGE(PkgConfig) -PKG_CHECK_MODULES(PC_LIBXML libxml-2.0) +PKG_CHECK_MODULES(PC_LIBXML libxml-2.0 QUIET) SET(LIBXML2_DEFINITIONS ${PC_LIBXML_CFLAGS_OTHER}) FIND_PATH(LIBXML2_INCLUDE_DIR NAMES libxml/xpath.h diff --git a/Modules/FindPkgConfig.cmake b/Modules/FindPkgConfig.cmake index 6e6b802dd8..3cbb7af76f 100644 --- a/Modules/FindPkgConfig.cmake +++ b/Modules/FindPkgConfig.cmake @@ -1,15 +1,17 @@ # - a pkg-config module for CMake # # Usage: -# pkg_check_modules( [REQUIRED] []*) +# pkg_check_modules( [REQUIRED] [QUIET] []*) # checks for all the given modules # -# pkg_search_module( [REQUIRED] []*) +# pkg_search_module( [REQUIRED] [QUIET] []*) # checks for given modules and uses the first working one # # When the 'REQUIRED' argument was set, macros will fail with an error # when module(s) could not be found # +# When the 'QUIET' argument is set, no status messages will be printed. +# # It sets the following variables: # PKG_CONFIG_FOUND ... true if pkg-config works on the system # PKG_CONFIG_EXECUTABLE ... pathname of the pkg-config program @@ -138,17 +140,22 @@ macro(_pkgconfig_invoke_dyn _pkglist _prefix _varname cleanup_regexp) endmacro(_pkgconfig_invoke_dyn) # Splits given arguments into options and a package list -macro(_pkgconfig_parse_options _result _is_req) +macro(_pkgconfig_parse_options _result _is_req _is_silent) set(${_is_req} 0) + set(${_is_silent} 0) foreach(_pkg ${ARGN}) if (_pkg STREQUAL "REQUIRED") set(${_is_req} 1) endif (_pkg STREQUAL "REQUIRED") + if (_pkg STREQUAL "QUIET") + set(${_is_silent} 1) + endif (_pkg STREQUAL "QUIET") endforeach(_pkg ${ARGN}) set(${_result} ${ARGN}) list(REMOVE_ITEM ${_result} "REQUIRED") + list(REMOVE_ITEM ${_result} "QUIET") endmacro(_pkgconfig_parse_options) ### @@ -279,7 +286,9 @@ macro(_pkg_check_modules_internal _is_required _is_silent _prefix) _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" INCLUDEDIR "" --variable=includedir ) _pkgconfig_invoke(${_pkg_check_modules_pkg} "${_pkg_check_prefix}" LIBDIR "" --variable=libdir ) - message(STATUS " found ${_pkg_check_modules_pkg}, version ${_pkgconfig_VERSION}") + if (NOT ${_is_silent}) + message(STATUS " found ${_pkg_check_modules_pkg}, version ${_pkgconfig_VERSION}") + endif (NOT ${_is_silent}) endforeach(_pkg_check_modules_pkg) # set variables which are combined for multiple modules @@ -307,8 +316,8 @@ endmacro(_pkg_check_modules_internal) macro(pkg_check_modules _prefix _module0) # check cached value if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) - _pkgconfig_parse_options (_pkg_modules _pkg_is_required "${_module0}" ${ARGN}) - _pkg_check_modules_internal("${_pkg_is_required}" 0 "${_prefix}" ${_pkg_modules}) + _pkgconfig_parse_options (_pkg_modules _pkg_is_required _pkg_is_silent "${_module0}" ${ARGN}) + _pkg_check_modules_internal("${_pkg_is_required}" "${_pkg_is_silent}" "${_prefix}" ${_pkg_modules}) _pkgconfig_set(__pkg_config_checked_${_prefix} ${PKG_CONFIG_VERSION}) endif(NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) @@ -319,9 +328,11 @@ macro(pkg_search_module _prefix _module0) # check cached value if (NOT DEFINED __pkg_config_checked_${_prefix} OR __pkg_config_checked_${_prefix} LESS ${PKG_CONFIG_VERSION} OR NOT ${_prefix}_FOUND) set(_pkg_modules_found 0) - _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required "${_module0}" ${ARGN}) + _pkgconfig_parse_options(_pkg_modules_alt _pkg_is_required _pkg_is_silent "${_module0}" ${ARGN}) - message(STATUS "checking for one of the modules '${_pkg_modules_alt}'") + if (NOT ${_pkg_is_silent}) + message(STATUS "checking for one of the modules '${_pkg_modules_alt}'") + endif (NOT ${_pkg_is_silent}) # iterate through all modules and stop at the first working one. foreach(_pkg_alt ${_pkg_modules_alt})