blob: 3279766320b5557f6727b797340706c143bdbf39 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
# Copyright 2018, 2019 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
if(NOT CMAKE_VERSION VERSION_LESS 3.10)
include_guard()
endif()
if(NOT COMMAND FetchContent_Populate)
if(CMAKE_VERSION VERSION_LESS 3.11)
message(STATUS "Fetching FetchContent.cmake")
file(DOWNLOAD
"https://gitlab.kitware.com/cmake/cmake/raw/v3.11.3/Modules/FetchContent.cmake"
"${CMAKE_BINARY_DIR}/Modules/FetchContent.cmake"
)
file(DOWNLOAD
"https://gitlab.kitware.com/cmake/cmake/raw/v3.11.3/Modules/FetchContent/CMakeLists.cmake.in"
"${CMAKE_BINARY_DIR}/Modules/FetchContent/CMakeLists.cmake.in"
)
include(${CMAKE_BINARY_DIR}/Modules/FetchContent.cmake)
else()
include(FetchContent)
endif()
endif()
function(boost_fetch)
cmake_parse_arguments(_ "EXCLUDE_FROM_ALL;NO_ADD_SUBDIR" "TAG" "" ${ARGN})
if(NOT __UNPARSED_ARGUMENTS)
message(FATAL_ERROR "boost_fetch: missing required argument, repository name")
return()
endif()
list(GET __UNPARSED_ARGUMENTS 0 REPO)
list(REMOVE_AT __UNPARSED_ARGUMENTS 0)
if(__UNPARSED_ARGUMENTS)
message(AUTHOR_WARNING "boost_fetch: extra arguments ignored: ${__UNPARSED_ARGUMENTS}")
endif()
if(NOT __TAG)
set(__TAG master)
endif()
string(MAKE_C_IDENTIFIER ${REPO} NAME)
if(CMAKE_VERSION VERSION_LESS 3.6)
FetchContent_Declare(${NAME} QUIET GIT_REPOSITORY "https://github.com/${REPO}" GIT_TAG ${__TAG})
else()
FetchContent_Declare(${NAME} QUIET GIT_REPOSITORY "https://github.com/${REPO}" GIT_TAG ${__TAG} GIT_SHALLOW 1)
endif()
FetchContent_GetProperties(${NAME})
if(NOT ${NAME}_POPULATED)
message(STATUS "Fetching ${REPO}:${__TAG}")
FetchContent_Populate(${NAME})
if(__NO_ADD_SUBDIR)
# Skip add_subdirectory
elseif(__EXCLUDE_FROM_ALL)
add_subdirectory(${${NAME}_SOURCE_DIR} ${${NAME}_BINARY_DIR} EXCLUDE_FROM_ALL)
else()
add_subdirectory(${${NAME}_SOURCE_DIR} ${${NAME}_BINARY_DIR})
endif()
endif()
endfunction(boost_fetch)
|