8
8
# update target to bump the tag to the master revision by
9
9
# recreating .gitexternals.
10
10
# * Provides function
11
- # git_external(<directory> <giturl> <gittag> [VERBOSE,SHALLOW ]
11
+ # git_external(<directory> <giturl> <gittag> [VERBOSE]
12
12
# [RESET <files>])
13
13
# which will check out directory in CMAKE_SOURCE_DIR (if relative)
14
14
# or in the given absolute path using the given repository and tag
18
18
# VERBOSE, when present, this option tells the function to output
19
19
# information about what operations are being performed by git on
20
20
# the repo.
21
- # SHALLOW, when present, causes a shallow clone of depth 1 to be made
22
- # of the specified repo. This may save considerable memory/bandwidth
23
- # when only a specific branch of a repo is required and the full history
24
- # is not required. Note that the SHALLOW option will only work for a branch
25
- # or tag and cannot be used for an arbitrary SHA.
26
21
# OPTIONAL, when present, this option makes this operation optional.
27
22
# The function will output a warning and return if the repo could not be
28
23
# cloned.
@@ -69,15 +64,8 @@ macro(GIT_EXTERNAL_MESSAGE msg)
69
64
endif ()
70
65
endmacro ()
71
66
72
- # utility function for printing a list with custom separator
73
- function (JOIN VALUES GLUE OUTPUT )
74
- string (REGEX REPLACE "([^\\ ]|^);" "\\ 1${GLUE} " _TMP_STR "${VALUES} " )
75
- string (REGEX REPLACE "[\\ ](.)" "\\ 1" _TMP_STR "${_TMP_STR} " ) #fixes escaping
76
- set (${OUTPUT} "${_TMP_STR} " PARENT_SCOPE)
77
- endfunction ()
78
-
79
67
function (GIT_EXTERNAL DIR REPO tag)
80
- cmake_parse_arguments (GIT_EXTERNAL_LOCAL "VERBOSE;SHALLOW; OPTIONAL" "" "RESET" ${ARGN} )
68
+ cmake_parse_arguments (GIT_EXTERNAL_LOCAL "VERBOSE;OPTIONAL" "" "RESET" ${ARGN} )
81
69
set (TAG ${tag} )
82
70
if (GIT_EXTERNAL_TAG AND "${tag} " MATCHES "^[0-9a-f]+$" )
83
71
set (TAG ${GIT_EXTERNAL_TAG} )
@@ -105,16 +93,9 @@ function(GIT_EXTERNAL DIR REPO tag)
105
93
106
94
if (NOT EXISTS "${DIR} " )
107
95
# clone
108
- set (_clone_options --recursive)
109
- if (GIT_EXTERNAL_LOCAL_SHALLOW)
110
- list (APPEND _clone_options --depth 1 --branch ${TAG} )
111
- else ()
112
- set (_msg_tag "[${TAG} ]" )
113
- endif ()
114
- JOIN("${_clone_options} " " " _msg_text)
115
- message (STATUS "git clone ${_msg_text} ${REPO} ${DIR} ${_msg_tag} " )
96
+ message (STATUS "git clone --recursive ${REPO} ${DIR} [${TAG} ]" )
116
97
execute_process (
117
- COMMAND "${GIT_EXECUTABLE} " clone ${_clone_options} ${REPO} ${DIR}
98
+ COMMAND "${GIT_EXECUTABLE} " clone --recursive ${REPO} ${DIR}
118
99
RESULT_VARIABLE nok ERROR_VARIABLE error
119
100
WORKING_DIRECTORY "${GIT_EXTERNAL_DIR} " )
120
101
if (nok)
@@ -127,21 +108,8 @@ function(GIT_EXTERNAL DIR REPO tag)
127
108
endif ()
128
109
129
110
# checkout requested tag
130
- if (NOT GIT_EXTERNAL_LOCAL_SHALLOW)
131
- execute_process (
132
- COMMAND "${GIT_EXECUTABLE} " checkout -q "${TAG} "
133
- RESULT_VARIABLE nok ERROR_VARIABLE error
134
- WORKING_DIRECTORY "${DIR} " )
135
- if (nok)
136
- message (FATAL_ERROR "git checkout ${TAG} in ${DIR} failed: ${error} \n " )
137
- endif ()
138
- endif ()
139
-
140
- # checkout requested tag
141
- execute_process (
142
- COMMAND "${GIT_EXECUTABLE} " checkout -q "${TAG} "
143
- RESULT_VARIABLE nok ERROR_VARIABLE error
144
- WORKING_DIRECTORY "${DIR} " )
111
+ execute_process (COMMAND "${GIT_EXECUTABLE} " checkout -q "${TAG} "
112
+ RESULT_VARIABLE nok ERROR_VARIABLE error WORKING_DIRECTORY "${DIR} " )
145
113
if (nok)
146
114
message (FATAL_ERROR "git checkout ${TAG} in ${DIR} failed: ${error} \n " )
147
115
endif ()
0 commit comments