Skip to content

Commit

Permalink
cmake API documentation improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
wjakob committed Jun 1, 2023
1 parent f525139 commit 9a3eff6
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions docs/api_cmake.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ The high-level interface consists of just one CMake command:
nanobind_build_library(
my_ext # Target name
NB_STATIC STABLE_API LTO # Optional flags (see below)
NB_STATIC STABLE_ABI LTO # Optional flags (see below)
my_ext.h # Source code files below
my_ext.cpp)
Expand All @@ -45,14 +45,16 @@ The high-level interface consists of just one CMake command:
- Perform a `stable ABI
<https://docs.python.org/3/c-api/stable.html>`_ build, making it
possible to use a compiled extension across Python minor versions.
Only Python >= 3.12 is supported. The flag is ignored on older
Python versions.
* - ``NB_SHARED``
- Compile the core nanobind library as a shared library (the default).
The flag is ignored on Python versions older than < 3.12.
* - ``NB_STATIC``
- Compile the core nanobind library as a static library. This
simplifies redistribution but unnecessarily increases the binary
storage footprint when a project contains many Python extensions.
simplifies redistribution but can increase the combined binary
storage footprint when a project contains many Python extensions
(this is the default).
* - ``NB_SHARED``
- The opposite of ``NB_STATIC``: compile the core nanobind library
as a shared library for use in projects that consist of multiple
extensions.
* - ``PROTECT_STACK``
- Don't remove stack smashing-related protections.
* - ``LTO``
Expand Down Expand Up @@ -219,7 +221,7 @@ is equivalent to
nanobind_link_options(my_ext)
# Statically link against libstdc++/libgcc when targeting musllinux
nanobind_musl_static_libcpp(${name})
nanobind_musl_static_libcpp(my_ext)
The various commands are described below:

Expand All @@ -234,7 +236,7 @@ The various commands are described below:
:widths: 10 50

* - ``-static``
- Perform a static library build (shared is the default).
- Perform a static library build (without this suffix, a shared build is used)
* - ``-abi3``
- Perform a stable ABI build targeting Python v3.12+.

Expand Down Expand Up @@ -278,16 +280,6 @@ The various commands are described below:
nanobind_strip(my_target)
.. cmake:command:: nanobind_strip
This function strips unused and debug symbols in ``Release`` and
``MinSizeRel`` builds on Linux and macOS. It expects a single target as
argument, as in

.. code-block:: cmake
nanobind_strip(my_target)
.. cmake:command:: nanobind_disable_stack_protector
The stack protector affects the binary size of bindings negatively (+8%
Expand Down Expand Up @@ -344,3 +336,10 @@ The various commands are described below:
``-static-libgcc`` to ``gcc`` when the environment variable
``AUDITWHEEL_PLAT`` contains the string ``musllinux``, which indicates a
cibuildwheel build targeting that platform.

The function expects a single target as argument, as in

.. code-block:: cmake
nanobind_musl_static_libcpp(my_target)

0 comments on commit 9a3eff6

Please sign in to comment.