mirror of
https://github.com/Kitware/CMake.git
synced 2026-03-07 23:28:36 -06:00
try_compile: Add options to specify language standards
Give `try_compile` callers a way to control the `CXX_STANDARD`, `CXX_STANDARD_REQUIRED`, and `CXX_EXTENSIONS` properties of the generated test target (or the `C` equivalents) in order to compile a test source for a particular language standard. Issue: #16456
This commit is contained in:
@@ -35,7 +35,11 @@ Try Compiling Source Files
|
||||
[COMPILE_DEFINITIONS <defs>...]
|
||||
[LINK_LIBRARIES <libs>...]
|
||||
[OUTPUT_VARIABLE <var>]
|
||||
[COPY_FILE <fileName> [COPY_FILE_ERROR <var>]])
|
||||
[COPY_FILE <fileName> [COPY_FILE_ERROR <var>]]
|
||||
[<LANG>_STANDARD <std>]
|
||||
[<LANG>_STANDARD_REQUIRED <bool>]
|
||||
[<LANG>_EXTENSIONS <bool>]
|
||||
)
|
||||
|
||||
Try building an executable from one or more source files. The success or
|
||||
failure of the ``try_compile``, i.e. ``TRUE`` or ``FALSE`` respectively, is
|
||||
@@ -82,6 +86,18 @@ The options are:
|
||||
``OUTPUT_VARIABLE <var>``
|
||||
Store the output from the build process the given variable.
|
||||
|
||||
``<LANG>_STANDARD <std>``
|
||||
Specify the :prop_tgt:`C_STANDARD` or :prop_tgt:`CXX_STANDARD`
|
||||
target property of the generated project.
|
||||
|
||||
``<LANG>_STANDARD_REQUIRED <bool>``
|
||||
Specify the :prop_tgt:`C_STANDARD_REQUIRED` or
|
||||
:prop_tgt:`CXX_STANDARD_REQUIRED` target property of the generated project.
|
||||
|
||||
``<LANG>_EXTENSIONS <bool>``
|
||||
Specify the :prop_tgt:`C_EXTENSIONS` or :prop_tgt:`CXX_EXTENSIONS`
|
||||
target property of the generated project.
|
||||
|
||||
In this version all files in ``<bindir>/CMakeFiles/CMakeTmp`` will be
|
||||
cleaned automatically. For debugging, ``--debug-trycompile`` can be
|
||||
passed to ``cmake`` to avoid this clean. However, multiple sequential
|
||||
|
||||
5
Help/release/dev/try_compile-lang-std.rst
Normal file
5
Help/release/dev/try_compile-lang-std.rst
Normal file
@@ -0,0 +1,5 @@
|
||||
try_compile-lang-std
|
||||
--------------------
|
||||
|
||||
* The :command:`try_compile` command source file signature gained new options
|
||||
to specify the language standard to use in the generated test project.
|
||||
Reference in New Issue
Block a user