CheckFortranCompilerFlag.cmake 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. CheckFortranCompilerFlag
  5. ------------------------
  6. .. versionadded:: 3.3
  7. Check whether the Fortran compiler supports a given flag.
  8. .. command:: check_fortran_compiler_flag
  9. .. code-block:: cmake
  10. check_fortran_compiler_flag(<flag> <resultVar>)
  11. Check that the ``<flag>`` is accepted by the compiler without
  12. a diagnostic. Stores the result in an internal cache entry
  13. named ``<resultVar>``.
  14. A positive result from this check indicates only that the compiler did not
  15. issue a diagnostic message when given the flag. Whether the flag has any
  16. effect or even a specific one is beyond the scope of this module.
  17. The check is only performed once, with the result cached in the variable named
  18. by ``<resultVar>``. Every subsequent CMake run will reuse this cached value
  19. rather than performing the check again, even if the ``<code>`` changes. In
  20. order to force the check to be re-evaluated, the variable named by
  21. ``<resultVar>`` must be manually removed from the cache.
  22. See also :command:`check_compiler_flag` for a more general command syntax.
  23. The compile and link commands can be influenced by setting any of the
  24. following variables prior to calling ``check_fortran_compiler_flag()``
  25. .. include:: /module/CMAKE_REQUIRED_FLAGS.txt
  26. .. include:: /module/CMAKE_REQUIRED_DEFINITIONS.txt
  27. .. include:: /module/CMAKE_REQUIRED_INCLUDES.txt
  28. .. include:: /module/CMAKE_REQUIRED_LINK_OPTIONS.txt
  29. .. include:: /module/CMAKE_REQUIRED_LIBRARIES.txt
  30. .. include:: /module/CMAKE_REQUIRED_QUIET.txt
  31. #]=======================================================================]
  32. include_guard(GLOBAL)
  33. include(Internal/CheckCompilerFlag)
  34. macro (CHECK_FORTRAN_COMPILER_FLAG _FLAG _RESULT)
  35. cmake_check_compiler_flag(Fortran "${_FLAG}" ${_RESULT})
  36. endmacro ()
  37. # FIXME(#24994): The following module is included only for compatibility
  38. # with projects that accidentally relied on it with CMake 3.26 and below.
  39. include(CheckFortranSourceCompiles)