言語名は大文字と小文字が区別されます。投稿されたように、私は得る:
~/cmt> cmake ./
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_fortran_COMPILER_ENV_VAR
CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
Missing variable is:
CMAKE_fortran_COMPILER
CMake Error: Could not find cmake module file:/home/tgallagher/cmt/CMakeFiles/CMakefortranCompiler.cmake
CMake Error: Could not find cmake module file:CMakefortranInformation.cmake
CMake Error: CMAKE_fortran_COMPILER not set, after EnableLanguage
-- 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
^C
ただし、ファイルを次のように変更することにより (これはではFortran
なく:fortran
enable_language()
cmake_minimum_required(VERSION 2.6)
enable_language(Fortran)
project(fortranTest)
get_filename_component (Fortran_COMPILER_NAME ${CMAKE_Fortran_COMPILER} NAME)
あなたは得る:
~/cmt> cmake ./
-- The Fortran compiler identification is GNU
-- Check for working Fortran compiler: /usr/bin/gfortran
-- Check for working Fortran compiler: /usr/bin/gfortran -- works
-- Detecting Fortran compiler ABI info
-- Detecting Fortran compiler ABI info - done
-- Checking whether /usr/bin/gfortran supports Fortran 90
-- Checking whether /usr/bin/gfortran supports Fortran 90 -- yes
-- The C compiler identification is GNU
-- The CXX compiler identification is GNU
-- Check for working C compiler: /usr/bin/gcc
^C
これは、終了が許可されていれば、期待どおりに機能します。ただし、コンパイラ フラグを決定する目的でコンパイラを識別するより良い方法があります。引用された例で使用されている方法は、コンパイラがラップされていないシステムでのみ機能します。mpif90
つまりftn
、Cray などを介してコンパイラを呼び出さないシステムを意味します。より良い方法は、次を確認することです。
if(${CMAKE_Fortran_COMPILER_ID} STREQUAL "Intel")
...
endif()
可能な名前のリストは、CMake モジュール ディレクトリ内のファイルを調べることで見つけることができます。Modules/CMakeFortranCompilerId.F.in