cmake/Modules/TestCXXAcceptsFlag.cmake

38 lines
1013 B
CMake
Raw Normal View History

2016-10-30 18:24:19 +01:00
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
2019-11-11 23:01:05 +01:00
#[=======================================================================[.rst:
TestCXXAcceptsFlag
------------------
.. deprecated:: 3.0
See :module:`CheckCXXCompilerFlag`.
Check if the CXX compiler accepts a flag.
.. code-block:: cmake
CHECK_CXX_ACCEPTS_FLAG(<flags> <variable>)
``<flags>``
the flags to try
``<variable>``
variable to store the result
#]=======================================================================]
2013-03-16 19:13:01 +02:00
macro(CHECK_CXX_ACCEPTS_FLAG FLAGS VARIABLE)
if(NOT DEFINED ${VARIABLE})
2020-08-30 11:54:41 +02:00
message(CHECK_START "Checking to see if CXX compiler accepts flag ${FLAGS}")
2013-03-16 19:13:01 +02:00
try_compile(${VARIABLE}
2022-11-16 20:14:03 +01:00
SOURCES ${CMAKE_ROOT}/Modules/DummyCXXFile.cxx
CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${FLAGS}
2023-05-23 16:38:00 +02:00
)
2013-03-16 19:13:01 +02:00
if(${VARIABLE})
2020-08-30 11:54:41 +02:00
message(CHECK_PASS "yes")
2013-03-16 19:13:01 +02:00
else()
2020-08-30 11:54:41 +02:00
message(CHECK_FAIL "no")
2013-03-16 19:13:01 +02:00
endif()
endif()
endmacro()