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

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


On 06/05/2012 11:54 AM, Stephen Kelly wrote:
> I can add a try_compile for -fPIE on APPLE (though I wonder if it would 
> work), but still, I expect to see something like that in the OUTPUT variable 
> from check_cxx_source_compiles...

The OUTPUT variable is internal to the macro and not documented as holding
anything when the call returns.  A quick glance doesn't tell me why the
value isn't leaking out as an implementation detail though.

You can't try_compile inside a platform file.  It's too early in the
init process because the platform files are needed to generate inside
the try_compile.  You would have to run your own execute_process and
invoke the compiler directly.  I suggest checking the compiler version
rather than testing the flag.  Just checking CMAKE_C_COMPILER_VERSION
might be enough in this case.

-Brad



More information about the cmake-developers mailing list