$NetBSD: patch-tree_CMakeLists.txt,v 1.1 2024/08/05 20:38:39 adam Exp $ Use system pybind11 and absl. https://github.com/google-deepmind/tree/pull/73 --- tree/CMakeLists.txt.orig 2024-08-05 19:44:05.774867683 +0000 +++ tree/CMakeLists.txt @@ -51,68 +51,12 @@ if(APPLE) 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}) -endif() - -# Needed to disable Abseil tests. -set (BUILD_TESTING OFF) - -# Include abseil-cpp. -set(ABSEIL_VER 20210324.2) -include(ExternalProject) -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") -if(DEFINED CMAKE_OSX_ARCHITECTURES) - set(ABSEIL_CMAKE_ARGS - ${ABSEIL_CMAKE_ARGS} - "-DCMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}") -endif() -ExternalProject_Add(abseil-cpp - GIT_REPOSITORY https://github.com/abseil/abseil-cpp.git - GIT_TAG ${ABSEIL_VER} - PREFIX ${CMAKE_SOURCE_DIR}/abseil-cpp - CMAKE_ARGS ${ABSEIL_CMAKE_ARGS} -) -ExternalProject_Get_Property(abseil-cpp install_dir) -set(abseil_install_dir ${install_dir}) -include_directories (${abseil_install_dir}/include) - +find_package(pybind11 REQUIRED CONFIG) +find_package(absl REQUIRED) # Define pybind11 tree module. pybind11_add_module(_tree tree.h tree.cc) -add_dependencies(_tree abseil-cpp) - -if (WIN32 OR MSVC) - set(ABSEIL_LIB_PREF "absl") - set(LIB_SUFF "lib") -else() - set(ABSEIL_LIB_PREF "libabsl") - set(LIB_SUFF "a") -endif() - -# Link abseil static libs. -# We don't use find_library here to force cmake to build abseil before linking. -set(ABSEIL_LIBS int128 raw_hash_set raw_logging_internal strings throw_delegate) -foreach(ABSEIL_LIB IN LISTS ABSEIL_LIBS) - target_link_libraries(_tree PRIVATE - "${abseil_install_dir}/lib/${ABSEIL_LIB_PREF}_${ABSEIL_LIB}.${LIB_SUFF}") -endforeach() +target_link_libraries(_tree PRIVATE absl::int128 absl::raw_hash_set absl::raw_logging_internal absl::strings absl::throw_delegate) # Make the module private to tree package. set_target_properties(_tree PROPERTIES OUTPUT_NAME tree/_tree)