From 940c425c19e50a9ded2629422db54785802143af Mon Sep 17 00:00:00 2001 From: Guilhem Saurel Date: Tue, 21 Jan 2025 17:15:53 +0100 Subject: [PATCH] CMake: add DART_USE_SYSTEM_PYBIND11 (#1907) --- CMakeLists.txt | 1 + python/CMakeLists.txt | 18 +++++++++++------- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fdfe749467f2b..a826e884bd229 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,6 +101,7 @@ dart_option(DART_FORCE_COLORED_OUTPUT dart_option(DART_USE_SYSTEM_IMGUI "Use system ImGui" OFF) dart_option(DART_USE_SYSTEM_GOOGLEBENCHMARK "Use system GoogleBenchmark" OFF) dart_option(DART_USE_SYSTEM_GOOGLETEST "Use system GoogleTest" OFF) +dart_option(DART_USE_SYSTEM_PYBIND11 "Use system pybind11" OFF) #=============================================================================== # Print intro diff --git a/python/CMakeLists.txt b/python/CMakeLists.txt index 37cadf4f8de14..de79041bb4b7c 100644 --- a/python/CMakeLists.txt +++ b/python/CMakeLists.txt @@ -6,13 +6,17 @@ if(NOT DART_BUILD_DARTPY) endif() # Set up pybind11 -include(FetchContent) -FetchContent_Declare( - pybind11 - GIT_REPOSITORY https://github.com/pybind/pybind11 - GIT_TAG v2.12.0 -) -FetchContent_MakeAvailable(pybind11) +if(DART_USE_SYSTEM_PYBIND11) + find_package(pybind11 CONFIG REQUIRED) +else() + include(FetchContent) + FetchContent_Declare( + pybind11 + GIT_REPOSITORY https://github.com/pybind/pybind11 + GIT_TAG v2.12.0 + ) + FetchContent_MakeAvailable(pybind11) +endif() if(NOT pybind11_FOUND) message(WARNING "Disabling [dartpy] due to missing pybind11 >= 2.2.0.")