CMakeTestFortranCompiler.cmake 1.6 KB

1234567891011121314151617181920212223242526272829303132
  1. # This file is used by EnableLanguage in cmGlobalGenerator to
  2. # determine that that selected Fortran 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. PROGRAM TESTFortran
  10. PRINT *, 'Hello'
  11. END
  12. ")
  13. TRY_COMPILE(CMAKE_Fortran_COMPILER_WORKS ${CMAKE_BINARY_DIR}
  14. ${CMAKE_BINARY_DIR}/CMakeTmp/testFortranCompiler.f
  15. OUTPUT_VARIABLE OUTPUT)
  16. ENDIF(NOT CMAKE_Fortran_COMPILER_WORKS)
  17. IF(NOT CMAKE_Fortran_COMPILER_WORKS)
  18. MESSAGE(STATUS "Check for working Fortran compiler: ${CMAKE_Fortran_COMPILER} -- broken")
  19. FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeError.log
  20. "Determining if the Fortran compiler works failed with "
  21. "the following output:\n${OUTPUT}\n\n")
  22. MESSAGE(FATAL_ERROR "The Fortran compiler \"${CMAKE_Fortran_COMPILER}\" "
  23. "is not able to compile a simple test program.\nIt fails "
  24. "with the following output:\n ${OUTPUT}\n\n"
  25. "CMake will not be able to correctly generate this project.")
  26. ELSE(NOT CMAKE_Fortran_COMPILER_WORKS)
  27. MESSAGE(STATUS "Check for working Fortran compiler: ${CMAKE_Fortran_COMPILER} -- works")
  28. FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeOutput.log
  29. "Determining if the Fortran compiler works passed with "
  30. "the following output:\n${OUTPUT}\n\n")
  31. ENDIF(NOT CMAKE_Fortran_COMPILER_WORKS)