MantisBT - CMake
View Issue Details
0015460CMakeCMakepublic2015-03-19 11:022015-11-02 09:13
Tiago Quintino 
 
normalmajoralways
closedfixed 
LinuxOpensuse13.1
 
CMake 3.3CMake 3.3 
0015460: PGI Fortran compiler does not recognise -fPIE
By selecting POSITION_INDEPENDENT_CODE the PGI compiler settings add automatically the flag -fPIE.
This flag does not exist for PGI Fortran Compiler.
I have checked this with pgf77, pgf90 and pgfortran.

The only workaround I found is to set the flag:

-DCMAKE_Fortran_FLAGS="-noswitcherror"

This turns off the check for flag validity in the compiler, but obviously is not a long-term solution, since now any test to compiler flags will pass irrespectively if the flag is recognised or not.

The solution I think is changing Modules/Platform/Linux-PGI.cmake to:

set(CMAKE_${lang}_COMPILE_OPTIONS_PIE "")

Note that the flag -fPIE also does not exist for PGI C and C++ compilers.


Build the attached CMakeLists.txt project with

cmake -DCMAKE_Fortran_COMPILER=pgf90 ..

I am using CMake 3.1.2 and PGI Fortran 14.4.
The man page of compiler does not reference this flag whatsoever.
This is the output I get:

-- The C compiler identification is GNU 4.8.1
-- Check for working C compiler: /usr/bin/gcc
-- Check for working C compiler: /usr/bin/gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- The Fortran compiler identification is PGI
-- Check for working Fortran compiler: /usr/local/apps/pgi/14.4/bin/pgf90
-- Check for working Fortran compiler: /usr/local/apps/pgi/14.4/bin/pgf90 -- broken
CMake Error at /usr/local/apps/cmake/3.1.2/share/cmake-3.1/Modules/CMakeTestFortranCompiler.cmake:54 (message):
  The Fortran compiler "/usr/local/apps/pgi/14.4/bin/pgf90" is not able to
  compile a simple test program.

  It fails with the following output:

   Change Dir: /home/ma/matq/git/cmake-test/pgi-pie/build/CMakeFiles/CMakeTmp

  

  Run Build Command:"/usr/bin/gmake" "cmTryCompileExec951442437/fast"

  gmake: Warning: File `Makefile' has modification time 1.9 s in the future

  /usr/bin/gmake -f CMakeFiles/cmTryCompileExec951442437.dir/build.make
  CMakeFiles/cmTryCompileExec951442437.dir/build

  gmake[1]: Entering directory
  `/home/ma/matq/git/cmake-test/pgi-pie/build/CMakeFiles/CMakeTmp'

  gmake[1]: Warning: File
  `CMakeFiles/cmTryCompileExec951442437.dir/flags.make' has modification time
  1.9 s in the future

  /usr/local/apps/cmake/3.1.2/bin/cmake -E cmake_progress_report
  /home/ma/matq/git/cmake-test/pgi-pie/build/CMakeFiles/CMakeTmp/CMakeFiles 1

  Building Fortran object
  CMakeFiles/cmTryCompileExec951442437.dir/testFortranCompiler.f.o

  /usr/local/apps/pgi/14.4/bin/pgf90 -Mpreprocess -Kieee -fPIE -c
  /home/ma/matq/git/cmake-test/pgi-pie/build/CMakeFiles/CMakeTmp/testFortranCompiler.f
  -o CMakeFiles/cmTryCompileExec951442437.dir/testFortranCompiler.f.o

  pgf90-Error-Unknown switch: -fPIE

  gmake[1]: ***
  [CMakeFiles/cmTryCompileExec951442437.dir/testFortranCompiler.f.o] Error 1

  gmake[1]: Leaving directory
  `/home/ma/matq/git/cmake-test/pgi-pie/build/CMakeFiles/CMakeTmp'

  gmake: *** [cmTryCompileExec951442437/fast] Error 2

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:7 (enable_language)

No tags attached.
txt CMakeLists.txt (142) 2015-03-19 11:02
https://public.kitware.com/Bug/file/5409/CMakeLists.txt
Issue History
2015-03-19 11:02Tiago QuintinoNew Issue
2015-03-19 11:02Tiago QuintinoFile Added: CMakeLists.txt
2015-03-20 13:02Brad KingNote Added: 0038266
2015-03-20 13:02Brad KingStatusnew => resolved
2015-03-20 13:02Brad KingResolutionopen => fixed
2015-03-20 13:02Brad KingFixed in Version => CMake 3.3
2015-03-20 13:02Brad KingTarget Version => CMake 3.3
2015-11-02 09:13Robert MaynardNote Added: 0039741
2015-11-02 09:13Robert MaynardStatusresolved => closed

Notes
(0038266)
Brad King   
2015-03-20 13:02   
Okay, thanks. Fixed:

 PGI: Remove invalid -fPIE flag
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=00842df4 [^]
(0039741)
Robert Maynard   
2015-11-02 09:13   
Closing resolved issues that have not been updated in more than 4 months.