TestCXXAcceptsFlag¶
在 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 command to test whether the C++ (CXX) compiler supports specific flags.
在 CMake 專案中使用以下命令載入該模組:
include(TestCXXAcceptsFlag)
命令¶
This module provides the following command:
- 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.
範例¶
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)