Check*CompilerFlag: Rewrite documentation of these modules

Format with modern markup.  Clarify that the setting of
`CMAKE_REQUIRED_DEFINITIONS` is temporary.  Add a note warning
about contamination of the checks by `CMAKE_<LANG>_FLAGS`.

Issue: #16973
This commit is contained in:
Brad King 2017-06-15 13:49:35 -04:00
parent 7c5299add4
commit aa944c88e3
3 changed files with 90 additions and 60 deletions

View File

@ -1,26 +1,36 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details. # file Copyright.txt or https://cmake.org/licensing for details.
#.rst: #[=======================================================================[.rst:
# CheckCCompilerFlag CheckCCompilerFlag
# ------------------ ------------------
#
# Check whether the C compiler supports a given flag. Check whether the C compiler supports a given flag.
#
# CHECK_C_COMPILER_FLAG(<flag> <var>) .. command:: check_c_compiler_flag
#
# :: ::
#
# <flag> - the compiler flag check_c_compiler_flag(<flag> <var>)
# <var> - variable to store the result
# Will be created as an internal cache variable. Check that the ``<flag>`` is accepted by the compiler without
# a diagnostic. Stores the result in an internal cache entry
# This internally calls the check_c_source_compiles macro and sets named ``<var>``.
# CMAKE_REQUIRED_DEFINITIONS to <flag>. See help for
# CheckCSourceCompiles for a listing of variables that can otherwise This command temporarily sets the ``CMAKE_REQUIRED_DEFINITIONS`` variable
# modify the build. The result only tells that the compiler does not and calls the ``check_c_source_compiles`` macro from the
# give an error message when it encounters the flag. If the flag has :module:`CheckCSourceCompiles` module. See documentation of that
# any effect or even a specific one is beyond the scope of this module. module for a listing of variables that can otherwise modify the build.
A positive result from this check indicates only that the compiler did not
issue a diagnostic message when given the flag. Whether the flag has any
effect or even a specific one is beyond the scope of this module.
.. note::
Since the :command:`try_compile` command forwards flags from variables
like :variable:`CMAKE_C_FLAGS <CMAKE_<LANG>_FLAGS>`, unknown flags
in such variables may cause a false negative for this check.
#]=======================================================================]
include(CheckCSourceCompiles) include(CheckCSourceCompiles)
include(CMakeCheckCompilerFlagCommonPatterns) include(CMakeCheckCompilerFlagCommonPatterns)

View File

@ -1,25 +1,36 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details. # file Copyright.txt or https://cmake.org/licensing for details.
#.rst: #[=======================================================================[.rst:
# CheckCXXCompilerFlag CheckCXXCompilerFlag
# -------------------- ------------------------
#
# Check whether the CXX compiler supports a given flag. Check whether the CXX compiler supports a given flag.
#
# CHECK_CXX_COMPILER_FLAG(<flag> <var>) .. command:: check_cxx_compiler_flag
#
# :: ::
#
# <flag> - the compiler flag check_cxx_compiler_flag(<flag> <var>)
# <var> - variable to store the result
# Check that the ``<flag>`` is accepted by the compiler without
# This internally calls the check_cxx_source_compiles macro and sets a diagnostic. Stores the result in an internal cache entry
# CMAKE_REQUIRED_DEFINITIONS to <flag>. See help for named ``<var>``.
# CheckCXXSourceCompiles for a listing of variables that can otherwise
# modify the build. The result only tells that the compiler does not This command temporarily sets the ``CMAKE_REQUIRED_DEFINITIONS`` variable
# give an error message when it encounters the flag. If the flag has and calls the ``check_cxx_source_compiles`` macro from the
# any effect or even a specific one is beyond the scope of this module. :module:`CheckCXXSourceCompiles` module. See documentation of that
module for a listing of variables that can otherwise modify the build.
A positive result from this check indicates only that the compiler did not
issue a diagnostic message when given the flag. Whether the flag has any
effect or even a specific one is beyond the scope of this module.
.. note::
Since the :command:`try_compile` command forwards flags from variables
like :variable:`CMAKE_CXX_FLAGS <CMAKE_<LANG>_FLAGS>`, unknown flags
in such variables may cause a false negative for this check.
#]=======================================================================]
include(CheckCXXSourceCompiles) include(CheckCXXSourceCompiles)
include(CMakeCheckCompilerFlagCommonPatterns) include(CMakeCheckCompilerFlagCommonPatterns)

View File

@ -1,27 +1,36 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details. # file Copyright.txt or https://cmake.org/licensing for details.
#.rst: #[=======================================================================[.rst:
# CheckFortranCompilerFlag CheckFortranCompilerFlag
# ------------------------ ------------------------
#
# Check whether the Fortran compiler supports a given flag. Check whether the Fortran compiler supports a given flag.
#
# CHECK_Fortran_COMPILER_FLAG(<flag> <var>) .. command:: check_fortran_compiler_flag
#
# :: ::
#
# <flag> - the compiler flag check_fortran_compiler_flag(<flag> <var>)
# <var> - variable to store the result
# Will be created as an internal cache variable. Check that the ``<flag>`` is accepted by the compiler without
# a diagnostic. Stores the result in an internal cache entry
# This internally calls the check_fortran_source_compiles macro and named ``<var>``.
# sets CMAKE_REQUIRED_DEFINITIONS to <flag>. See help for
# CheckFortranSourceCompiles for a listing of variables that can This command temporarily sets the ``CMAKE_REQUIRED_DEFINITIONS`` variable
# otherwise modify the build. The result only tells that the compiler and calls the ``check_fortran_source_compiles`` macro from the
# does not give an error message when it encounters the flag. If the :module:`CheckFortranSourceCompiles` module. See documentation of that
# flag has any effect or even a specific one is beyond the scope of module for a listing of variables that can otherwise modify the build.
# this module.
A positive result from this check indicates only that the compiler did not
issue a diagnostic message when given the flag. Whether the flag has any
effect or even a specific one is beyond the scope of this module.
.. note::
Since the :command:`try_compile` command forwards flags from variables
like :variable:`CMAKE_Fortran_FLAGS <CMAKE_<LANG>_FLAGS>`, unknown flags
in such variables may cause a false negative for this check.
#]=======================================================================]
include(CheckFortranSourceCompiles) include(CheckFortranSourceCompiles)
include(CMakeCheckCompilerFlagCommonPatterns) include(CMakeCheckCompilerFlagCommonPatterns)