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.

-- 
David Jarvie.
KAlarm author and maintainer.
http://www.astrojar.org.uk/kalarm
# This macro is identical in function and arguments to the standard cmake macro
# find_package_handle_standard_args(), except that if the package is found, it
# always outputs a "Found" message.
#
# It is intended for use in FindXXXX.cmake scripts where pkgconfig is first
# used to locate the package, and then other methods are used to locate it.
# This macro avoids user confusion by ensuring that if the script finds the
# after pkgconfig fails to find it, a 'Found' message is output following
# the pkgconfig failure message.
#
# FIND_PKGCONFIG_HANDLE_STANDARD_ARGS(PACKAGE FAIL_MESSAGE VAR1..VARn)
#   PACKAGE - the package name
#   FAIL_MESSAGE - the message output if the package has not been found
#   VAR1..VARn - one or more variables which are all true if the package has
#                been found.
#
# Copyright (c) 2009, David Jarvie <[email protected]>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

include(FindPackageHandleStandardArgs)

FUNCTION(FIND_PKGCONFIG_HANDLE_STANDARD_ARGS _PKG _FAIL_MSG _VAR1)

  set(${_PKG}_FIND_QUIETLY FALSE)
  set(_SAVE_FIND_PACKAGE_MESSAGE_DETAILS ${FIND_PACKAGE_MESSAGE_DETAILS_${_PKG}})
  set(FIND_PACKAGE_MESSAGE_DETAILS_${_PKG} "")

  find_package_handle_standard_args(${_PKG} ${_FAIL_MSG} ${_VAR1} ${ARGN})

  if(NOT ${FIND_PACKAGE_MESSAGE_DETAILS_${_PKG}})
    set(FIND_PACKAGE_MESSAGE_DETAILS_${_PKG} ${_SAVE_FIND_PACKAGE_MESSAGE_DETAILS})
  endif(NOT ${FIND_PACKAGE_MESSAGE_DETAILS_${_PKG}})

ENDFUNCTION(FIND_PKGCONFIG_HANDLE_STANDARD_ARGS)
_______________________________________________
Kde-buildsystem mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kde-buildsystem

Reply via email to