[CMake] nagfor, Ninja, and Missing variable is: CMAKE_Fortran_PREPROCESS_SOURCE

Josh Hykes jhykes at gmail.com
Mon Aug 7 09:00:39 EDT 2017


Hello,

I was trying to build my Fortran project with nagfor using the Ninja
generator. I ran into the below error. I am using cmake version 3.9.0.

I found a discussion of a similar error at

http://public.kitware.com/pipermail/cmake/2016-December/064710.html

If I add the following line for the NAG compiler, then the error goes away:

set(CMAKE_Fortran_PREPROCESS_SOURCE
    "<CMAKE_Fortran_COMPILER> -fpp <DEFINES> <INCLUDES> <FLAGS> -F <SOURCE>
-o <PREPROCESSED_SOURCE>")

I thought I should mention this in case you wanted to add it to CMake.

-Josh


$ cmake ../test -GNinja -DCMAKE_BUILD_TYPE=DEBUG
-DCMAKE_Fortran_COMPILER=nagfor
-- The C compiler identification is GNU 4.5.1
-- The CXX compiler identification is GNU 4.5.1
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - 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
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- The Fortran compiler identification is NAG 6.1.6120
-- Detecting NAG Fortran directory
-- Detecting NAG Fortran directory -
/home/joshua/opt/nag/nagfor_6120/lib/NAG_Fortran
-- Check for working Fortran compiler:
/home/joshua/opt/nag/nagfor_6120/bin/nagfor
CMake Error: Error required internal CMake variable not set, cmake may not
be built correctly.
Missing variable is:
CMAKE_Fortran_PREPROCESS_SOURCE
CMake Error at
/home/joshua/opt/cmake/cmake-3.9.0-Linux-x86_64/share/cmake-3.9/Modules/CMakeTestFortranCompiler.cmake:30
(try_compile):
  Failed to generate test project build system.
Call Stack (most recent call first):
  CMakeLists.txt:5 (enable_language)


-- Configuring incomplete, errors occurred!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20170807/e5a60e7c/attachment.html>


More information about the CMake mailing list