CheckOBJCXXCompilerFlag.cmake 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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> <var>)
  11. Check that the ``<flag>`` is accepted by the compiler without
  12. a diagnostic. Stores the result in an internal cache entry
  13. named ``<var>``.
  14. This command temporarily sets the ``CMAKE_REQUIRED_DEFINITIONS`` variable
  15. and calls the ``check_objcxx_source_compiles`` macro from the
  16. :module:`CheckOBJCXXSourceCompiles` module. See documentation of that
  17. module for a listing of variables that can otherwise modify the build.
  18. A positive result from this check indicates only that the compiler did not
  19. issue a diagnostic message when given the flag. Whether the flag has any
  20. effect or even a specific one is beyond the scope of this module.
  21. .. note::
  22. Since the :command:`try_compile` command forwards flags from variables
  23. like :variable:`CMAKE_OBJCXX_FLAGS <CMAKE_<LANG>_FLAGS>`, unknown flags
  24. in such variables may cause a false negative for this check.
  25. #]=======================================================================]
  26. include_guard(GLOBAL)
  27. include(CheckOBJCXXSourceCompiles)
  28. include(CheckCompilerFlag)
  29. macro (CHECK_OBJCXX_COMPILER_FLAG _FLAG _RESULT)
  30. check_compiler_flag(OBJCXX "${_FLAG}" ${_RESULT})
  31. endmacro ()