Merge topic 'cpack-innosetup-linux'
[kiteware-cmake.git] / Modules / CheckCCompilerFlag.cmake
blob27b7ae879774c7bc4400953af6890df10c8d31ca
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 CheckCCompilerFlag
6 ------------------
8 Check whether the C compiler supports a given flag.
10 .. command:: check_c_compiler_flag
12   .. code-block:: cmake
14     check_c_compiler_flag(<flag> <resultVar>)
16   Check that the ``<flag>`` is accepted by the compiler without
17   a diagnostic.  Stores the result in an internal cache entry
18   named ``<resultVar>``.
20 A positive result from this check indicates only that the compiler did not
21 issue a diagnostic message when given the flag.  Whether the flag has any
22 effect or even a specific one is beyond the scope of this module.
24 The check is only performed once, with the result cached in the variable named
25 by ``<resultVar>``. Every subsequent CMake run will reuse this cached value
26 rather than performing the check again, even if the ``<code>`` changes. In
27 order to force the check to be re-evaluated, the variable named by
28 ``<resultVar>`` must be manually removed from the cache.
30 The compile and link commands can be influenced by setting any of the
31 following variables prior to calling ``check_c_compiler_flag()``
33 .. include:: /module/CMAKE_REQUIRED_FLAGS.txt
35 .. include:: /module/CMAKE_REQUIRED_DEFINITIONS.txt
37 .. include:: /module/CMAKE_REQUIRED_INCLUDES.txt
39 .. include:: /module/CMAKE_REQUIRED_LINK_OPTIONS.txt
41 .. include:: /module/CMAKE_REQUIRED_LIBRARIES.txt
43 .. include:: /module/CMAKE_REQUIRED_QUIET.txt
45 #]=======================================================================]
47 include_guard(GLOBAL)
48 include(Internal/CheckCompilerFlag)
50 macro (CHECK_C_COMPILER_FLAG _FLAG _RESULT)
51   cmake_check_compiler_flag(C "${_FLAG}" ${_RESULT})
52 endmacro ()
54 # FIXME(#24994): The following module is included only for compatibility
55 # with projects that accidentally relied on it with CMake 3.26 and below.
56 include(CheckCSourceCompiles)