@@ -84,11 +84,7 @@ variables to guide Python and C++ standard detection should be set
84
84
and libraries as needed, and C++ compile definitions attached. This
85
85
target is suitable for linking to an independently constructed (through
86
86
``add_library ``, not ``pybind11_add_module ``) target in the consuming
87
- project. Note that this target has only build *requirements * attached
88
- and is missing the several build *recommendations * supplied by
89
- ``pybind11_add_module `` (see :ref: `faq <faq:symhidden >` for discussion
90
- of desirability).
91
- A working example can be found at [test_installed_target ]_ .
87
+ project. A working example can be found at [test_installed_target ]_ .
92
88
93
89
.. code-block :: cmake
94
90
@@ -102,5 +98,20 @@ A working example can be found at [test_installed_target]_ .
102
98
set_target_properties(example PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}"
103
99
SUFFIX "${PYTHON_MODULE_EXTENSION}")
104
100
101
+ ..warning:
102
+
103
+ Since pybind11 is a metatemplate library, it is crucial that certain
104
+ compiler flags are provided to ensure high quality code generation. In
105
+ contrast to the ``pybind11_add_module() `` command, the CMake interface
106
+ library only provides the *minimal * set of parameters to ensure that the
107
+ code using pybind11 compiles, but it does **not ** pass these extra compiler
108
+ flags (i.e. this is up to you).
109
+
110
+ These include Link Time Optimization (``-flto `` on GCC/Clang/ICPC, ``/GL ``
111
+ and ``/LTCG `` on Visual Studio). Default-hidden symbols on GCC/Clang/ICPC
112
+ ("-fvisibility=hidden") and .OBJ files with many sections on Visual Studio
113
+ ("/bigobj"). The :ref: `FAQ <faq:symhidden >` contains an
114
+ explanation on why these are needed.
115
+
105
116
.. [test_installed_target ] https://github.com/pybind/pybind11/blob/master/tests/test_installed_target/CMakeLists.txt
106
117
0 commit comments