On Mon 9 March 2009 23:32:48 Alexander Neundorf wrote:
> On Tuesday 10 March 2009, David Jarvie wrote:
> > Currently, FindXXXX.cmake scripts often use pkgconfig to attempt to find
> > a package, followed by other code which may locate it even if pkgconfig
> > failed. See for example FindQImageBlitz.cmake. The way these scripts are
> > currently coded produces misleading output when they are run, when
> > pkgconfig fails to find the package but it is nevertheless found by the
> > subsequent code in the script. In the QImageBlitz example, the console
> > output is:
> >
> > -- checking for module 'qimageblitz'
> > -- package 'qimageblitz' not found
> >
> > even if the package is actually found after pkgconfig fails to find it.
> > This can lead to significant time wasting trying to work out what has
> > gone wrong when in fact nothing is wrong at all.
> >
> > I propose a new function to replace the call to
> > find_package_handle_standard_args() in these scripts. This function would
> > always output a 'Found' message, thereby ensuring that the user is not
> > left under the impression that a package which actually exists on the
> > system has not been found by cmake. The messages in the example would
> > then be:
> >
> > -- checking for module 'qimageblitz'
> > -- package 'qimageblitz' not found
> > -- Found QImageBlitz: /opt/kde4.2/include/qimageblitz
> >
> > The new function is attached. If agreed that this can be committed, I'll
> > prepare a patch to modify the relevant FindXXXX.cmake scripts to use it.
>
> In general find_package_handle_standard_args() prints the "Found" message
> only if the message changed. This is what is disabled by your macro, but
> its name suggests that it's related to pkg-config, which it is not
> directly.
>
> But I think a much better way to do this is to modify FindPkgConfig.cmake
> so that the "package foo not found" message doesn't appear. This message is
> not necessary because we have our own success message anyway at the end.
> The message from FindPkgConfig.cmake could be optionally disabled e.g. via
> an additional argument to pkg_check_modules() or (easier) via a
> PKG_CONFIG_QUIET (or something like this) variable.
>
> It's no (real) problem to add a copy of FindPkgConfig.cmake again to
> kdelibs/cmake/modules/.
OK, here's a patch to FindPkgConfig.cmake (from cmake 2.6.2) to provide a
QUIET option for pkg_check_modules(). For example,
pkg_check_modules(PC_QIMAGEBLITZ QUIET qimageblitz)
OK to commit to kdelibs/cmake/modules? If so, I'll do a patch to convert the
relevant FindXXXX.cmake files.
--
David Jarvie.
KAlarm author and maintainer.
http://www.astrojar.org.uk/kalarm
--- /usr/share/cmake-2.6/Modules/FindPkgConfig.cmake 2008-09-24 19:34:34.000000000 +0100
+++ ./FindPkgConfig.cmake 2009-03-10 00:24:10.000000000 +0000
@@ -1,7 +1,7 @@
# - a pkg-config module for CMake
#
# Usage:
-# pkg_check_modules(<PREFIX> [REQUIRED] <MODULE> [<MODULE>]*)
+# pkg_check_modules(<PREFIX> [REQUIRED] [QUIET] <MODULE> [<MODULE>]*)
# checks for all the given modules
#
# pkg_search_module(<PREFIX> [REQUIRED] <MODULE> [<MODULE>]*)
@@ -149,17 +149,22 @@
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)
###
@@ -318,8 +323,8 @@
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)
@@ -330,7 +335,7 @@
# 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}'")
_______________________________________________
Kde-buildsystem mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kde-buildsystem