[CMake] Ninja+Fortran support for PGI compiler (was: Bug in Kitware's release of Ninja when compiling with PGI Fortran)

Daniel Carrera dcarrera at gmail.com
Thu Dec 15 21:10:21 EST 2016


On 15 December 2016 at 17:35, Brad King <brad.king at kitware.com> wrote:

>
> This is not a problem with Ninja or our branch of it, but rather with
> CMake's information about the PGI Fortran compiler not being updated
> to support the Ninja generator.  One can see the value for a few other
> compilers (from commit 39ebfc79e614dc395d5ace2ad5818b3ba75ca478):
>
> ```
> $ git grep -A 1 Fortran_PREPROCESS_SOURCE
> Modules/Compiler/GNU-Fortran.cmake:set(CMAKE_Fortran_PREPROCESS_SOURCE
> Modules/Compiler/GNU-Fortran.cmake-  "<CMAKE_Fortran_COMPILER> -cpp
> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> -o <PREPROCESSED_SOURCE>")
> --
> Modules/Compiler/Intel-Fortran.cmake:set(CMAKE_Fortran_PREPROCESS_SOURCE
> Modules/Compiler/Intel-Fortran.cmake-  "<CMAKE_Fortran_COMPILER> -fpp
> <DEFINES> <INCLUDES> <FLAGS> -E <SOURCE> > <PREPROCESSED_SOURCE>")
> --
> Modules/Compiler/SunPro-Fortran.cmake:set(CMAKE_Fortran_PREPROCESS_SOURCE
> Modules/Compiler/SunPro-Fortran.cmake-  "<CMAKE_Fortran_COMPILER>
> <DEFINES> <INCLUDES> <FLAGS> -F <SOURCE> -o <PREPROCESSED_SOURCE>")
> ```
>
> The `Modules/Compiler/PGI-Fortran.cmake` module needs to be updated too.
> I don't have that compiler handy, so if you can figure out the appropriate
> line to add to that file, please try it out.  If you get it working please
> post it and Cc me so it can be integrated.
>


Ok... keeping in mind that I don't know much about CMake or PGI, this seems
to be the correct line:

set(CMAKE_Fortran_PREPROCESS_SOURCE
"<CMAKE_Fortran_COMPILER> -Mpreprocess <DEFINES> <INCLUDES> <FLAGS> -E
<SOURCE> > <PREPROCESSED_SOURCE>")


The PGI documentation says that -Mpreprocess "instructs the compiler to
perform cpp-like preprocessing on assembly and Fortran input source files".
The -E flag causes the compiler to spit the result to stdout instead of
saving it to a file. Since the -E flag behaves as in the Intel compiler, I
used copied the stdout redirect ">" from the Intel-Fortran.cmake example.

I added that line to PGI-Fortran.cmake and it seems to work. CMake can now
make Ninja files for PGI.

Cheers,
Daniel.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20161216/066e9512/attachment-0001.html>


More information about the CMake mailing list