Files
cmake/Help/policy/CMP0181.rst
T
Brad King 5e52f92a2a try_compile: Add support for toolchain files to query CMP0181
Follow the approach from commit 92320466dd (try_compile: Restore
platform-default link flags in pre-CMP0210 projects, 2026-08-22)
to make the CMP0181 policy setting available in `try_compile`
projects before the toolchain file is loaded.

Fixes: #28108
2026-09-22 11:35:05 -04:00

46 lines
1.7 KiB
ReStructuredText

CMP0181
-------
.. versionadded:: 4.0
The :variable:`CMAKE_EXE_LINKER_FLAGS`,
:variable:`CMAKE_EXE_LINKER_FLAGS_<CONFIG>`,
:variable:`CMAKE_SHARED_LINKER_FLAGS`,
:variable:`CMAKE_SHARED_LINKER_FLAGS_<CONFIG>`,
:variable:`CMAKE_MODULE_LINKER_FLAGS`,
and :variable:`CMAKE_MODULE_LINKER_FLAGS_<CONFIG>` variables are parsed and
re-quoted and support the ``LINKER:`` prefix.
CMake 3.31 and below use the content of these variables as is.
CMake 4.0 and above parse the content of these variables and manage the
escaping of special characters. Moreover, the ``LINKER:`` prefix is now
recognized and expanded.
The ``OLD`` behavior of this policy is to consume the content of the
:variable:`CMAKE_EXE_LINKER_FLAGS`,
:variable:`CMAKE_EXE_LINKER_FLAGS_<CONFIG>`,
:variable:`CMAKE_SHARED_LINKER_FLAGS`,
:variable:`CMAKE_SHARED_LINKER_FLAGS_<CONFIG>`,
:variable:`CMAKE_MODULE_LINKER_FLAGS`,
and :variable:`CMAKE_MODULE_LINKER_FLAGS_<CONFIG>` variables as is.
The ``NEW`` behavior of this policy is to parse and re-quote the content of the
:variable:`CMAKE_EXE_LINKER_FLAGS`,
:variable:`CMAKE_EXE_LINKER_FLAGS_<CONFIG>`,
:variable:`CMAKE_SHARED_LINKER_FLAGS`,
:variable:`CMAKE_SHARED_LINKER_FLAGS_<CONFIG>`,
:variable:`CMAKE_MODULE_LINKER_FLAGS`,
and :variable:`CMAKE_MODULE_LINKER_FLAGS_<CONFIG>` variables as well as to
expand the ``LINKER:`` prefix.
.. |INTRODUCED_IN_CMAKE_VERSION| replace:: 4.0
.. |WARNS_OR_DOES_NOT_WARN| replace:: does *not* warn
.. include:: include/STANDARD_ADVICE.rst
.. versionchanged:: 4.5
The policy is now set in :command:`try_compile` test projects early enough
to be queried by :variable:`toolchain files <CMAKE_TOOLCHAIN_FILE>`.
.. include:: include/DEPRECATED.rst