<div dir="ltr">Hello,<div><br></div><div>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:<br><div><br></div><div><br></div><div><a href="https://github.com/Kitware/ninja/releases">https://github.com/Kitware/ninja/releases</a><br></div><div><br></div><div><br></div><div>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:</div></div><div><br></div><div>- CMakeLists.txt<br></div><div>- src/foo.f90</div><div><br></div><div><br></div><div>Where foo.f90 is a toy program that adds two integers, and CMakeLists.tx contains the bare minimum:</div><div><br></div><div><div>--------------------------</div><div>$ cat CMakeLists.txt </div><div>cmake_minimum_required(VERSION 3.7)</div><div><br></div><div>project(hello)</div><div>enable_language(Fortran)</div><div><br></div><div>add_executable(prog src/foo.f90)</div></div><div>--------------------------</div><div><br></div><div>At this point I should say that I am running CMake 3.7.1 freshly downloaded from <a href="http://cmake.org">cmake.org</a> and my OS is Ubuntu Linux 16.04 LTS. So anyway, if we produce Makefiles everything is fine:</div><div><br></div><div><div>--------------------------</div><div>$ mkdir build</div><div>$ cd build</div><div><div>build $ echo $FC   # <---- PGI compiler.</div><div>pgfortran</div></div><div><br></div><div>build $ cmake ..</div><div>-- The C compiler identification is GNU 5.4.0</div><div>-- The CXX compiler identification is GNU 5.4.0</div><div>-- Check for working C compiler: /usr/bin/cc</div><div>-- Check for working C compiler: /usr/bin/cc -- works</div><div>-- Detecting C compiler ABI info</div><div>-- Detecting C compiler ABI info - done</div><div>-- Detecting C compile features</div><div>-- Detecting C compile features - done</div><div>-- Check for working CXX compiler: /usr/bin/c++</div><div>-- Check for working CXX compiler: /usr/bin/c++ -- works</div><div>-- Detecting CXX compiler ABI info</div><div>-- Detecting CXX compiler ABI info - done</div><div>-- Detecting CXX compile features</div><div>-- Detecting CXX compile features - done</div><div>-- The Fortran compiler identification is PGI 16.10.0</div><div>-- Check for working Fortran compiler: /usr/local/bin/pgfortran</div><div>-- Check for working Fortran compiler: /usr/local/bin/pgfortran  -- works</div><div>-- Detecting Fortran compiler ABI info</div><div>-- Detecting Fortran compiler ABI info - done</div><div>-- Checking whether /usr/local/bin/pgfortran supports Fortran 90</div><div>-- Checking whether /usr/local/bin/pgfortran supports Fortran 90 -- yes</div><div>-- Configuring done</div><div>-- Generating done</div><div>-- Build files have been written to: <snip>/build</div></div><div><div>--------------------------</div></div><div><br></div><div>But when I ask CMake to make Ninja files, I have a problem:</div><div><br></div><div><br></div><div><div>--------------------------</div><div>build $ rm -rf [a-zA-Z]*</div><div>build $ cmake -GNinja ..</div><div>-- The C compiler identification is GNU 5.4.0</div><div>-- The CXX compiler identification is GNU 5.4.0</div><div>-- Check for working C compiler: /usr/bin/cc</div><div>-- Check for working C compiler: /usr/bin/cc -- works</div><div>-- Detecting C compiler ABI info</div><div>-- Detecting C compiler ABI info - done</div><div>-- Detecting C compile features</div><div>-- Detecting C compile features - done</div><div>-- Check for working CXX compiler: /usr/bin/c++</div><div>-- Check for working CXX compiler: /usr/bin/c++ -- works</div><div>-- Detecting CXX compiler ABI info</div><div>-- Detecting CXX compiler ABI info - done</div><div>-- Detecting CXX compile features</div><div>-- Detecting CXX compile features - done</div><div>-- The Fortran compiler identification is PGI 16.10.0</div><div>-- Check for working Fortran compiler: /usr/local/bin/pgfortran</div><div>CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.</div><div>Missing variable is:</div><div>CMAKE_Fortran_PREPROCESS_SOURCE</div><div>CMake Error: Internal CMake error, TryCompile generation of cmake failed</div><div>-- Check for working Fortran compiler: /usr/local/bin/pgfortran  -- broken</div><div>CMake Error at /opt/cmake-3.7.1-Linux-x86_64/share/cmake-3.7/Modules/CMakeTestFortranCompiler.cmake:44 (message):</div><div>  The Fortran compiler "/usr/local/bin/pgfortran" is not able to compile a</div><div>  simple test program.</div><div><br></div><div>  It fails with the following output:</div><div><div><br></div></div><div>   </div><div><br></div><div>  </div><div><br></div><div>  CMake will not be able to correctly generate this project.</div><div>Call Stack (most recent call first):</div><div>  CMakeLists.txt:4 (enable_language)</div><div><br></div><div><br></div><div>-- Configuring incomplete, errors occurred!</div><div>See also "<snip>/build/CMakeFiles/CMakeOutput.log".</div><div>See also "<snip>/build/CMakeFiles/CMakeError.log".</div></div><div><div>--------------------------</div></div><div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>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.</div><div><br></div><div>Cheers,</div><div>Daniel.</div><div><br></div></div>