[CMake] module style question: checking for special versions of
packages
Alexander Neundorf
a.neundorf-work at gmx.net
Thu Nov 30 16:34:25 EST 2006
Hi,
in KDE svn we have a bunch of FindXXX.cmake modules which check for the availability of some package (e.g. Samba or Cups). Additionally we have to ensure that we have a recent enough version of this package.
For Samba we check for smbc_set_context(), for Cups we check for ippDeleteAttribute().
I implemented this now for both in this way, that you have to set some variable to TRUE (SAMBA_REQUIRE_SMBC_SET_CONTEXT and CUPS_REQUIRE_IPP_DELETE_ATTRIBUTE) before calling find_package(). If this special variable is set to TRUE, then the find_package() call will only succeed if the package is found AND this function exists.
Do you consider this good style ?
Another option would be to define a variable in the FindFoo.cmake script like SAMBA_HAVE_SMBC_SET_CONTEXT(), but don't change SAMBA_FOUND depending on this value.
This has the disadvantage that you have to do more checking in the calling CMakeLists.txt, like this:
find_package(Samba)
if (SAMBA_FOUND AND SAMBA_HAVE_SMBC_SET_CONTEXT)
...
endif (SAMBA_FOUND AND SAMBA_HAVE_SMBC_SET_CONTEXT)
as opposed to:
set(SAMBA_REQUIRE_SMBC_SET_CONTEXT TRUE)
find_package(Samba)
#proceed as usual
if (SAMBA_FOUND)
...
endif (SAMBA_FOUND)
What do you think ?
Other ideas ?
The version number as arguments for find_package() are not yet supported, right ?
Bye
Alex
--
Der GMX SmartSurfer hilft bis zu 70% Ihrer Onlinekosten zu sparen!
Ideal für Modem und ISDN: http://www.gmx.net/de/go/smartsurfer
More information about the CMake
mailing list