NAG-Fortran.cmake 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Help CMAKE_PARSE_IMPLICIT_LINK_INFO detect NAG Fortran object files.
  2. if(NOT CMAKE_Fortran_COMPILER_WORKS AND NOT CMAKE_Fortran_COMPILER_FORCED)
  3. message(STATUS "Detecting NAG Fortran directory")
  4. # Run with -dryrun to see sample "link" line.
  5. execute_process(
  6. COMMAND ${CMAKE_Fortran_COMPILER} dummy.o -dryrun
  7. OUTPUT_VARIABLE _dryrun
  8. ERROR_VARIABLE _dryrun
  9. )
  10. # Match an object file.
  11. string(REGEX MATCH "/[^ ]*/[^ /][^ /]*\\.o" _nag_obj "${_dryrun}")
  12. if(_nag_obj)
  13. # Parse object directory and convert to a regex.
  14. string(REGEX REPLACE "/[^/]*$" "" _nag_dir "${_nag_obj}")
  15. string(REGEX REPLACE "([][+.*()^])" "\\\\\\1" _nag_regex "${_nag_dir}")
  16. set(CMAKE_Fortran_IMPLICIT_OBJECT_REGEX "^${_nag_regex}/")
  17. file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
  18. "Detecting NAG Fortran directory with -dryrun found\n"
  19. " object: ${_nag_obj}\n"
  20. " directory: ${_nag_dir}\n"
  21. " regex: ${CMAKE_Fortran_IMPLICIT_OBJECT_REGEX}\n"
  22. "from output:\n${_dryrun}\n\n")
  23. message(STATUS "Detecting NAG Fortran directory - ${_nag_dir}")
  24. else()
  25. file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
  26. "Detecting NAG Fortran directory with -dryrun failed:\n${_dryrun}\n\n")
  27. message(STATUS "Detecting NAG Fortran directory - failed")
  28. endif()
  29. endif()
  30. set(CMAKE_Fortran_SUBMODULE_SEP ".")
  31. set(CMAKE_Fortran_SUBMODULE_EXT ".sub")
  32. set(CMAKE_Fortran_MODDIR_FLAG "-mdir ")
  33. set(CMAKE_SHARED_LIBRARY_Fortran_FLAGS "-PIC")
  34. set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-fixed")
  35. set(CMAKE_Fortran_FORMAT_FREE_FLAG "-free")
  36. set(CMAKE_Fortran_COMPILE_OPTIONS_PIC "-PIC")
  37. set(CMAKE_Fortran_COMPILE_OPTIONS_PIE "-PIC")
  38. set(CMAKE_Fortran_RESPONSE_FILE_LINK_FLAG "-Wl,@")