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
-- 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
