[CMake] static libs and more

Philip Lowman philip at yhbt.com
Thu Jul 17 19:48:36 EDT 2008


On Thu, Jul 17, 2008 at 6:25 PM, Alin M Elena <alin.elena at qub.ac.uk> wrote:

>  Hi All,
>
> I do not really think is any need to test if the lib is static or dynamic.
> In real life you should already now that.
>
> Let us take as an example a package XXX we know from documentation that
> provides a static link libA.lib and a dynamic link libB.lib (windows case).
>
> i want to write a module findXXX.cmake that I can use in a find_package
> command,
>
> if I want a dynamic link i can use
>
> find_package(XXX)
>
> if I want static
>
> find_package(XXX USE_STATIC)
>
> somewhere inside I will have
>
> if (USE_STATIC)
>
> give me libA.lib
>
> else
>
> give me libB.lib
>
> endif
>
> So, in my line of thoughts there is no need to test the nature of the two
> libs. I assume their nature based on the documentation.
>

This is true, if you're willing to add the logic to every CMake module to
support this.

I think a better approach might be to start at the find_library() level and
add a USE_STATIC and USE_SHARED option to find_library() which would enforce
the selection of libraries.  This way you could list both the static and
shared form of the library name on the same FIND_LIBRARY() call and the user
would have ultimate control over which to pick without resorting to having
to add two FIND_LIBRARY calls in every module where there are now only one.

After this is done the FIND_PACKAGE interface could be modified probably
also with a USE_STATIC or USE_SHARED that would simply be passed to
FIND_LIBRARY.

Does anyone know of any other platforms that share filename extensions for
archive vs. shared libraries other than MSVC/Win32?

-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080717/3bfe6e7e/attachment.htm>


More information about the CMake mailing list