Merge topic 'cxx-checks-tolerate-unused-arguments'
[kiteware-cmake.git] / Modules / CheckOBJCSourceCompiles.cmake
blobbc0cac1a1597ab6ef71a006d46dc3b3994bb5493
1 # Distributed under the OSI-approved BSD 3-Clause License.  See accompanying
2 # file Copyright.txt or https://cmake.org/licensing for details.
4 #[=======================================================================[.rst:
5 CheckOBJCSourceCompiles
6 -----------------------
8 .. versionadded:: 3.16
10 Check if given Objective-C source compiles and links into an executable.
12 .. command:: check_objc_source_compiles
14   .. code-block:: cmake
16     check_objc_source_compiles(<code> <resultVar>
17                                [FAIL_REGEX <regex1> [<regex2>...]])
19   Check that the source supplied in ``<code>`` can be compiled as a Objectie-C source
20   file and linked as an executable (so it must contain at least a ``main()``
21   function). The result will be stored in the internal cache variable specified
22   by ``<resultVar>``, with a boolean true value for success and boolean false
23   for failure. If ``FAIL_REGEX`` is provided, then failure is determined by
24   checking if anything in the output matches any of the specified regular
25   expressions.
27   The check is only performed once, with the result cached in the variable named
28   by ``<resultVar>``. Every subsequent CMake run will reuse this cached value
29   rather than performing the check again, even if the ``<code>`` changes. In
30   order to force the check to be re-evaluated, the variable named by
31   ``<resultVar>`` must be manually removed from the cache.
33   The compile and link commands can be influenced by setting any of the
34   following variables prior to calling ``check_objc_source_compiles()``
36 .. include:: /module/CMAKE_REQUIRED_FLAGS.txt
38 .. include:: /module/CMAKE_REQUIRED_DEFINITIONS.txt
40 .. include:: /module/CMAKE_REQUIRED_INCLUDES.txt
42 .. include:: /module/CMAKE_REQUIRED_LINK_OPTIONS.txt
44 .. include:: /module/CMAKE_REQUIRED_LIBRARIES.txt
46 .. include:: /module/CMAKE_REQUIRED_QUIET.txt
48 #]=======================================================================]
50 include_guard(GLOBAL)
51 include(Internal/CheckSourceCompiles)
53 macro(CHECK_OBJC_SOURCE_COMPILES SOURCE VAR)
54   cmake_check_source_compiles(OBJC "${SOURCE}" ${VAR} ${ARGN})
55 endmacro()