[CMake] /usr/lib/path/to/libmyfancylib.a -> -Wl, -Bstatic -lmyfancylb -Wl, -Bdynamic

Roland Schulz roland at utk.edu
Sat Jun 22 03:09:55 EDT 2013


On Sat, Jun 22, 2013 at 2:35 AM, Nico Schlömer <nico.schloemer at gmail.com> wrote:
>> Why does that not help?
>
> Can I set LINK_SEARCH_{START,END}_STATIC like
>
> cmake \
>   -D LINK_SEARCH_START_STATIC:BOOL=ON \
>   -D LINK_SEARCH_END_STATIC:BOOL=ON \
>   ../source
>
> ?
> That would help indeed. I was under the impression that I'd have to maintain
> a patch to insert those as properties for every target of the software
> project (I large library).

No you cannot set target properties like that. But target properties
are not per source file but per target. So if you have one large
library you only need to change it for the one "add_library". If you
have several libraries you need to set it for each but a
loop/marco/function/variable-expansion can make it so that you don't
need to replicate code.

Roland

>
> --Nico
>
>
> On Sat, Jun 22, 2013 at 6:03 AM, Roland Schulz <roland at utk.edu> wrote:
>>
>> On Fri, Jun 21, 2013 at 3:52 PM, Nico Schlömer <nico.schloemer at gmail.com>
>> wrote:
>> >> It explains, why the library names are cutted,
>> >
>> > Why? Everything that can be found automatically by the compiler is
>> > transformed from
>> >
>> > /path/to/libmylib.a
>> >
>> > to
>> >
>> > (-Wl,-Bstatic) -lmylib (-Wl,-Bdynamic)
>> > ?
>> > That's what I would like to avoid (the -Wl add-ons anyway).
>> >
>> > About "choosing" static vs. dynamic, I found
>> >
>> > http://www.cmake.org/cmake/help/cmake2.6docs.html#prop_tgt:LINK_SEARCH_END_STATIC
>> > -- no idea if this is still up-to-date. It doesn't help me much anyways
>> > since this is a fixed property of the target.
>> Why does that not help? What's the problem problem with the -Wl
>> options if you can choose what is used for the remaining libraries?
>> Together with LINK_SEARCH_START_STATIC you can configure your build as
>> if there were no -Wl options.
>>
>> Roland
>>
>> >
>> > --Nico
>> >
>> >
>> >
>> >
>> > On Fri, Jun 21, 2013 at 8:47 PM, Andreas Naumann
>> > <Andreas-Naumann at gmx.net>
>> > wrote:
>> >>
>> >> It explains, why the library names are cutted, but it does not explain,
>> >> why cmake sometimes chooses static and sometimes dynamic libaries. It
>> >> should
>> >> consequently set static for each library in the given list.
>> >>
>> >> Andreas
>> >>
>> >>
>> >> On 21.06.2013 20:34, Nico Schlömer wrote:
>> >>>
>> >>> That's true indeed: The compiler is able to find netcdf by itself.
>> >>> Something like
>> >>>
>> >>> $ cc test.o -lnetcdf
>> >>>
>> >>> doesn't fail on the machine that I'm working on. I don't understand
>> >>> why
>> >>> it would do the translation there though.
>> >>>
>> >>> --Nico
>> >>>
>> >>
>> >> --
>> >>
>> >> 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
>> >
>> >
>>
>>
>>
>> --
>> ORNL/UT Center for Molecular Biophysics cmb.ornl.gov
>> 865-241-1537, ORNL PO BOX 2008 MS6309
>
>



-- 
ORNL/UT Center for Molecular Biophysics cmb.ornl.gov
865-241-1537, ORNL PO BOX 2008 MS6309


More information about the CMake mailing list