CheckOBJCSourceRuns.cmake 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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. 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>``. Success of build and run is indicated by boolean ``true``.
  17. Failure to build or run is indicated by boolean ``false`` such as an empty
  18. 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/CMAKE_REQUIRED_FLAGS.txt
  23. .. include:: /module/CMAKE_REQUIRED_DEFINITIONS.txt
  24. .. include:: /module/CMAKE_REQUIRED_INCLUDES.txt
  25. .. include:: /module/CMAKE_REQUIRED_LINK_OPTIONS.txt
  26. .. include:: /module/CMAKE_REQUIRED_LIBRARIES.txt
  27. .. include:: /module/CMAKE_REQUIRED_LINK_DIRECTORIES.txt
  28. .. include:: /module/CMAKE_REQUIRED_QUIET.txt
  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()