Merge topic 'cuda_add_12.8_new_sm_support'
[kiteware-cmake.git] / Modules / CheckCSourceRuns.cmake
blob5edfe378ec8932ac6551545656a76e7f408fd338
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 CheckCSourceRuns
6 ----------------
8 Check once if given C source compiles and links into an executable and can
9 subsequently be run.
11 .. command:: check_c_source_runs
13   .. code-block:: cmake
15     check_c_source_runs(<code> <resultVar>)
17   Check once that the source supplied in ``<code>`` can be built, linked as an
18   executable, and then run. The ``<code>`` must contain at least a ``main()``
19   function.
21   The result is stored in the internal cache variable specified by
22   ``<resultVar>``. If the code builds and runs with exit code ``0``, success is
23   indicated by boolean ``true``. Failure to build or run is indicated by boolean
24   ``false``, such as an empty string or an error message.
26   See also :command:`check_source_runs` for a more general command syntax.
28   The compile and link commands can be influenced by setting any of the
29   following variables prior to calling ``check_c_source_runs()``:
31 .. include:: /module/CMAKE_REQUIRED_FLAGS.txt
33 .. include:: /module/CMAKE_REQUIRED_DEFINITIONS.txt
35 .. include:: /module/CMAKE_REQUIRED_INCLUDES.txt
37 .. include:: /module/CMAKE_REQUIRED_LINK_OPTIONS.txt
39 .. include:: /module/CMAKE_REQUIRED_LIBRARIES.txt
41 .. include:: /module/CMAKE_REQUIRED_LINK_DIRECTORIES.txt
43 .. include:: /module/CMAKE_REQUIRED_QUIET.txt
45 #]=======================================================================]
47 include_guard(GLOBAL)
48 include(Internal/CheckSourceRuns)
50 macro(CHECK_C_SOURCE_RUNS SOURCE VAR)
51   set(_CheckSourceRuns_old_signature 1)
52   cmake_check_source_runs(C "${SOURCE}" ${VAR} ${ARGN})
53   unset(_CheckSourceRuns_old_signature)
54 endmacro()