summaryrefslogtreecommitdiffstats
path: root/Help/command
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2019-11-13 12:25:15 (GMT)
committerCraig Scott <craig.scott@crascit.com>2019-11-13 13:49:31 (GMT)
commitcc88ede7a37f8180f670c0d6036ba40cf005c7b9 (patch)
treeb8c6613d5c70f2253b5e28da77c459d7a7c69c1a /Help/command
parentdae9a808fe0cb039298fab75459e3803403c5194 (diff)
downloadCMake-cc88ede7a37f8180f670c0d6036ba40cf005c7b9.zip
CMake-cc88ede7a37f8180f670c0d6036ba40cf005c7b9.tar.gz
CMake-cc88ede7a37f8180f670c0d6036ba40cf005c7b9.tar.bz2
Help: Provide guidance on INTERFACE for target_precompile_headers()
Fixes: #19953
Diffstat (limited to 'Help/command')
-rw-r--r--Help/command/target_precompile_headers.rst14
1 files changed, 14 insertions, 0 deletions
diff --git a/Help/command/target_precompile_headers.rst b/Help/command/target_precompile_headers.rst
index 1be453d..569c7eb 100644
--- a/Help/command/target_precompile_headers.rst
+++ b/Help/command/target_precompile_headers.rst
@@ -30,6 +30,20 @@ items will populate the :prop_tgt:`PRECOMPILE_HEADERS` property of
(:ref:`IMPORTED targets <Imported Targets>` only support ``INTERFACE`` items).
Repeated calls for the same ``<target>`` will append items in the order called.
+Projects should generally avoid using ``PUBLIC`` or ``INTERFACE`` for targets
+that will be :ref:`exported <install(EXPORT)>`, or they should at least use
+the ``$<BUILD_INTERFACE:...>`` generator expression to prevent precompile
+headers from appearing in an installed exported target. Consumers of a target
+should typically be in control of what precompile headers they use, not have
+precompile headers forced on them by the targets being consumed (since
+precompile headers are not typically usage requirements). A notable exception
+to this is where an :ref:`interface library <Interface Libraries>` is created
+to define a commonly used set of precompile headers in one place and then other
+targets link to that interface library privately. In this case, the interface
+library exists specifically to propagate the precompile headers to its
+consumers and the consumer is effectively still in control, since it decides
+whether to link to the interface library or not.
+
The list of header files is used to generate a header file named
``cmake_pch.h|xx`` which is used to generate the precompiled header file
(``.pch``, ``.gch``, ``.pchi``) artifact. The ``cmake_pch.h|xx`` header