[CMake] enable_language( ... OPTIONAL) causes error or second cmake run

Marcel Loose loose at astron.nl
Tue Nov 24 09:45:47 EST 2009


Hi all,

I've been experimenting a bit with enable_language() and stumbled upon
what I think is a bug. 

I have wanted to know how to properly handle a missing Fortran compiler.
So, on a system without a working Fortran compiler I ran cmake twice.

In the first cmake run, the Fortran compiler is searched and not found.
However, the second run of cmake then causes an error, which IMHO should
not happen.

This happens with CMake 2.6.2 and 2.8.0

$ cat ../CMakeLists.txt
project(Dummy)
cmake_minimum_required(VERSION 2.6)
enable_language(Fortran OPTIONAL)

$ cmake ..
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- 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
-- 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
-- The Fortran compiler identification is unknown
-- Configuring done
-- Generating done
-- Build files have been written to: /tmp/loose/cmake/build

$ cmake ..
-- The Fortran compiler identification is unknown
CMake Error
at /dop131_0/loose/x86_64-linux/usr/share/cmake-2.8/Modules/CMakeFortranInformation.cmake:25 (GET_FILENAME_COMPONENT):
  get_filename_component called with incorrect number of arguments
Call Stack (most recent call first):
  CMakeLists.txt:3 (enable_language)


-- Configuring incomplete, errors occurred!


Best regards,
Marcel Loose.




More information about the CMake mailing list