Quantcast

Querying global property in FindXXX.cmake: good or bad?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Querying global property in FindXXX.cmake: good or bad?

Marcel Loose
Hi all,

I was wondering whether it is good or bad practice to query a (global)
property in a FindXXX.cmake file.

The reason I wanted to do this is, that when creating statically linked
executables you will have to link against every library that you
(indirectly) depend upon. When creating dynamically linked executables
you usually don't have to worry so much, because indirect dependencies
will be handled by the dynamic loader (assuming that the library you
directly depend upon has its run-time dependencies set up properly).

So, for example, assume I want to link against libldap. The 'ldd'
command reveals all libraries that (the dynamic library) libldap.so
depends upon. When creating a statically linked executable, I would have
to link against each and every (static) library in that list. On the
other hand, when linking dynamically, I would only have to link against
libldap.so.

Testing needlessly for the presence of all these (static) libraries
makes CMake run unnecessary slow, so I would prefer to only do this if
absolutely necessary: i.e. when creating a statically linked executable.

For this I could query the global property TARGET_SUPPORTS_SHARED_LIBS,
and have my FindXXX macro only check for all indirect dependencies when
that property is FALSE.

Good idea or bad idea?

Best regards,
Marcel Loose.


_______________________________________________
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Querying global property in FindXXX.cmake: good or bad?

Clinton Stimpson
On 07/14/2009 03:34 AM, Marcel Loose wrote:

> Hi all,
>
> I was wondering whether it is good or bad practice to query a (global)
> property in a FindXXX.cmake file.
>
> The reason I wanted to do this is, that when creating statically linked
> executables you will have to link against every library that you
> (indirectly) depend upon. When creating dynamically linked executables
> you usually don't have to worry so much, because indirect dependencies
> will be handled by the dynamic loader (assuming that the library you
> directly depend upon has its run-time dependencies set up properly).
>
> So, for example, assume I want to link against libldap. The 'ldd'
> command reveals all libraries that (the dynamic library) libldap.so
> depends upon. When creating a statically linked executable, I would have
> to link against each and every (static) library in that list. On the
> other hand, when linking dynamically, I would only have to link against
> libldap.so.
>
> Testing needlessly for the presence of all these (static) libraries
> makes CMake run unnecessary slow, so I would prefer to only do this if
> absolutely necessary: i.e. when creating a statically linked executable.
>
> For this I could query the global property TARGET_SUPPORTS_SHARED_LIBS,
> and have my FindXXX macro only check for all indirect dependencies when
> that property is FALSE.
>
> Good idea or bad idea?
>
> Best regards,
> Marcel Loose.
>
>    

Not all linkers behave that way.
There are some that require dependent shared libraries to be specified.

Clint


_______________________________________________
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
Loading...