File use-system-pybind11.patch of Package python-dm-tree
From 5dd767f3e60d9e4c58f6ee7764b24e1dec2c5edb Mon Sep 17 00:00:00 2001
From: Alexander Tsvyashchenko <ndl@endl.ch>
Date: Sat, 1 Jan 2022 13:22:47 +0100
Subject: [PATCH] Use system pybind11 and absl when available
Current CMakeLists.txt always downloads and builds `pybind11` and `absl` which conflicts with packaging best practices in some of the distributions. This change uses system libraries (if available) and falls back to the old behavior (if not).
---
tree/CMakeLists.txt | 122 ++++++++++++++++++++++++--------------------
1 file changed, 66 insertions(+), 56 deletions(-)
Index: dm-tree-0.1.8/tree/CMakeLists.txt
===================================================================
--- dm-tree-0.1.8.orig/tree/CMakeLists.txt
+++ dm-tree-0.1.8/tree/CMakeLists.txt
@@ -50,18 +50,21 @@ if(APPLE)
set (CMAKE_FIND_FRAMEWORK LAST)
endif()
-# Fetch pybind to be able to use pybind11_add_module symbol.
-set(PYBIND_VER v2.10.1)
-include(FetchContent)
-FetchContent_Declare(
- pybind11
- GIT_REPOSITORY https://github.com/pybind/pybind11
- GIT_TAG ${PYBIND_VER}
-)
-if(NOT pybind11_POPULATED)
- FetchContent_Populate(pybind11)
- add_subdirectory(${pybind11_SOURCE_DIR} ${pybind11_BINARY_DIR})
- include_directories(${pybind11_INCLUDE_DIR})
+find_package(pybind11 CONFIG)
+if (NOT pybind11_FOUND)
+ # Fetch pybind to be able to use pybind11_add_module symbol.
+ set(PYBIND_VER v2.10.1)
+ include(FetchContent)
+ FetchContent_Declare(
+ pybind11
+ GIT_REPOSITORY https://github.com/pybind/pybind11
+ GIT_TAG ${PYBIND_VER}
+ )
+ if(NOT pybind11_POPULATED)
+ FetchContent_Populate(pybind11)
+ add_subdirectory(${pybind11_SOURCE_DIR} ${pybind11_BINARY_DIR})
+ include_directories(${pybind11_INCLUDE_DIR})
+ endif()
endif()
# Define pybind11 tree module.