Merge topic 'cuda_add_12.8_new_sm_support'
[kiteware-cmake.git] / Modules / CheckCXXCompilerFlag.cmake
blob41af21043387bfc9d7580430946236dfb228192a
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 CheckCXXCompilerFlag
6 ------------------------
8 Check once whether the CXX compiler supports a given flag.
10 .. command:: check_cxx_compiler_flag
12   .. code-block:: cmake
14     check_cxx_compiler_flag(<flag> <resultVar>)
16 Check once that the ``<flag>`` is accepted by the compiler without a diagnostic.
17 The result is stored in the internal cache variable specified by
18 ``<resultVar>``, with boolean ``true`` for success and boolean ``false`` for
19 failure.
21 ``true`` indicates only that the compiler did not issue a diagnostic message
22 when given the flag. Whether the flag has any effect is beyond the scope of
23 this module.
25 Internally, :command:`try_compile` is used to perform the check. If
26 :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` is set to ``EXECUTABLE`` (default),
27 the check compiles and links an executable program. If set to
28 ``STATIC_LIBRARY``, the check is compiled but not linked.
30 See also :command:`check_compiler_flag` for a more general command syntax.
32 The compile and link commands can be influenced by setting any of the
33 following variables prior to calling ``check_cxx_compiler_flag()``. Unknown flags
34 in these variables can case a false negative result.
36 .. include:: /module/CMAKE_REQUIRED_FLAGS.txt
38 .. include:: /module/CMAKE_REQUIRED_DEFINITIONS.txt
40 .. include:: /module/CMAKE_REQUIRED_INCLUDES.txt
42 .. include:: /module/CMAKE_REQUIRED_LINK_OPTIONS.txt
44 .. include:: /module/CMAKE_REQUIRED_LIBRARIES.txt
46 .. include:: /module/CMAKE_REQUIRED_LINK_DIRECTORIES.txt
48 .. include:: /module/CMAKE_REQUIRED_QUIET.txt
49 #]=======================================================================]
51 include_guard(GLOBAL)
52 include(Internal/CheckCompilerFlag)
54 macro (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT)
55   cmake_check_compiler_flag(CXX "${_FLAG}" ${_RESULT})
56 endmacro ()
58 # FIXME(#24994): The following module is included only for compatibility
59 # with projects that accidentally relied on it with CMake 3.26 and below.
60 include(CheckCXXSourceCompiles)