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