CheckOBJCSourceCompiles.cmake 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. CheckOBJCSourceCompiles
  5. -----------------------
  6. .. versionadded:: 3.16
  7. Check once if Objective-C source can be built.
  8. .. command:: check_objc_source_compiles
  9. .. code-block:: cmake
  10. check_objc_source_compiles(<code> <resultVar>
  11. [FAIL_REGEX <regex1> [<regex2>...]])
  12. Check once that the source supplied in ``<code>`` can be built. The result is
  13. stored in the internal cache variable specified by ``<resultVar>``, with
  14. boolean ``true`` for success and boolean ``false`` for failure.
  15. If ``FAIL_REGEX`` is provided, then failure is determined by checking
  16. if anything in the compiler output matches any of the specified regular
  17. expressions.
  18. Internally, :command:`try_compile` is used to compile the source. If
  19. :variable:`CMAKE_TRY_COMPILE_TARGET_TYPE` is set to ``EXECUTABLE`` (default),
  20. the source is compiled and linked as an executable program. If set to
  21. ``STATIC_LIBRARY``, the source is compiled but not linked. In any case, all
  22. functions must be declared as usual.
  23. See also :command:`check_source_compiles` for a more general command syntax.
  24. See also :command:`check_source_runs` to run compiled source.
  25. The compile and link commands can be influenced by setting any of the
  26. following variables prior to calling ``check_objc_source_compiles()``
  27. .. include:: /module/include/CMAKE_REQUIRED_FLAGS.rst
  28. .. include:: /module/include/CMAKE_REQUIRED_DEFINITIONS.rst
  29. .. include:: /module/include/CMAKE_REQUIRED_INCLUDES.rst
  30. .. include:: /module/include/CMAKE_REQUIRED_LINK_OPTIONS.rst
  31. .. include:: /module/include/CMAKE_REQUIRED_LIBRARIES.rst
  32. .. include:: /module/include/CMAKE_REQUIRED_LINK_DIRECTORIES.rst
  33. .. include:: /module/include/CMAKE_REQUIRED_QUIET.rst
  34. #]=======================================================================]
  35. include_guard(GLOBAL)
  36. include(Internal/CheckSourceCompiles)
  37. macro(CHECK_OBJC_SOURCE_COMPILES SOURCE VAR)
  38. cmake_check_source_compiles(OBJC "${SOURCE}" ${VAR} ${ARGN})
  39. endmacro()