Marcel Loose wrote:

I sent this mail more than a week ago, but got no answers.

Hi all,

I've been searching the documentation, but couldn't find a way to
specify that I want to create a statically linked binary. The only
platform-specific and even compiler-specific answer I could find was to
add "-static" to CMAKE_EXE_LINKER_FLAGS.

Now this solves only part of the problem. Suppose I want to link against
the static library of some 3rd party package Foo. Suppose that Foo only
supplies a (but I'm unaware of this fact).

When I search for the foo-library using find_library(foo_library foo) I
find a match, so CMake happily trods on. But when I type 'make', I'll
discover to my dismay that the system cannot create a  statically linked
executable, because it cannot find libfoo.a. Bummer!

So my question is twofold:

1) Is there a generic platform- and compiler-independent way to specify
that you want to create a statically linked executable?

2) How can I persuade find_library() to only search for static

You can't.


Bill Hoffman
Kitware, Inc.
28 Corporate Drive
Clifton Park, NY 12065
518 881-4905 (Direct)
518 371-3971 x105
Fax (518) 371-4573
Powered by

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