Choosing whether a dependency is optional or required.

Raphael Kubo da Costa kubito at gmail.com
Sat Jan 29 14:32:01 CET 2011


Hey there,

I've recently committed a patch to Kopete's Yahoo! protocol that makes
libjasper required when the protocol is built.

As I can see, the other Kopete protocols usually check for their
dependencies in the top-level CMakeLists.txt with

  macro_optional_find_package(Foo)
  macro_log_feature(... FALSE ...) # FALSE for the required parameter

and then, in protocols/CMakeLists.txt they do something along these
lines:

  if (WITH_someprotocol AND FOO_FOUND)
    add_subdirectory(someprotocol)
  else (WITH_someprotocol AND FOO_FOUND)
    message(STATUS "Not building someprotocol")
  endif (WITH_someprotocol AND FOO_FOUND)

The "Not building" messages are shown right before the list of optional
and required dependencies which have been found/not found, and Foo is
shown as an optional dependency which could not be found.

On the other hand, in the patch I've applied the checking is done
differently:

  # protocols/CMakeLists.txt
  if (WITH_someprotocol)
    add_subdirectory(someprotocol)
  endif (WITH_someprotocol)

  # protocols/someprotocol/CMakeLists.txt
  find_package(Foo)
  macro_optional_find_package(... TRUE ...)

So Foo is listed as a required dependency when the protocol is built.

In the end, what's the way to go here with regards to considering these
protocol dependencies required or optional? And is find_package
preferred here in case we make the dependency required?


More information about the Kde-buildsystem mailing list