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

Axel Roebel Axel.Roebel at ircam.fr
Wed Sep 27 04:42:30 EDT 2006


On Wednesday 27 September 2006 07:49, cmake-request at cmake.org wrote:
> 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.

Sorry Alan you are wrong here!
most of the Linux OS don't require the use of -fPIC for shared libraries
some do (notably x86_64 (amd)). In your case where it worked
to link a static library compiled without special means to a shared library
you most likely did that on a system which does not require the -fPIC
flag. On x86_64 this will NOT work and cmake does not take care of it
(I know because it failed for me).

> If not, then it is time for a simple cmake example demonstrating the actual
> problem you are having.
Seems clear to me! 

My solution was something similar to

in my opinion and with the experience I have (gcc only!)


should work as well.

Axel Roebel
IRCAM Analysis/Synthesis Team
Phone: ++33-1-4478 4845 | Fax: ++33-1-4478 1540

More information about the CMake mailing list