CheckOBJCXXSourceRuns.cmake 2.0 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. CheckOBJCXXSourceRuns
  5. ---------------------
  6. .. versionadded:: 3.16
  7. Check if given Objective-C++ source compiles and links into an executable and can
  8. subsequently be run.
  9. .. command:: check_objcxx_source_runs
  10. .. code-block:: cmake
  11. check_objcxx_source_runs(<code> <resultVar>)
  12. Check that the source supplied in ``<code>`` can be compiled as a Objective-C++ source
  13. file, linked as an executable and then run. The ``<code>`` must contain at
  14. least a ``main()`` function. If the ``<code>`` could be built and run
  15. successfully, the internal cache variable specified by ``<resultVar>`` will
  16. be set to 1, otherwise it will be set to an value that evaluates to boolean
  17. false (e.g. an empty string or an error message).
  18. The check is only performed once, with the result cached in the variable named
  19. by ``<resultVar>``. Every subsequent CMake run will reuse this cached value
  20. rather than performing the check again, even if the ``<code>`` changes. In
  21. order to force the check to be re-evaluated, the variable named by
  22. ``<resultVar>`` must be manually removed from the cache.
  23. The compile and link commands can be influenced by setting any of the
  24. following variables prior to calling ``check_objcxx_source_runs()``
  25. .. include:: /module/CMAKE_REQUIRED_FLAGS.txt
  26. .. include:: /module/CMAKE_REQUIRED_DEFINITIONS.txt
  27. .. include:: /module/CMAKE_REQUIRED_INCLUDES.txt
  28. .. include:: /module/CMAKE_REQUIRED_LINK_OPTIONS.txt
  29. .. include:: /module/CMAKE_REQUIRED_LIBRARIES.txt
  30. .. include:: /module/CMAKE_REQUIRED_QUIET.txt
  31. #]=======================================================================]
  32. include_guard(GLOBAL)
  33. include(Internal/CheckSourceRuns)
  34. macro(CHECK_OBJCXX_SOURCE_RUNS SOURCE VAR)
  35. set(_CheckSourceRuns_old_signature 1)
  36. cmake_check_source_runs(OBJCXX "${SOURCE}" ${VAR} ${ARGN})
  37. unset(_CheckSourceRuns_old_signature)
  38. endmacro()