CheckOBJCXXCompilerFlag.cmake 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file LICENSE.rst or https://cmake.org/licensing for details.
  3. #[=======================================================================[.rst:
  4. CheckOBJCXXCompilerFlag
  5. -----------------------
  6. .. versionadded:: 3.16
  7. Check once whether the Objective-C++ compiler supports a given flag.
  8. .. command:: check_objcxx_compiler_flag
  9. .. code-block:: cmake
  10. check_objcxx_compiler_flag(<flag> <resultVar>)
  11. Check once that the ``<flag>`` is accepted by the compiler without a diagnostic.
  12. The result is stored in the internal cache variable specified by
  13. ``<resultVar>``, with boolean ``true`` for success and boolean ``false`` for
  14. failure.
  15. ``true`` indicates only that the compiler did not issue a diagnostic message
  16. when given the flag. Whether the flag has any effect is beyond the scope of
  17. this module.
  18. Internally, :command:`try_compile` is used to perform the check. If
  19. :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` is set to ``EXECUTABLE`` (default),
  20. the check compiles and links an executable program. If set to
  21. ``STATIC_LIBRARY``, the check is compiled but not linked.
  22. See also :command:`check_compiler_flag` for a more general command syntax.
  23. The compile and link commands can be influenced by setting any of the
  24. following variables prior to calling ``check_objcxx_compiler_flag()``. Unknown
  25. flags in these variables can case a false negative result.
  26. .. include:: /module/include/CMAKE_REQUIRED_FLAGS.rst
  27. .. include:: /module/include/CMAKE_REQUIRED_DEFINITIONS.rst
  28. .. include:: /module/include/CMAKE_REQUIRED_INCLUDES.rst
  29. .. include:: /module/include/CMAKE_REQUIRED_LINK_OPTIONS.rst
  30. .. include:: /module/include/CMAKE_REQUIRED_LIBRARIES.rst
  31. .. include:: /module/include/CMAKE_REQUIRED_LINK_DIRECTORIES.rst
  32. .. include:: /module/include/CMAKE_REQUIRED_QUIET.rst
  33. #]=======================================================================]
  34. include_guard(GLOBAL)
  35. include(Internal/CheckCompilerFlag)
  36. macro (CHECK_OBJCXX_COMPILER_FLAG _FLAG _RESULT)
  37. cmake_check_compiler_flag(OBJCXX "${_FLAG}" ${_RESULT})
  38. endmacro ()
  39. # FIXME(#24994): The following module is included only for compatibility
  40. # with projects that accidentally relied on it with CMake 3.26 and below.
  41. include(CheckOBJCXXSourceCompiles)