|
1 | | -function(EnableDept) |
2 | | - cmake_parse_arguments(DEPT "" "NAME;TAG" "GIT_URLS" ${ARGN}) |
3 | | - find_program(GIT_EXECUTABLE git) |
4 | | - if(NOT GIT_EXECUTABLE) |
5 | | - message(FATAL_ERROR "git not found!") |
6 | | - endif() |
7 | | - foreach(GIT_URL IN LISTS DEPT_GIT_URLS) |
8 | | - execute_process( |
9 | | - COMMAND ${GIT_EXECUTABLE} ls-remote --heads "${GIT_URL}" |
10 | | - RESULT_VARIABLE GIT_RESULT |
11 | | - OUTPUT_QUIET |
12 | | - ERROR_QUIET |
13 | | - TIMEOUT 15 |
14 | | - ) |
15 | | - if(GIT_RESULT EQUAL 0) |
16 | | - set(VALID_GIT_URL ${GIT_URL}) |
17 | | - break() |
18 | | - endif() |
19 | | - endforeach() |
20 | | - if(NOT VALID_GIT_URL) |
21 | | - message(FATAL_ERROR "all urls for ${DEPT_NAME} are not reachable!") |
22 | | - endif() |
23 | | - message(STATUS "Fetching ${DEPT_NAME}(${DEPT_TAG}) from ${VALID_GIT_URL}") |
24 | | - FetchContent_Declare(${DEPT_NAME} GIT_REPOSITORY ${VALID_GIT_URL} GIT_TAG ${DEPT_TAG} GIT_SHALLOW TRUE) |
25 | | - string(TOUPPER ${DEPT_NAME} NAME_UPPER) |
26 | | - set(${NAME_UPPER}_INSTALL OFF CACHE INTERNAL "" FORCE) |
27 | | - set(${NAME_UPPER}_BUILD_TESTS OFF CACHE INTERNAL "" FORCE) |
28 | | - set(${NAME_UPPER}_BUILD_EXAMPLES OFF CACHE INTERNAL "" FORCE) |
29 | | - FetchContent_MakeAvailable(${DEPT_NAME}) |
30 | | -endfunction() |
31 | | - |
32 | | -if(DOWNLOAD_DEPENDENCE) |
33 | | - include(FetchContent) |
34 | | - EnableDept( |
35 | | - NAME fmt |
36 | | - TAG 11.2.0 |
37 | | - GIT_URLS |
38 | | - https://github.com/fmtlib/fmt.git |
39 | | - https://gitcode.com/GitHub_Trending/fm/fmt.git |
40 | | - ) |
41 | | - EnableDept( |
42 | | - NAME spdlog |
43 | | - TAG v1.15.3 |
44 | | - GIT_URLS |
45 | | - https://github.com/gabime/spdlog.git |
46 | | - https://gitcode.com/GitHub_Trending/sp/spdlog.git |
47 | | - ) |
48 | | - EnableDept( |
49 | | - NAME pybind11 |
50 | | - TAG v3.0.1 |
51 | | - GIT_URLS |
52 | | - https://github.com/pybind/pybind11.git |
53 | | - https://gitcode.com/GitHub_Trending/py/pybind11.git |
54 | | - ) |
55 | | -else() |
56 | | - add_subdirectory(fmt) |
57 | | - add_subdirectory(spdlog) |
58 | | - add_subdirectory(pybind11) |
59 | | -endif() |
| 1 | +include(dep-fmt.cmake) |
| 2 | +include(dep-spdlog.cmake) |
| 3 | +include(dep-pybind11.cmake) |
0 commit comments