1 # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
4 #[=======================================================================[.rst:
5 CheckFortranCompilerFlag
6 ------------------------
10 Check once whether the Fortran compiler supports a given flag.
12 .. command:: check_fortran_compiler_flag
16 check_fortran_compiler_flag(<flag> <resultVar>)
18 Check once that the ``<flag>`` is accepted by the compiler without a diagnostic.
19 The result is stored in the internal cache variable specified by
20 ``<resultVar>``, with boolean ``true`` for success and boolean ``false`` for
23 ``true`` indicates only that the compiler did not issue a diagnostic message
24 when given the flag. Whether the flag has any effect is beyond the scope of
27 Internally, :command:`try_compile` is used to perform the check. If
28 :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` is set to ``EXECUTABLE`` (default),
29 the check compiles and links an executable program. If set to
30 ``STATIC_LIBRARY``, the check is compiled but not linked.
32 See also :command:`check_compiler_flag` for a more general command syntax.
34 The compile and link commands can be influenced by setting any of the
35 following variables prior to calling ``check_fortran_compiler_flag()``. Unknown
36 flags in these variables can case a false negative result.
38 .. include:: /module/CMAKE_REQUIRED_FLAGS.txt
40 .. include:: /module/CMAKE_REQUIRED_DEFINITIONS.txt
42 .. include:: /module/CMAKE_REQUIRED_INCLUDES.txt
44 .. include:: /module/CMAKE_REQUIRED_LINK_OPTIONS.txt
46 .. include:: /module/CMAKE_REQUIRED_LIBRARIES.txt
48 .. include:: /module/CMAKE_REQUIRED_LINK_DIRECTORIES.txt
50 .. include:: /module/CMAKE_REQUIRED_QUIET.txt
52 #]=======================================================================]
55 include(Internal/CheckCompilerFlag)
57 macro (CHECK_FORTRAN_COMPILER_FLAG _FLAG _RESULT)
58 cmake_check_compiler_flag(Fortran "${_FLAG}" ${_RESULT})
61 # FIXME(#24994): The following module is included only for compatibility
62 # with projects that accidentally relied on it with CMake 3.26 and below.
63 include(CheckFortranSourceCompiles)