The following issue has been SUBMITTED. ====================================================================== http://www.cmake.org/Bug/view.php?id=15460 ====================================================================== Reported By: Tiago Quintino Assigned To: ====================================================================== Project: CMake Issue ID: 15460 Category: CMake Reproducibility: always Severity: major Priority: normal Status: new ====================================================================== Date Submitted: 2015-03-19 11:02 EDT Last Modified: 2015-03-19 11:02 EDT ====================================================================== Summary: PGI Fortran compiler does not recognise -fPIE Description: 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. Steps to Reproduce: Build the attached CMakeLists.txt project with cmake -DCMAKE_Fortran_COMPILER=pgf90 .. Additional Information: 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) ====================================================================== Issue History Date Modified Username Field Change ====================================================================== 2015-03-19 11:02 Tiago Quintino New Issue 2015-03-19 11:02 Tiago Quintino File Added: CMakeLists.txt ====================================================================== -- 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-developers