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

Rolf Eike Beer eike at sf-mail.de
Fri Jul 27 13:26:46 EDT 2012


Philipp Berger wrote:
> I tried to incorporate all hints.
> This is my new and better version of FindPantheios.cmake.
> Once again, please *review it* and give comments :)
> 
> See attached file.
> 
> A few Debug message() calls are still included, just ignore them for now.

The module is, ehm, lengthy. Like your mail ;)

-the debug/optimized stuff can be handled through 
SelectLibraryConfiguration.cmake

-I see much stuff that looks very much the same, e.g. the loop on line 572 and 
the one on 596. Maybe you can wrap parts of that in a macro.

Hint: this works:

set(lr BACKEND_R)
find_library(PATHEIOS_${t}_$PANTHEIOS_${lr}}_...)

-say I have a gcc47, but your module will not work with it. I wonder why not 
just set(_P_COMP_TAG gcc${GCC_MAJOR}${GCC_MINOR}) and just let the user live 
with it when the libraries matching his compiler are not found.

Also I wonder if a gcc45 library can't be used together with e.g. gcc46? Those 
gcc stuff is usually compatible, at least in one direction.

-for the component selection you can probably save a lot of lines if you do 
things like this:

elseif (component STREQUAL "Null" OR
		component STREQUAL "Speech" OR
		component STREQUAL "Syslog")
	message(STATUS "Pantheios: Setting BackEnd to ${component}")
	string(TOLOWER "${component}" PANTHEIOS_BACKEND)

Since you have many such cases that are similar to each other you can make 
things much less lengthy. This is a programming language, you don't copy code, 
you introduce functions and macros to deal with it ;)

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/20120727/03b3d9e8/attachment.pgp>


More information about the CMake mailing list