CheckCXXCompilerFlag.cmake 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. CheckCXXCompilerFlag
  5. ------------------------
  6. Check whether the CXX compiler supports a given flag.
  7. .. command:: check_cxx_compiler_flag
  8. .. code-block:: cmake
  9. check_cxx_compiler_flag(<flag> <var>)
  10. Check that the ``<flag>`` is accepted by the compiler without
  11. a diagnostic. Stores the result in an internal cache entry
  12. named ``<var>``.
  13. A positive result from this check indicates only that the compiler did not
  14. issue a diagnostic message when given the flag. Whether the flag has any
  15. effect or even a specific one is beyond the scope of this module.
  16. .. note::
  17. Since the :command:`try_compile` command forwards flags from variables
  18. like :variable:`CMAKE_CXX_FLAGS <CMAKE_<LANG>_FLAGS>`, unknown flags
  19. in such variables may cause a false negative for this check.
  20. #]=======================================================================]
  21. include_guard(GLOBAL)
  22. include(Internal/CheckCompilerFlag)
  23. macro (CHECK_CXX_COMPILER_FLAG _FLAG _RESULT)
  24. cmake_check_compiler_flag(CXX "${_FLAG}" ${_RESULT})
  25. endmacro ()
  26. # FIXME(#24994): The following module is included only for compatibility
  27. # with projects that accidentally relied on it with CMake 3.26 and below.
  28. include(CheckCXXSourceCompiles)