Merge topic 'cxx-checks-tolerate-unused-arguments'
[kiteware-cmake.git] / Modules / TestCXXAcceptsFlag.cmake
blob023d6ba6e70d97dc8cd87a1bfe050bdebbfaf7fd
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 TestCXXAcceptsFlag
6 ------------------
8 .. deprecated:: 3.0
10   See :module:`CheckCXXCompilerFlag`.
12 Check if the CXX compiler accepts a flag.
14 .. code-block:: cmake
16  CHECK_CXX_ACCEPTS_FLAG(<flags> <variable>)
18 ``<flags>``
19  the flags to try
20 ``<variable>``
21  variable to store the result
22 #]=======================================================================]
24 macro(CHECK_CXX_ACCEPTS_FLAG FLAGS  VARIABLE)
25   if(NOT DEFINED ${VARIABLE})
26     message(CHECK_START "Checking to see if CXX compiler accepts flag ${FLAGS}")
27     try_compile(${VARIABLE}
28       SOURCES ${CMAKE_ROOT}/Modules/DummyCXXFile.cxx
29       CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${FLAGS}
30       )
31     if(${VARIABLE})
32       message(CHECK_PASS "yes")
33     else()
34       message(CHECK_FAIL "no")
35     endif()
36   endif()
37 endmacro()