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

Brad King brad.king at kitware.com
Tue Jun 5 13:36:00 EDT 2012


On 06/05/2012 01:23 PM, Stephen Kelly wrote:
> Brad King wrote:
>> You can't try_compile inside a platform file.
> 
> I'm not sure I'm trying to?

I thought you meant you would add the try_compile to the platform file
to decide whether to report -fPIE.

> Do you mean in the tests, or do you mean the POSITION_INDEPENDENT_CODE 
> feature should be disabled for older GCC?

I mean that

  set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "-fPIE")

should not be done if the compiler does not have -fPIE.
Therefore Modules/Compiler/GNU.cmake needs to test the
compiler version to decide whether -fPIE is available.
Likely other toolchains will need similar checks.

-Brad



More information about the cmake-developers mailing list