[cmake-developers] Adding logic to CMake for -fPIE and -fPIC

Brad King brad.king at kitware.com
Fri May 25 17:03:55 EDT 2012


On 05/25/2012 04:47 PM, Stephen Kelly wrote:
> I've re-pushed to my gitorious clone.

Thanks.  I'll review when I get a chance.

>> AddPositionIndependentFlags shouldn't care whether the library is
>> shared or not, right?
> 
> My vague understanding up to now has been that static libraries should not 
> get the flag

It should be up to the project.  I might create some static libs
as dependencies of a shared lib.  When linking the shared lib it
will bring in the objects from the static libs so they should have
been built with -fPIC.  If I set POSITION_INDEPENDENT_CODE on a
target I expect to get -fPI{C,E} no matter the target type.

-Brad



More information about the cmake-developers mailing list