1# Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2# file Copyright.txt or https://cmake.org/licensing for details.
3
4#[=======================================================================[.rst:
5CheckFortranCompilerFlag
6------------------------
7
8.. versionadded:: 3.3
9
10Check whether the Fortran compiler supports a given flag.
11
12.. command:: check_fortran_compiler_flag
13
14  .. code-block:: cmake
15
16    check_fortran_compiler_flag(<flag> <var>)
17
18  Check that the ``<flag>`` is accepted by the compiler without
19  a diagnostic.  Stores the result in an internal cache entry
20  named ``<var>``.
21
22This command temporarily sets the ``CMAKE_REQUIRED_DEFINITIONS`` variable
23and calls the ``check_fortran_source_compiles`` macro from the
24:module:`CheckFortranSourceCompiles` module.  See documentation of that
25module for a listing of variables that can otherwise modify the build.
26
27A positive result from this check indicates only that the compiler did not
28issue a diagnostic message when given the flag.  Whether the flag has any
29effect or even a specific one is beyond the scope of this module.
30
31.. note::
32  Since the :command:`try_compile` command forwards flags from variables
33  like :variable:`CMAKE_Fortran_FLAGS <CMAKE_<LANG>_FLAGS>`, unknown flags
34  in such variables may cause a false negative for this check.
35#]=======================================================================]
36
37include_guard(GLOBAL)
38include(CheckFortranSourceCompiles)
39include(Internal/CheckCompilerFlag)
40
41macro (CHECK_FORTRAN_COMPILER_FLAG _FLAG _RESULT)
42  cmake_check_compiler_flag(Fortran "${_FLAG}" ${_RESULT})
43endmacro ()
44