Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 3 additions & 59 deletions ucm/shared/vendor/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,59 +1,3 @@
function(EnableDept)
cmake_parse_arguments(DEPT "" "NAME;TAG" "GIT_URLS" ${ARGN})
find_program(GIT_EXECUTABLE git)
if(NOT GIT_EXECUTABLE)
message(FATAL_ERROR "git not found!")
endif()
foreach(GIT_URL IN LISTS DEPT_GIT_URLS)
execute_process(
COMMAND ${GIT_EXECUTABLE} ls-remote --heads "${GIT_URL}"
RESULT_VARIABLE GIT_RESULT
OUTPUT_QUIET
ERROR_QUIET
TIMEOUT 15
)
if(GIT_RESULT EQUAL 0)
set(VALID_GIT_URL ${GIT_URL})
break()
endif()
endforeach()
if(NOT VALID_GIT_URL)
message(FATAL_ERROR "all urls for ${DEPT_NAME} are not reachable!")
endif()
message(STATUS "Fetching ${DEPT_NAME}(${DEPT_TAG}) from ${VALID_GIT_URL}")
FetchContent_Declare(${DEPT_NAME} GIT_REPOSITORY ${VALID_GIT_URL} GIT_TAG ${DEPT_TAG} GIT_SHALLOW TRUE)
string(TOUPPER ${DEPT_NAME} NAME_UPPER)
set(${NAME_UPPER}_INSTALL OFF CACHE INTERNAL "" FORCE)
set(${NAME_UPPER}_BUILD_TESTS OFF CACHE INTERNAL "" FORCE)
set(${NAME_UPPER}_BUILD_EXAMPLES OFF CACHE INTERNAL "" FORCE)
FetchContent_MakeAvailable(${DEPT_NAME})
endfunction()

if(DOWNLOAD_DEPENDENCE)
include(FetchContent)
EnableDept(
NAME fmt
TAG 11.2.0
GIT_URLS
https://github.com/fmtlib/fmt.git
https://gitcode.com/GitHub_Trending/fm/fmt.git
)
EnableDept(
NAME spdlog
TAG v1.15.3
GIT_URLS
https://github.com/gabime/spdlog.git
https://gitcode.com/GitHub_Trending/sp/spdlog.git
)
EnableDept(
NAME pybind11
TAG v3.0.1
GIT_URLS
https://github.com/pybind/pybind11.git
https://gitcode.com/GitHub_Trending/py/pybind11.git
)
else()
add_subdirectory(fmt)
add_subdirectory(spdlog)
add_subdirectory(pybind11)
endif()
include(dep-fmt.cmake)
include(dep-spdlog.cmake)
include(dep-pybind11.cmake)
20 changes: 20 additions & 0 deletions ucm/shared/vendor/dep-fmt.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
set(FMT_INSTALL OFF CACHE INTERNAL "" FORCE)
set(FMT_BUILD_TESTS OFF CACHE INTERNAL "" FORCE)
set(FMT_BUILD_EXAMPLES OFF CACHE INTERNAL "" FORCE)

if(DOWNLOAD_DEPENDENCE)
set(DEP_FMT_NAME fmt)
set(DEP_FMT_TAG 11.2.0)
set(DEP_FMT_GIT_URLS
https://github.com/fmtlib/fmt.git
https://gitcode.com/GitHub_Trending/fm/fmt.git
)
include(helper.cmake)
find_reachable_git_url(REACHABLE_URL DEP_FMT_GIT_URLS)
include(FetchContent)
message(STATUS "Fetching ${DEP_FMT_NAME}(${DEP_FMT_TAG}) from ${REACHABLE_URL}")
FetchContent_Declare(${DEP_FMT_NAME} GIT_REPOSITORY ${REACHABLE_URL} GIT_TAG ${DEP_FMT_TAG} GIT_SHALLOW TRUE)
FetchContent_MakeAvailable(${DEP_FMT_NAME})
else()
add_subdirectory(fmt)
endif()
20 changes: 20 additions & 0 deletions ucm/shared/vendor/dep-pybind11.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
set(PYBIND11_INSTALL OFF CACHE INTERNAL "" FORCE)
set(PYBIND11_BUILD_TESTS OFF CACHE INTERNAL "" FORCE)
set(PYBIND11_BUILD_EXAMPLES OFF CACHE INTERNAL "" FORCE)

if(DOWNLOAD_DEPENDENCE)
set(DEP_PYBIND11_NAME pybind11)
set(DEP_PYBIND11_TAG v3.0.1)
set(DEP_PYBIND11_GIT_URLS
https://github.com/pybind/pybind11.git
https://gitcode.com/GitHub_Trending/py/pybind11.git
)
include(helper.cmake)
find_reachable_git_url(REACHABLE_URL DEP_PYBIND11_GIT_URLS)
include(FetchContent)
message(STATUS "Fetching ${DEP_PYBIND11_NAME}(${DEP_PYBIND11_TAG}) from ${REACHABLE_URL}")
FetchContent_Declare(${DEP_PYBIND11_NAME} GIT_REPOSITORY ${REACHABLE_URL} GIT_TAG ${DEP_PYBIND11_TAG} GIT_SHALLOW TRUE)
FetchContent_MakeAvailable(${DEP_PYBIND11_NAME})
else()
add_subdirectory(pybind11)
endif()
21 changes: 21 additions & 0 deletions ucm/shared/vendor/dep-spdlog.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
set(SPDLOG_INSTALL OFF CACHE INTERNAL "" FORCE)
set(SPDLOG_BUILD_TESTS OFF CACHE INTERNAL "" FORCE)
set(SPDLOG_BUILD_EXAMPLES OFF CACHE INTERNAL "" FORCE)
set(SPDLOG_FMT_EXTERNAL ON CACHE INTERNAL "" FORCE)

if(DOWNLOAD_DEPENDENCE)
set(DEP_SPDLOG_NAME spdlog)
set(DEP_SPDLOG_TAG v1.15.3)
set(DEP_SPDLOG_GIT_URLS
https://github.com/gabime/spdlog.git
https://gitcode.com/GitHub_Trending/sp/spdlog.git
)
include(helper.cmake)
find_reachable_git_url(REACHABLE_URL DEP_SPDLOG_GIT_URLS)
include(FetchContent)
message(STATUS "Fetching ${DEP_SPDLOG_NAME}(${DEP_SPDLOG_TAG}) from ${REACHABLE_URL}")
FetchContent_Declare(${DEP_SPDLOG_NAME} GIT_REPOSITORY ${REACHABLE_URL} GIT_TAG ${DEP_SPDLOG_TAG} GIT_SHALLOW TRUE)
FetchContent_MakeAvailable(${DEP_SPDLOG_NAME})
else()
add_subdirectory(spdlog)
endif()
27 changes: 27 additions & 0 deletions ucm/shared/vendor/helper.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
function(find_reachable_git_url OUT_REACHABLE_URL IN_URL_LIST)
find_program(GIT_EXECUTABLE git)
if(NOT GIT_EXECUTABLE)
message(FATAL_ERROR "git not found!")
endif()

if(DEFINED ${IN_URL_LIST})
set(URL_LIST ${${IN_URL_LIST}})
else()
set(URL_LIST ${ARGN})
endif()

foreach(GIT_URL IN LISTS URL_LIST)
execute_process(
COMMAND ${GIT_EXECUTABLE} ls-remote --heads "${GIT_URL}"
RESULT_VARIABLE GIT_RESULT
OUTPUT_QUIET ERROR_QUIET
TIMEOUT 5
)
if(GIT_RESULT EQUAL 0)
set(${OUT_REACHABLE_URL} ${GIT_URL} PARENT_SCOPE)
return()
endif()
endforeach()

message(FATAL_ERROR "All git URLs are not reachable!")
endfunction()