CheckOBJCXXCompilerFlag.cmake 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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. CheckOBJCXXCompilerFlag
  5. -----------------------
  6. .. versionadded:: 3.16
  7. Check 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 that the ``<flag>`` is accepted by the compiler without
  12. a diagnostic. Stores the result in an internal cache entry
  13. named ``<resultVar>``.
  14. A positive result from this check indicates only that the compiler did not
  15. issue a diagnostic message when given the flag. Whether the flag has any
  16. effect or even a specific one is beyond the scope of this module.
  17. The check is only performed once, with the result cached in the variable named
  18. by ``<resultVar>``. Every subsequent CMake run will reuse this cached value
  19. rather than performing the check again, even if the ``<code>`` changes. In
  20. order to force the check to be re-evaluated, the variable named by
  21. ``<resultVar>`` must be manually removed from the cache.
  22. The compile and link commands can be influenced by setting any of the
  23. following variables prior to calling ``check_objcxx_compiler_flag()``
  24. .. include:: /module/CMAKE_REQUIRED_FLAGS.txt
  25. .. include:: /module/CMAKE_REQUIRED_DEFINITIONS.txt
  26. .. include:: /module/CMAKE_REQUIRED_INCLUDES.txt
  27. .. include:: /module/CMAKE_REQUIRED_LINK_OPTIONS.txt
  28. .. include:: /module/CMAKE_REQUIRED_LIBRARIES.txt
  29. .. include:: /module/CMAKE_REQUIRED_QUIET.txt
  30. #]=======================================================================]
  31. include_guard(GLOBAL)
  32. include(Internal/CheckCompilerFlag)
  33. macro (CHECK_OBJCXX_COMPILER_FLAG _FLAG _RESULT)
  34. cmake_check_compiler_flag(OBJCXX "${_FLAG}" ${_RESULT})
  35. endmacro ()
  36. # FIXME(#24994): The following module is included only for compatibility
  37. # with projects that accidentally relied on it with CMake 3.26 and below.
  38. include(CheckOBJCXXSourceCompiles)