[CMake] linking static vs dynamic

Dominik Szczerba dominik at itis.ethz.ch
Sat Feb 12 18:08:58 EST 2011


Yes, full paths seem to work fine for me.
Many thanks for your feedback!

Dominik

On Sat, Feb 12, 2011 at 11:11 PM, Michael Hertling <mhertling at online.de> wrote:
> On 02/12/2011 09:39 PM, Andreas Pakulat wrote:
>> On 12.02.11 21:20:58, Dominik Szczerba wrote:
>>> I never actually saw a solution to this problem in cmake:
>>> I need to link (independent constraint from above) with libguide.a and
>>> not libguide.so (in intel compiler, does not matter much), but both
>>> are available, and cmake always takes the shared one when given
>>> "guide" as the desired library to be linked.
>>> Is there an elegant way of static linking (other than -static passed
>>> to the linker for static linking of everything) of this particular lib
>>> other than hacking (like deleting the .so from the folder)?
>>
>> No, i.e. no elegant way. What you can do is force cmake to search only
>> for .a files by setting a cmake variable, unfortunately I don't remember
>> which one and can't easily find it right now. The archive of this list
>> has more info as well as the cmake manual or the FAQ on the cmake
>> website.
>>
>> Andreas
>
> Hi Dominik,
>
> it's CMAKE_FIND_LIBRARY_SUFFIXES; setting it to ".a" on *nix makes
> FIND_LIBRARY() search for static libraries only. It can be set to
> its original value at any time to restore the previous behaviour.
>
> However, if you know that you're looking exactly for libguide.a and
> have control over the FIND_LIBRARY() call, i.e. it's not buried in a
> find module or config file, you should follow Alexander's advice, use
> the library's full name in FIND_LIBRARY() and pass the latter's result
> to TARGET_LINK_LIBRARIES().
>
> Regards,
>
> Michael
> _______________________________________________
> 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
>
>


More information about the CMake mailing list