TestCXXAcceptsFlag¶
Deprecated since version 3.0: This module should no longer be used. It has been superseded by the
CheckCXXCompilerFlag
module. As of CMake 3.19, the
CheckCompilerFlag
module is also available for checking flags across
multiple languages.
This module provides a macro to test whether the C++ (CXX) compiler supports specific flags.
Macros¶
- check_cxx_accepts_flag¶
Checks whether the CXX compiler accepts the specified flags:
check_cxx_accepts_flag(<flags> <result-variable>)
<flags>
One or more compiler flags to test. For multiple flags, provide them as a space-separated string.
<result-variable>
Name of an internal cache variable that stores the result. It is set to boolean true if the compiler accepts the flags and false otherwise.
Examples¶
Checking if the C++ compiler supports specific flags:
include(TestCXXAcceptsFlag)
check_cxx_accepts_flag("-fno-common -fstack-clash-protection" HAVE_FLAGS)
Migrating to the CheckCompilerFlag
module:
include(CheckCompilerFlag)
check_compiler_flag(CXX "-fno-common;-fstack-clash-protection" HAVE_FLAGS)