$NetBSD: patch-tree_CMakeLists.txt,v 1.2 2025/04/15 16:02:34 adam Exp $ Use system pybind11 and absl. https://github.com/google-deepmind/tree/pull/73 --- tree/CMakeLists.txt.orig 2025-01-30 17:23:48.000000000 +0000 +++ tree/CMakeLists.txt @@ -7,8 +7,8 @@ cmake_policy(SET CMP0135 NEW) project (tree LANGUAGES CXX) -option(USE_SYSTEM_ABSEIL "Force use of system abseil-cpp" OFF) -option(USE_SYSTEM_PYBIND11 "Force use of system pybind11" OFF) +option(USE_SYSTEM_ABSEIL "Force use of system abseil-cpp" ON) +option(USE_SYSTEM_PYBIND11 "Force use of system pybind11" ON) # Required for Python.h and python binding. find_package(Python3 COMPONENTS Interpreter Development) @@ -57,9 +57,6 @@ if(APPLE) set (CMAKE_FIND_FRAMEWORK LAST) endif() -# Use `FetchContent` module to manage all external dependencies (i.e. -# abseil-cpp and pybind11). -include(FetchContent) # Needed to disable Abseil tests. set(BUILD_TESTING OFF) @@ -70,45 +67,14 @@ if (USE_SYSTEM_ABSEIL) set(ABSEIL_FIND_PACKAGE_ARGS FIND_PACKAGE_ARGS) endif() -# Include abseil-cpp. -set(ABSEIL_REPO https://github.com/abseil/abseil-cpp) -set(ABSEIL_CMAKE_ARGS - "-DCMAKE_INSTALL_PREFIX=${CMAKE_SOURCE_DIR}/abseil-cpp" - "-DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}" - "-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}" - "-DCMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}" - "-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}" - "-DCMAKE_POSITION_INDEPENDENT_CODE=${CMAKE_POSITION_INDEPENDENT_CODE}" - "-DLIBRARY_OUTPUT_PATH=${CMAKE_SOURCE_DIR}/abseil-cpp/lib" - "-DABSL_PROPAGATE_CXX_STD=ON") -if(DEFINED CMAKE_OSX_ARCHITECTURES) - set(ABSEIL_CMAKE_ARGS - ${ABSEIL_CMAKE_ARGS} - "-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}") -endif() - -FetchContent_Declare( - absl - URL ${ABSEIL_REPO}/archive/refs/tags/20220623.2.tar.gz - URL_HASH SHA256=773652c0fc276bcd5c461668dc112d0e3b6cde499600bfe3499c5fdda4ed4a5b - CMAKE_ARGS ${ABSEIL_CMAKE_ARGS} - EXCLUDE_FROM_ALL - ${ABSEIL_FIND_PACKAGE_ARGS}) - # Try to find pybind11 package system-wide first. if (USE_SYSTEM_PYBIND11) message(STATUS "Use system pybind11: ${USE_SYSTEM_PYBIND11}") set(PYBIND11_FIND_PACKAGE_ARGS FIND_PACKAGE_ARGS) endif() -FetchContent_Declare( - pybind11 - URL https://github.com/pybind/pybind11/archive/refs/tags/v2.10.1.tar.gz - URL_HASH SHA256=111014b516b625083bef701df7880f78c2243835abdb263065b6b59b960b6bad - ${PYBIND11_FIND_PACKAGE_ARGS}) - -FetchContent_MakeAvailable(absl pybind11) - +find_package(pybind11 REQUIRED CONFIG) +find_package(absl REQUIRED) # Define pybind11 tree module. pybind11_add_module(_tree tree.h tree.cc)