On Fri, May 8, 2009 at 10:58 AM, Marcel Loose <lo...@astron.nl> wrote:

> Hi Denis,
> There are definitely cases where you do want to create a statically
> linked executable; for example when running on a massively parallel
> diskless system -- you don't want thousands of compute nodes to load a
> shared library over some NFS link.
> Anyway, the real problem with find_library() is, when you have a shared
> library installed, but not the associated static library. In that case,
> the linker will choke while creating a statically linked executable,
> because it cannot find the library it needs.
> I guess the only way to solve this is to manually set
> CMAKE_FIND_LIBRARY_SUFFIXES, like FindBoost.cmake does. I wish there
> were a more generic, platform-independent way to do this. Maybe worth a
> feature request?

The big problem is WIN32 where static and shared/import libraries have the
same file extension so they obviously can't go in the same directory.  You
could solve the problem with keywords.  If you forced the keywords to have
actual filenames behind them it would probably make it clear to people at
first glance that they only affect WIN32.  For example:

find_library(FOO NAMES foo STATIC:foo_static.lib SHARED:foo.lib )

Then all you would need is a variable with 4 options to control the
1. prefer shared (default)
2. prefer static
3. require shared
4. require static

Philip Lowman
Powered by www.kitware.com

Visit other Kitware open-source projects at 

Please keep messages on-topic and check the CMake FAQ at: 

Follow this link to subscribe/unsubscribe:

Reply via email to