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

Stephen Kelly steveire at gmail.com
Fri May 25 17:21:41 EDT 2012


Brad King wrote:

> 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.
> 

Something else that occured to me was that there's no way currently in the 
branch to use both POSITION_INDEPENDENT_CODE and set FLAGS for all 
SHARED_LIBRARYs and set the policy to NEW.

Should a CMAKE_${TARGET_TYPE}_${LANG}_COMPILE_OPTIONS be added in this 
branch too?

>>> 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.


Right.

Thanks,

Steve.





More information about the cmake-developers mailing list