CheckOBJCSourceRuns.cmake 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. CheckOBJCSourceRuns
  5. -------------------
  6. .. versionadded:: 3.16
  7. Check once if given Objective-C source compiles and links into an executable and
  8. can subsequently be run.
  9. .. command:: check_objc_source_runs
  10. .. code-block:: cmake
  11. check_objc_source_runs(<code> <resultVar>)
  12. Check once that the source supplied in ``<code>`` can be built, linked as an
  13. executable, and then run. The ``<code>`` must contain at least a ``main()``
  14. function.
  15. The result is stored in the internal cache variable specified by
  16. ``<resultVar>``. If the code builds and runs with exit code ``0``, success is
  17. indicated by boolean ``true``. Failure to build or run is indicated by boolean
  18. ``false``, such as an empty string or an error message.
  19. See also :command:`check_source_runs` for a more general command syntax.
  20. The compile and link commands can be influenced by setting any of the
  21. following variables prior to calling ``check_objc_source_runs()``
  22. .. include:: /module/include/CMAKE_REQUIRED_FLAGS.rst
  23. .. include:: /module/include/CMAKE_REQUIRED_DEFINITIONS.rst
  24. .. include:: /module/include/CMAKE_REQUIRED_INCLUDES.rst
  25. .. include:: /module/include/CMAKE_REQUIRED_LINK_OPTIONS.rst
  26. .. include:: /module/include/CMAKE_REQUIRED_LIBRARIES.rst
  27. .. include:: /module/include/CMAKE_REQUIRED_LINK_DIRECTORIES.rst
  28. .. include:: /module/include/CMAKE_REQUIRED_QUIET.rst
  29. #]=======================================================================]
  30. include_guard(GLOBAL)
  31. include(Internal/CheckSourceRuns)
  32. macro(CHECK_OBJC_SOURCE_RUNS SOURCE VAR)
  33. set(_CheckSourceRuns_old_signature 1)
  34. cmake_check_source_runs(OBJC "${SOURCE}" ${VAR} ${ARGN})
  35. unset(_CheckSourceRuns_old_signature)
  36. endmacro()