6 :command:`try_compile` passes platform variables in project mode.
8 The :command:`try_compile` command :ref:`source file <Try Compiling Source
9 Files>` signature propagates CMake variables containing platform settings,
10 and those specified by the :variable:`CMAKE_TRY_COMPILE_PLATFORM_VARIABLES`
11 variable, into the generated test project. This helps the test project drive
12 the toolchain the same way the calling project will. In CMake 3.23 and below,
13 the :ref:`whole-project <Try Compiling Whole Projects>` signature does not
14 propagate platform variables automatically. CMake 3.24 and above prefer to
15 propagate platform variables in the :ref:`whole-project <Try Compiling Whole
16 Projects>` signature. This policy provides compatibility with projects that
17 have not been updated to expect the behavior.
19 The ``OLD`` behavior for this policy is to not pass any additional variables to
20 the :ref:`whole-project <Try Compiling Whole Projects>` signature.
21 The ``NEW`` behavior for this policy is to pass the same variables that the
22 :ref:`source file <Try Compiling Source Files>` signature does.
24 Regardless of the policy setting, the
25 :variable:`CMAKE_TRY_COMPILE_NO_PLATFORM_VARIABLES` variable may be set
26 to suppress passing the platform variables through either signature.
28 This policy was introduced in CMake version 3.24. Use the
29 :command:`cmake_policy` command to set this policy to ``OLD`` or ``NEW``
30 explicitly. Unlike many policies, CMake version |release| does *not* warn
31 by default when this policy is not set and simply uses ``OLD`` behavior.
33 .. include:: DEPRECATED.txt