[cmake-developers] Adding logic to CMake for -fPIE and -fPIC
Stephen Kelly
steveire at gmail.com
Tue May 29 12:16:31 EDT 2012
Brad King wrote:
> On 05/25/2012 04:47 PM, Stephen Kelly wrote:
>> I'm also not completely certain about the change to the try_compile
>> behavior in the branch. Could there be any reason to use
>> set(CMAKE_POSITION_INDEPENDENT_CODE ON) but want to do a try_compile
>> without -fPI{C,E} ? My guess is no, because one would do the try_compile
>> before conditionally setting that property, I guess.
>
> Since project's don't currently set CMAKE_POSITION_INDEPENDENT_CODE
> there is no compatibility problem. I think it is okay to honor that
> for try_compile. It is more representative of how the sources will
> actually be compiled in the calling project.
>
> The current topic looks pretty good so far. There is some more work
> to be done. Please see the block at the bottom of this message for
> the documentation I recommend using for CMP0018.
Done, in a new force push.
>
> Look at the logic in cmLocalGenerator::AppendFeatureOptions for
> handling of _COMPILE_OPTIONS_ values. We need to use
> ExpandListArgument to ensure that options are separated as
> CMake-style lists instead of whitespace. That is the convention
> I'm establishing for "COMPILE_OPTIONS" platform variables. It will
> not make a difference for single-argument options like "-fPIC" but
> could if some platforms have multi-argument options.
>
> Before merging we will need to add the equivalent to the hunk
>
> + set(CMAKE_${lang}_COMPILE_OPTIONS_PIC "-fPIC")
> + set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE")
>
> on all necessary platforms. The policy can't be per-platform.
> You already have a TODO comment for this.
Done, though I left some notes in the commit for now. It seems the existing
variable is used for more than just PIC equivalents.
Thanks,
Steve.
More information about the cmake-developers
mailing list