[CMake] Writing a custom Find*.cmake file for Pantheios

Rolf Eike Beer eike at sf-mail.de
Fri Jul 13 02:30:30 EDT 2012


Am Freitag, 13. Juli 2012, 02:41:50 schrieb Philipp Berger:
> Hello everybody,
> 
> I'm relatively new to CMake, but managed to learn everything I needed,
> up until now.
> For a software project in C++ we want to use Pantheios (
> http://www.pantheios.org <http://www.pantheios.org/> ) as logging framework.
> Sadly, there is no FindPantheios.cmake file readily available, so I set of
> to write my own.
> 
> The part for searching the include files/path was easy.
> 
> The big problem I am facing and find myself unable to solve is the wide
> variety of library files.
> The amount of available lib files is huge, see the attached file for the
> list.
> 
> For example, the core libs:
> pantheios.1.core.vc10.x64.dll.debug.lib
> pantheios.1.core.vc10.x64.dll.lib
> pantheios.1.core.vc10.x64.mt.debug.lib
> pantheios.1.core.vc10.x64.mt.lib
> pantheios.1.core.vc10.x64.widestring.dll.debug.lib
> pantheios.1.core.vc10.x64.widestring.dll.lib
> pantheios.1.core.vc10.x64.widestring.mt.debug.lib
> pantheios.1.core.vc10.x64.widestring.mt.lib
> 
> I would like to have a checkbox to select Widestring capability yes/no.
> 
> A main problem for me is to check that the selected libs are valid for
> the current configuration (if VC10 x64 was selected as compiler, only
> allow vc10.x64 libs) - is there a way to securely achieve that? Or
> should I rather let the user select arbitrary lib files and hope that
> they will work?
> 
> What I need is six fields for the user to select lib files - the core
> lib, one frontend and a backend. And that for both Debug and Release. It
> would be much more useful if the user could select from a dropdown menu
> which Front-/Backend he would like together with the Widestring checkbox
> and the CMake file would assign the required Debug and Release libs to
> the variables, but as sated above, I do not know how to produce the
> required version string and how to create such mechanisms in CMake in
> general.

The debug/release stuff can be handled by CMake, just put both of them in the 
result variable prefixed with "debug" and "optimized". See what I've done 
recently in e.g. FindBZip2.cmake.

I would put the backends in the COMPONENTS section, as well as the widestring, 
so you could do something like this:

find_package(Pantheios COMPONENTS SomeBackend WideString)

Choose one backend as default for the case the user does not select any and 
raise an error if more than one is specified (unless that actually makes sense, 
dunno).

Eike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120713/1e300260/attachment.pgp>


More information about the CMake mailing list