Skip to content

Commit 735f7c3

Browse files
committed
make bolder docs warning about recc flags not in cmake interface lib. fix up gitignore for add_subdir build.
1 parent 1cd37a3 commit 735f7c3

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,5 @@ MANIFEST
3333
/cmake/
3434
.cache/
3535
sosize-*.txt
36-
share/cmake/pybind11/pybind11*cmake
36+
pybind11Config*.cmake
37+
pybind11Targets.cmake

docs/compiling.rst

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,11 +84,7 @@ variables to guide Python and C++ standard detection should be set
8484
and libraries as needed, and C++ compile definitions attached. This
8585
target is suitable for linking to an independently constructed (through
8686
``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]_ .
9288

9389
.. code-block:: cmake
9490
@@ -102,5 +98,20 @@ A working example can be found at [test_installed_target]_ .
10298
set_target_properties(example PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}"
10399
SUFFIX "${PYTHON_MODULE_EXTENSION}")
104100
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+
105116
.. [test_installed_target] https://github.com/pybind/pybind11/blob/master/tests/test_installed_target/CMakeLists.txt
106117

0 commit comments

Comments
 (0)