[CMake] -fPIC .. (help w/ SET_TARGET_PROPERTIES)

Alan W. Irwin irwin at beluga.phys.uvic.ca
Wed Sep 27 01:48:38 EDT 2006


On 2006-09-26 22:24-0600 Abe Stephens wrote:

>
> Alan W. Irwin wrote:
>> On 2006-09-26 17:06-0600 Abe Stephens wrote:
>>> When I build object files for shared library targets cmake includes the 
>>> position independent code flag (-fPIC). However when I build objects for 
>>> static library targets the flag is omitted. I try to link the static lib 
>>> to other objects in a shared library the linker chokes.
>> Could you clarify your goal here?
> Hopefully ;-)
>> Are you trying to link a static library build by CMake with a shared 
>> library
>> built by CMake?  I haven't tried that, but I assume it would work just as
>> well as the link of static library built by CMake to an external library.
> I think this is closest to what I am trying to do.
>> In sum, I don't think there is any case where you have to explicitly 
>> specify
>> -fPIC. CMake takes care of that for you.

> I understand that in general static libs don't need to be compiled with -fPIC 
> since they're supposed to be linked with executables. In my case they will 
> eventually linked when I build a certain shared library.

I don't think it matters whether the static library is linked with an
executable or a shared library.  Certainly linking to an external shared
library has worked for me recently without me having to do anything special.
Thus, I am virtually positive that linking with a shared library built by
cmake should also work without you doing anything special.

If not, then it is time for a simple cmake example demonstrating the actual
problem you are having.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the Yorick front-end to PLplot (yplot.sf.net); the
Loads of Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________


More information about the CMake mailing list