summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
authorMarcus Müller <mmueller@gnuradio.org>2021-06-05 16:13:16 +0200
committermormj <34754695+mormj@users.noreply.github.com>2021-07-19 09:57:48 -0400
commit2d51507e10f767ddc941220860b7ebfd29e6c15e (patch)
treef6338ba903103b6a83f04c1865a0871a8cf45367 /cmake
parent6529fb50840529f9f3a664d27ff5a8cf45f76ef4 (diff)
pybind: add precompilation of pybind headers to pybind targets
Signed-off-by: Marcus Müller <mmueller@gnuradio.org>
Diffstat (limited to 'cmake')
-rw-r--r--cmake/Modules/GrPybind.cmake16
1 files changed, 16 insertions, 0 deletions
diff --git a/cmake/Modules/GrPybind.cmake b/cmake/Modules/GrPybind.cmake
index 7da4e36a56..a000f8e5e4 100644
--- a/cmake/Modules/GrPybind.cmake
+++ b/cmake/Modules/GrPybind.cmake
@@ -154,6 +154,22 @@ target_include_directories(${name}_python PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/${updir}/lib
${CMAKE_CURRENT_SOURCE_DIR}/${updir}/include
)
+
+# Precompile the pybind11 header
+# This should speed up building of the python bindings at least in larger modules
+# This functionality is only available in CMake >= 3.16
+if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.16.0")
+ target_precompile_headers(
+ ${name}_python
+ PRIVATE
+ ${pybind11_INCLUDE_DIR}/pybind11/pybind11.h
+ ${pybind11_INCLUDE_DIR}/pybind11/embed.h
+ ${pybind11_INCLUDE_DIR}/pybind11/complex.h
+ ${pybind11_INCLUDE_DIR}/pybind11/operators.h
+ ${pybind11_INCLUDE_DIR}/pybind11/stl.h
+)
+endif()
+
target_link_libraries(${name}_python PRIVATE ${Boost_LIBRARIES} pybind11::pybind11 Python::Module Python::NumPy gnuradio-${MODULE_NAME})
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR
CMAKE_CXX_COMPILER_ID STREQUAL "GNU")