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: 5CheckCXXCompilerFlag 6------------------------ 7 8Check whether the CXX compiler supports a given flag. 9 10.. command:: check_cxx_compiler_flag 11 12 .. code-block:: cmake 13 14 check_cxx_compiler_flag(<flag> <var>) 15 16 Check that the ``<flag>`` is accepted by the compiler without 17 a diagnostic. Stores the result in an internal cache entry 18 named ``<var>``. 19 20This command temporarily sets the ``CMAKE_REQUIRED_DEFINITIONS`` variable 21and calls the ``check_cxx_source_compiles`` macro from the 22:module:`CheckCXXSourceCompiles` module. See documentation of that 23module for a listing of variables that can otherwise modify the build. 24 25A positive result from this check indicates only that the compiler did not 26issue a diagnostic message when given the flag. Whether the flag has any 27effect or even a specific one is beyond the scope of this module. 28 29.. note:: 30 Since the :command:`try_compile` command forwards flags from variables 31 like :variable:`CMAKE_CXX_FLAGS <CMAKE_<LANG>_FLAGS>`, unknown flags 32 in such variables may cause a false negative for this check. 33#]=======================================================================] 34 35include_guard(GLOBAL) 36include(CheckCXXSourceCompiles) 37include(Internal/CheckCompilerFlag) 38 39macro (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT) 40 cmake_check_compiler_flag(CXX "${_FLAG}" ${_RESULT}) 41endmacro () 42