MantisBT - CMake
View Issue Details
0014862CMakeCMakepublic2014-04-03 16:252016-06-10 14:31
Marcus D. Hanwell 
Ben Boeckel 
normalmajoralways
closedmoved 
CMake 2.8.12.2 
CMake 3.0 
0014862: CMake and Ninja - check for Fortran optionally
Projects such as Eigen attempt to check for a working Fortran compiler, the act of probing for a working Fortran compiler causes configure to fail. This currently means that we are unable to use Ninja to build Eigen. I think the Ninja generator should at least exit more gracefully so that C/C++ projects with optional Fortran code are able to continue. This could be as simple as CMakeTestFortranCompiler.cmake returning failure on any attempt to test Fortran with the Ninja generator.
Get Eigen, attempt to build it, http://eigen.tuxfamily.org/ [^] is the main site, using the Ninja generator I get the following failed configure.
$ ninja eigen
[1/4] Performing configure step for 'eigen'
FAILED: cd /home/marcus/build/openchemistry/thirdparty/eigen && /usr/bin/cmake -C/home/marcus/build/openchemistry/thirdparty/eigen-prefix/tmp/eigen-cache.cmake "-GCodeBlocks - Ninja" /home/marcus/build/openchemistry/thirdparty/eigen-prefix/src/eigen && /usr/bin/cmake -E touch /home/marcus/build/openchemistry/thirdparty/eigen-prefix/src/eigen-stamp/eigen-configure
loading initial cache file /home/marcus/build/openchemistry/thirdparty/eigen-prefix/tmp/eigen-cache.cmake
CMake Warning (dev) in CMakeLists.txt:
  Syntax Warning in cmake code at

    /home/marcus/build/openchemistry/thirdparty/eigen-prefix/src/eigen/CMakeLists.txt:207:71

  Argument not separated from preceding token by whitespace.
This warning is for project developers. Use -Wno-dev to suppress it.

abort: repository /home/marcus/build/openchemistry/thirdparty/eigen-prefix/src/eigen not found!
abort: repository /home/marcus/build/openchemistry/thirdparty/eigen-prefix/src/eigen not found!
-- Standard libraries to link to explicitly: none
-- searching for 'pkgconfig' directory in PKG_CONFIG_LIBDIR ( ), /home/marcus/build/openchemistry/prefix/share, and /home/marcus/build/openchemistry/prefix/lib
-- pkgconfig not found; installing in /home/marcus/build/openchemistry/prefix/share
-- /home/marcus/build/openchemistry/thirdparty/eigen/test
-- Could NOT find CHOLMOD (missing: CHOLMOD_INCLUDES CHOLMOD_LIBRARIES)
-- Could NOT find UMFPACK (missing: UMFPACK_INCLUDES UMFPACK_LIBRARIES)
-- Could NOT find SUPERLU (missing: SUPERLU_INCLUDES SUPERLU_LIBRARIES)
-- Could NOT find PASTIX (missing: PASTIX_INCLUDES PASTIX_LIBRARIES)
-- Could NOT find SCOTCH (missing: SCOTCH_INCLUDES SCOTCH_LIBRARIES)
-- Could NOT find METIS (missing: METIS_INCLUDES METIS_LIBRARIES)
-- Could NOT find SPQR (missing: SPQR_INCLUDES SPQR_LIBRARIES)
CMake Error: The Ninja generator does not support Fortran yet.
-- The Fortran compiler identification is GNU
-- Check for working Fortran compiler using: Ninja
CMake Error: The Ninja generator does not support Fortran yet.
CMake Error: Internal CMake error, TryCompile configure of cmake failed
-- Check for working Fortran compiler using: Ninja -- broken
CMake Error at /usr/share/cmake-2.8/Modules/CMakeTestFortranCompiler.cmake:54 (message):
  The Fortran compiler "/usr/bin/gfortran" 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):
  blas/CMakeLists.txt:9 (enable_language)


-- Configuring incomplete, errors occurred!
See also "/home/marcus/build/openchemistry/thirdparty/eigen/CMakeFiles/CMakeOutput.log".
See also "/home/marcus/build/openchemistry/thirdparty/eigen/CMakeFiles/CMakeError.log".
ninja: build stopped: subcommand failed.
No tags attached.
Issue History
2014-04-03 16:25Marcus D. HanwellNew Issue
2014-04-03 16:25Marcus D. HanwellStatusnew => assigned
2014-04-03 16:25Marcus D. HanwellAssigned To => Ben Boeckel
2014-04-03 17:37Ben BoeckelNote Added: 0035633
2014-04-04 10:04Marcus D. HanwellNote Added: 0035638
2014-04-04 11:23Brad KingNote Added: 0035640
2014-04-04 11:24Brad KingNote Edited: 0035640bug_revision_view_page.php?bugnote_id=35640#r1440
2014-05-13 12:01Ben BoeckelNote Added: 0035872
2016-06-10 14:29Kitware RobotNote Added: 0042528
2016-06-10 14:29Kitware RobotStatusassigned => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0035633)
Ben Boeckel   
2014-04-03 17:37   
My thought is to move all of the hard-error cases down to when Ninja actually tries to generate a build rule for a Fortran object file since this is where Ninja actually has the issue (determining its dependencies reliably). A more useful error message could be used as well (which object file/target is the culprit and mentioning that Ninja can't get dependencies right).

Crazy idea I'm okay with not doing (but proposing so that anyone suggesting such a thing can be pointed here): having a CMAKE_NINJA_FORTRAN_I_KNOW_WHAT_IM_DOING_GIVE_ME_THE_ROPE variable to skip the check.
(0035638)
Marcus D. Hanwell   
2014-04-04 10:04   
Approaching this as a CMake user that mainly focuses on C/C++, but often has need of Fortran in projects, I would like a simple way of asking if I have a usable Fortran compiler and optionally doing stuff if so. I have no strong feelings on how that should be done, but it is a reasonably common use case in scientific computing to make it worthwhile supporting. If I have a real Fortran project I know that life will be much easier using a Makefile based generator and I will tend to prefer that, so the variable really would be of minimal practical use to many of us.
(0035640)
Brad King   
2014-04-04 11:23   
(edited on: 2014-04-04 11:24)
FWIW, CMake itself checks for Fortran support like this:

 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Tests/CheckFortran.cmake;hb=v3.0.0-rc3 [^]

in order to enable tests for it.

(0035872)
Ben Boeckel   
2014-05-13 12:01   
I have a branch on stage which delays the Fortran+Ninja error until a target with a Fortran compilation target is detected. This way you can ask for Fortran and do whatever, just not "add_library(tgt fortran.f90)". dev/ninja-fortran-erroring
(0042528)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.