[CMake] Default INTERFACE_POSITION_INDEPENDENT_CODE value for static library

Robert Maynard robert.maynard at kitware.com
Fri Apr 10 08:59:54 EDT 2015


The default for PIC is no for static libraries, see
http://www.cmake.org/cmake/help/v3.2/prop_tgt/POSITION_INDEPENDENT_CODE.html

On Wed, Apr 8, 2015 at 4:56 PM, Ruslan Baratov via CMake
<cmake at cmake.org> wrote:
> 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
> --
>
> Powered by www.kitware.com
>
> Please keep messages on-topic and check the CMake FAQ at:
> http://www.cmake.org/Wiki/CMake_FAQ
>
> Kitware offers various services to support the CMake community. For more
> information on each offering, please visit:
>
> CMake Support: http://cmake.org/cmake/help/support.html
> CMake Consulting: http://cmake.org/cmake/help/consulting.html
> CMake Training Courses: http://cmake.org/cmake/help/training.html
>
> Visit other Kitware open-source projects at
> http://www.kitware.com/opensource/opensource.html
>
> Follow this link to subscribe/unsubscribe:
> http://public.kitware.com/mailman/listinfo/cmake


More information about the CMake mailing list