CheckOBJCXXSourceCompiles.cmake 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. CheckOBJCXXSourceCompiles
  5. -------------------------
  6. .. versionadded:: 3.16
  7. Check if given Objective-C++ source compiles and links into an executable.
  8. .. command:: check_objcxx_source_compiles
  9. .. code-block:: cmake
  10. check_objcxx_source_compiles(<code> <resultVar>
  11. [FAIL_REGEX <regex1> [<regex2>...]])
  12. Check that the source supplied in ``<code>`` can be compiled as a Objective-C++ source
  13. file and linked as an executable (so it must contain at least a ``main()``
  14. function). The result will be stored in the internal cache variable specified
  15. by ``<resultVar>``, with a boolean true value for success and boolean false
  16. for failure. If ``FAIL_REGEX`` is provided, then failure is determined by
  17. checking if anything in the output matches any of the specified regular
  18. expressions.
  19. The check is only performed once, with the result cached in the variable named
  20. by ``<resultVar>``. Every subsequent CMake run will reuse this cached value
  21. rather than performing the check again, even if the ``<code>`` changes. In
  22. order to force the check to be re-evaluated, the variable named by
  23. ``<resultVar>`` must be manually removed from the cache.
  24. The compile and link commands can be influenced by setting any of the
  25. following variables prior to calling ``check_objcxx_source_compiles()``
  26. .. include:: /module/CMAKE_REQUIRED_FLAGS.txt
  27. .. include:: /module/CMAKE_REQUIRED_DEFINITIONS.txt
  28. .. include:: /module/CMAKE_REQUIRED_INCLUDES.txt
  29. .. include:: /module/CMAKE_REQUIRED_LINK_OPTIONS.txt
  30. .. include:: /module/CMAKE_REQUIRED_LIBRARIES.txt
  31. .. include:: /module/CMAKE_REQUIRED_QUIET.txt
  32. #]=======================================================================]
  33. include_guard(GLOBAL)
  34. include(Internal/CheckSourceCompiles)
  35. macro(CHECK_OBJCXX_SOURCE_COMPILES SOURCE VAR)
  36. cmake_check_source_compiles(OBJCXX "${SOURCE}" ${VAR} ${ARGN})
  37. endmacro()