janitor

janitor
git clone https://git.prime8.dev/janitor.git
Log | Files | Refs | README | LICENSE

pybind11.cmake (1542B)


      1 function(download_pybind11)
      2   if(CMAKE_VERSION VERSION_LESS 3.11)
      3     list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/Modules)
      4   endif()
      5 
      6   include(FetchContent)
      7 
      8   set(pybind11_URL  "https://github.com/pybind/pybind11/archive/refs/tags/v2.10.2.tar.gz")
      9   set(pybind11_URL2 "https://huggingface.co/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/pybind11-2.10.2.tar.gz")
     10   set(pybind11_HASH "SHA256=93bd1e625e43e03028a3ea7389bba5d3f9f2596abc074b068e70f4ef9b1314ae")
     11 
     12   # If you don't have access to the Internet,
     13   # please pre-download pybind11
     14   set(possible_file_locations
     15     $ENV{HOME}/Downloads/pybind11-2.10.2.tar.gz
     16     ${PROJECT_SOURCE_DIR}/pybind11-2.10.2.tar.gz
     17     ${PROJECT_BINARY_DIR}/pybind11-2.10.2.tar.gz
     18     /tmp/pybind11-2.10.2.tar.gz
     19     /star-fj/fangjun/download/github/pybind11-2.10.2.tar.gz
     20   )
     21 
     22   foreach(f IN LISTS possible_file_locations)
     23     if(EXISTS ${f})
     24       set(pybind11_URL  "${f}")
     25       file(TO_CMAKE_PATH "${pybind11_URL}" pybind11_URL)
     26       set(pybind11_URL2)
     27       break()
     28     endif()
     29   endforeach()
     30 
     31   FetchContent_Declare(pybind11
     32     URL
     33       ${pybind11_URL}
     34       ${pybind11_URL2}
     35     URL_HASH          ${pybind11_HASH}
     36   )
     37 
     38   FetchContent_GetProperties(pybind11)
     39   if(NOT pybind11_POPULATED)
     40     message(STATUS "Downloading pybind11 from ${pybind11_URL}")
     41     FetchContent_Populate(pybind11)
     42   endif()
     43   message(STATUS "pybind11 is downloaded to ${pybind11_SOURCE_DIR}")
     44   add_subdirectory(${pybind11_SOURCE_DIR} ${pybind11_BINARY_DIR} EXCLUDE_FROM_ALL)
     45 endfunction()
     46 
     47 download_pybind11()