0a63cb9fe1
* build: refactor CMake scripts to use functions for variable scope Wrap multiple CMake scripts in functions to restrict variable scope and prevent unintended resets. This ensures better modularity and maintainability in the build process while adhering to modern CMake best practices. * refactor: simplify opentelemetry fetch logic Streamline the handling of OpenTelemetry dependencies by removing unnecessary function wrappers and directly implementing the fetching logic. This improves readability and maintainability while ensuring that relevant variables are correctly set within the proper scope. * refactor: encapsulate OpenTelemetry configuration in a function Wrap the OpenTelemetry setup in a function to limit variable scope, improving code organization and maintainability.
34 lines
743 B
CMake
34 lines
743 B
CMake
# Copyright (c) 2023, AgiBot Inc.
|
|
# All rights reserved.
|
|
|
|
include(FetchContent)
|
|
|
|
message(STATUS "get pybind11 ...")
|
|
|
|
set(pybind11_DOWNLOAD_URL
|
|
"https://github.com/pybind/pybind11/archive/v2.13.1.tar.gz"
|
|
CACHE STRING "")
|
|
|
|
if(pybind11_LOCAL_SOURCE)
|
|
FetchContent_Declare(
|
|
pybind11
|
|
SOURCE_DIR ${pybind11_LOCAL_SOURCE}
|
|
OVERRIDE_FIND_PACKAGE)
|
|
else()
|
|
FetchContent_Declare(
|
|
pybind11
|
|
URL ${pybind11_DOWNLOAD_URL}
|
|
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
|
|
OVERRIDE_FIND_PACKAGE)
|
|
endif()
|
|
|
|
# Wrap it in a function to restrict the scope of the variables
|
|
function(get_pybind11)
|
|
FetchContent_GetProperties(pybind11)
|
|
if(NOT pybind11_POPULATED)
|
|
FetchContent_MakeAvailable(pybind11)
|
|
endif()
|
|
endfunction()
|
|
|
|
get_pybind11()
|