[CMake] Bad option -fPIE for NAG Fortran compiler
Neil Carlson
neil.n.carlson at gmail.com
Sun Aug 7 22:56:50 EDT 2016
I'm updating an older cmake configuration system, and tried using
CMAKE_POSITION_INDEPENDENT_CODE. While it mostly does
the right thing, I found that the flag -fPIE was being used for a source
file that gets compiled into an executable. The NAG Fortran compiler
doesn't recognize this flag and exits with an error.
I don't know who is setting this; perhaps it is a default guess that
specific compiler files (NAG-Fortran.cmake) are supposed to override?
I also don't understand what the difference is between PIC and PIE.
The NAG compiler doesn't provide a PIE option. But adding this
set(CMAKE_Fortran_COMPILE_OPTIONS_PIE "-PIC")
seems to work fine (and was almost certainly what was happening before.)
Alternatively, since the NAG Fortran compiler actually just generates C
code and then uses the underlying system C compiler, I've found this
also works
set(CMAKE_Fortran_COMPILE_OPTIONS_PIE "-Wc,-fPIE")
on Linux. But since that varies with platform, maybe the first option
is the safest.
Is the bottom of NAG-Fortran.cmake the right place to add this setting?
(Brad?)
Thanks, Neil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20160807/66092ef0/attachment.html>
More information about the CMake
mailing list