[CMake] Writing a custom Find*.cmake file for Pantheios
Philipp Berger
newsletters at philippberger.de
Fri Jul 27 17:56:07 EDT 2012
Am 27.07.2012 19:26, schrieb Rolf Eike Beer:
> 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
Thanks for the tip, as I am new to this, I do not know about all those
helpful macros.
But in this case I am not sure what advantage this one would give me.
How am I supposed to use it? One call per component or one for the whole?
In the current scenario, I require all debug _and_ release versions to
be available, so choosing between those is unnecessary.
Additionally, from what it looks like the macro only writes "optimized"
and "debug" *ONCE*, not once for each file in _LIBRARIES. As you pointed
out earlier, that does not (should not) work.
>
> -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}}_...)
I know, I know. I needed a lot of playing around and experimentation
with the (weird) CMake Syntax. Also I wanted a fully functional result
as soon as possible, not some easy to maintain masterpiece ;) But of
course I will try to refactor it.
>
> -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.
Well... I just read through the original makefiles and "copied" them.
Your solution is much simpler and more flexible - bought.
>
> -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 ;)
(See earlier comment, refactoring is due soon)
>
> Eike
>
>
> --
>
> Powered by www.kitware.com
>
> Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html
>
> Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ
>
> Follow this link to subscribe/unsubscribe:
> http://www.cmake.org/mailman/listinfo/cmake
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20120727/eec69d16/attachment.htm>
More information about the CMake
mailing list