[CMake] Default INTERFACE_POSITION_INDEPENDENT_CODE value for static library

Ruslan Baratov ruslan_baratov at yahoo.com
Wed Apr 8 16:56:32 EDT 2015


Hi,

I've got next error while trying to link static library to shared one on 
Linux:
     /usr/bin/ld: ...: relocation R_X86_64_32 against `.rodata' can not 
be used when making a shared object; recompile with -fPIC

This error can be detected on CMake configure step instead of linker 
stage if I add next code:
   set_property(TARGET ... PROPERTY INTERFACE_POSITION_INDEPENDENT_CODE YES)

in this case error message is:
   CMake Error: Property POSITION_INDEPENDENT_CODE on target "..." does
   not match the INTERFACE_POSITION_INDEPENDENT_CODE property requirement
   of dependency "...".

because there is POSITION_INDEPENDENT_CODE=YES default value for shared 
library. So I wonder why there is no default value 
INTERFACE_POSITION_INDEPENDENT_CODE=NO for static one?

Thanks, Ruslo


More information about the CMake mailing list