From 16351ed6651b0e88d447b5c175e85e6757e3668b Mon Sep 17 00:00:00 2001 From: Josh Polansky Date: Sat, 28 Sep 2024 18:29:19 -0700 Subject: [PATCH] Check if pybind already exists --- CMakeLists.txt | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b8e2f98..84fef5c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -74,11 +74,15 @@ endif() if(BUILD_PYTHON_MODULE) - # Check if pybind11 exists as a subdirectory - if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/pybind11) - add_subdirectory(pybind11) - else() - find_package(pybind11 2.6 REQUIRED) + + # check if pybind11 is already available + if(NOT TARGET pybind11::module) + # Check if pybind11 exists as a subdirectory + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/pybind11) + add_subdirectory(pybind11) + else() + find_package(pybind11 2.6 REQUIRED) + endif() endif() pybind11_add_module(python_ruckig src/ruckig/python.cpp)