ce505f3ce1858f77096202c010f1331fc33d75e8
[platform/upstream/cmake.git] / Modules / TestCXXAcceptsFlag.cmake
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:
5 TestCXXAcceptsFlag
6 ------------------
7
8 .. deprecated:: 3.0
9
10   See :module:`CheckCXXCompilerFlag`.
11
12 Check if the CXX compiler accepts a flag.
13
14 .. code-block:: cmake
15
16  CHECK_CXX_ACCEPTS_FLAG(<flags> <variable>)
17
18 ``<flags>``
19  the flags to try
20 ``<variable>``
21  variable to store the result
22 #]=======================================================================]
23
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       ${CMAKE_BINARY_DIR}
29       ${CMAKE_ROOT}/Modules/DummyCXXFile.cxx
30       CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${FLAGS}
31       OUTPUT_VARIABLE OUTPUT)
32     if(${VARIABLE})
33       message(CHECK_PASS "yes")
34       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
35         "Determining if the CXX compiler accepts the flag ${FLAGS} passed with "
36         "the following output:\n${OUTPUT}\n\n")
37     else()
38       message(CHECK_FAIL "no")
39       file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
40         "Determining if the CXX compiler accepts the flag ${FLAGS} failed with "
41         "the following output:\n${OUTPUT}\n\n")
42     endif()
43   endif()
44 endmacro()