CMakeTestFortranCompiler.cmake 1.6 KB

12345678910111213141516171819202122232425262728293031
  1. # This file is used by EnableLanguage in cmGlobalGenerator to
  2. # determine that that selected C compiler can actually compile
  3. # and link the most basic of programs. If not, a fatal error
  4. # is set and cmake stops processing commands and will not generate
  5. # any makefiles or projects.
  6. IF(NOT CMAKE_FORTRAN_COMPILER_WORKS)
  7. MESSAGE(STATUS "Check for working Fortran compiler: ${CMAKE_FORTRAN_COMPILER}")
  8. FILE(WRITE ${CMAKE_BINARY_DIR}/CMakeTmp/testFortranCompiler.f
  9. "\tPROGRAM TESTFORTRAN\n"
  10. "\tPRINT *, 'Hello'\n"
  11. "\tEND\n")
  12. TRY_COMPILE(CMAKE_FORTRAN_COMPILER_WORKS ${CMAKE_BINARY_DIR}
  13. ${CMAKE_BINARY_DIR}/CMakeTmp/testFortranCompiler.f
  14. OUTPUT_VARIABLE OUTPUT)
  15. ENDIF(NOT CMAKE_FORTRAN_COMPILER_WORKS)
  16. IF(NOT CMAKE_FORTRAN_COMPILER_WORKS)
  17. MESSAGE(STATUS "Check for working Fortran compiler: ${CMAKE_FORTRAN_COMPILER} -- broken")
  18. FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log
  19. "Determining if the Fortran compiler works failed with "
  20. "the following output:\n${OUTPUT}\n\n")
  21. MESSAGE(FATAL_ERROR "The Fortran compiler \"${CMAKE_FORTRAN_COMPILER}\" "
  22. "is not able to compile a simple test program.\nIt fails "
  23. "with the following output:\n ${OUTPUT}\n\n"
  24. "CMake will not be able to correctly generate this project.")
  25. ELSE(NOT CMAKE_FORTRAN_COMPILER_WORKS)
  26. MESSAGE(STATUS "Check for working Fortran compiler: ${CMAKE_FORTRAN_COMPILER} -- works")
  27. FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeOutput.log
  28. "Determining if the Fortran compiler works passed with "
  29. "the following output:\n${OUTPUT}\n\n")
  30. ENDIF(NOT CMAKE_FORTRAN_COMPILER_WORKS)