-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathCC_CommsPrefetch.cmake
More file actions
73 lines (58 loc) · 1.94 KB
/
Copy pathCC_CommsPrefetch.cmake
File metadata and controls
73 lines (58 loc) · 1.94 KB
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
# This file contains contains a function that prefetches comms project.
# ******************************************************
# cc_comms_prefetch(
# SRC_DIR <src_dir>
# [TAG <tag>]
# [REPO <repo>]
# )
#
# - SRC_DIR - A directory where comms sources will end up.
# - TAG - Override the default tag to checkout.
# - REPO - Override the default repository of the comms.
#
set (CC_FETCH_DEFAULT_REPO "https://github.com/commschamp/comms.git")
set (CC_FETCH_DEFAULT_TAG "master")
function (cc_comms_prefetch)
set (_prefix CC_FETCH)
set (_options)
set (_oneValueArgs SRC_DIR REPO TAG)
set (_mutiValueArgs)
cmake_parse_arguments(${_prefix} "${_options}" "${_oneValueArgs}" "${_mutiValueArgs}" ${ARGN})
if (NOT CC_FETCH_SRC_DIR)
message (FATAL_ERROR "The SRC_DIR parameter is not provided")
endif ()
if (NOT CC_FETCH_REPO)
set (CC_FETCH_REPO ${CC_FETCH_DEFAULT_REPO})
endif ()
if (NOT CC_FETCH_TAG)
set (CC_FETCH_TAG ${CC_FETCH_DEFAULT_TAG})
endif ()
if (NOT GIT_FOUND)
find_package(Git REQUIRED)
endif ()
if (EXISTS "${CC_FETCH_SRC_DIR}/.git")
execute_process (
COMMAND ${GIT_EXECUTABLE} fetch
WORKING_DIRECTORY ${CC_FETCH_SRC_DIR}
)
execute_process (
COMMAND ${GIT_EXECUTABLE} checkout ${CC_FETCH_TAG}
WORKING_DIRECTORY ${CC_FETCH_SRC_DIR}
)
return ()
endif()
execute_process (
COMMAND ${CMAKE_COMMAND} -E remove_directory "${CC_FETCH_SRC_DIR}"
)
execute_process (
COMMAND ${CMAKE_COMMAND} -E make_directory "${CC_FETCH_SRC_DIR}"
)
execute_process (
COMMAND
${GIT_EXECUTABLE} clone -b ${CC_FETCH_TAG} ${CC_FETCH_REPO} ${CC_FETCH_SRC_DIR}
RESULT_VARIABLE git_result
)
if (NOT "${git_result}" STREQUAL "0")
message (WARNING "git clone/checkout failed")
endif ()
endfunction()