[CMake] Bug in Kitware's release of Ninja when compiling with PGI Fortran

Daniel Carrera dcarrera at gmail.com
Tue Dec 13 21:26:54 EST 2016


Hello,

First of all, I want to say that I think it's amazing that Kitware has gone
through the trouble of maintaining a separate build of Ninja with bugfixes
so that us Fortran users can use Ninja with CMake:


https://github.com/Kitware/ninja/releases


Since no good deed goes unpunished... I want to report that this release of
Ninja doesn't seem to like the PGI compiler. Let me show you. I have a toy
project with just two files:

- CMakeLists.txt
- src/foo.f90


Where foo.f90 is a toy program that adds two integers, and CMakeLists.tx
contains the bare minimum:

--------------------------
$ cat CMakeLists.txt
cmake_minimum_required(VERSION 3.7)

project(hello)
enable_language(Fortran)

add_executable(prog src/foo.f90)
--------------------------

At this point I should say that I am running CMake 3.7.1 freshly downloaded
from cmake.org and my OS is Ubuntu Linux 16.04 LTS. So anyway, if we
produce Makefiles everything is fine:

--------------------------
$ mkdir build
$ cd build
build $ echo $FC   # <---- PGI compiler.
pgfortran

build $ cmake ..
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The Fortran compiler identification is PGI 16.10.0
-- Check for working Fortran compiler: /usr/local/bin/pgfortran
-- Check for working Fortran compiler: /usr/local/bin/pgfortran  -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether /usr/local/bin/pgfortran supports Fortran 90
-- Checking whether /usr/local/bin/pgfortran supports Fortran 90 -- yes
-- Configuring done
-- Generating done
-- Build files have been written to: <snip>/build
--------------------------

But when I ask CMake to make Ninja files, I have a problem:


--------------------------
build $ rm -rf [a-zA-Z]*
build $ cmake -GNinja ..
-- The C compiler identification is GNU 5.4.0
-- The CXX compiler identification is GNU 5.4.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The Fortran compiler identification is PGI 16.10.0
-- Check for working Fortran compiler: /usr/local/bin/pgfortran
CMake Error: Error required internal CMake variable not set, cmake may be
not be built correctly.
Missing variable is:
CMAKE_Fortran_PREPROCESS_SOURCE
CMake Error: Internal CMake error, TryCompile generation of cmake failed
-- Check for working Fortran compiler: /usr/local/bin/pgfortran  -- broken
CMake Error at
/opt/cmake-3.7.1-Linux-x86_64/share/cmake-3.7/Modules/CMakeTestFortranCompiler.cmake:44
(message):
  The Fortran compiler "/usr/local/bin/pgfortran" is not able to compile a
  simple test program.

  It fails with the following output:





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


-- Configuring incomplete, errors occurred!
See also "<snip>/build/CMakeFiles/CMakeOutput.log".
See also "<snip>/build/CMakeFiles/CMakeError.log".
--------------------------

I have attached CMakeError.log and CMakeOutput.log inside the Zip file
"CMakeFiles.zip". I looked at the log files and I didn't see anything
informative. This problem only occurs with the PGI compiler. CMake+Ninja
seem to work just fine for the GNU and Intel compilers.

I have verified that I can compile Fortran programs with the PGI compiler.
The PGI compiler is also a very recent download from their website. I'm
using the free "Community Edition" compiler.

I hope this helps someone find a fix so that CMake+Ninja works even better.
Once again, thank you for going through the trouble of patching somebody
else's source tree just to give me another feature.

Cheers,
Daniel.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20161214/f971f8ba/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: CMakeFiles.zip
Type: application/zip
Size: 4876 bytes
Desc: not available
URL: <http://public.kitware.com/pipermail/cmake/attachments/20161214/f971f8ba/attachment-0001.zip>


More information about the CMake mailing list