-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathForgeConfigureDepsVars.cmake
More file actions
138 lines (126 loc) Β· 4.99 KB
/
ForgeConfigureDepsVars.cmake
File metadata and controls
138 lines (126 loc) Β· 4.99 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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# Copyright (c) 2021, ArrayFire
# All rights reserved.
#
# This file is distributed under 3-clause BSD license.
# The complete license agreement can be obtained at:
# http://arrayfire.com/licenses/BSD-3-Clause
file(DOWNLOAD
"https://github.com/arrayfire/forge/blob/v1.0.0/CMakeLists.txt"
"${Forge_BINARY_DIR}/download_copy_cmakelists.stamp"
STATUS fg_check_result
TIMEOUT 4
)
list(GET fg_check_result 0 fg_is_connected)
if(${fg_is_connected})
set(BUILD_OFFLINE ON)
# Turn ON disconnected flag when connected to cloud
set(FETCHCONTENT_FULLY_DISCONNECTED ON CACHE BOOL
"Disable Download/Update stages of FetchContent workflow" FORCE)
message(STATUS "No cloud connection. Attempting offline build if dependencies are available")
else()
set(BUILD_OFFLINE OFF)
# Turn OFF disconnected flag when connected to cloud
# This is required especially in the following scenario:
# - cmake run successfully first
# - lost connection, but development can still be done
# - Now, connection regained. Hence updates should be allowed
set(FETCHCONTENT_FULLY_DISCONNECTED OFF CACHE BOOL
"Disable Download/Update stages of FetchContent workflow" FORCE)
endif()
# Track dependencies download persistently across multiple
# cmake configure runs. *_POPULATED variables are reset for each
# cmake run to 0. Hence, this internal cache value is needed to
# check for already (from previous cmake run's) populated data
# during the current cmake run if it looses network connection.
set(FG_INTERNAL_DOWNLOAD_FLAG OFF CACHE BOOL "Dependencies Download Tracker Flag")
# Override fetch content base dir before including AFfetch_content
set(FETCHCONTENT_BASE_DIR "${Forge_BINARY_DIR}/extern" CACHE PATH
"Base directory where Forge dependencies are downloaded and/or built" FORCE)
include(ForgeFetchContent)
mark_as_advanced(
FG_INTERNAL_DOWNLOAD_FLAG
FETCHCONTENT_BASE_DIR
FETCHCONTENT_QUIET
FETCHCONTENT_FULLY_DISCONNECTED
FETCHCONTENT_UPDATES_DISCONNECTED
)
macro(set_and_mark_depnames_advncd var name)
string(TOLOWER ${name} ${var})
string(TOUPPER ${name} ${var}_ucname)
mark_as_advanced(
FETCHCONTENT_SOURCE_DIR_${${var}_ucname}
FETCHCONTENT_UPDATES_DISCONNECTED_${${var}_ucname}
)
endmacro()
set_and_mark_depnames_advncd(glad_prefix "fg_glad")
set_and_mark_depnames_advncd(glm_prefix "fg_glm")
macro(fg_dep_check_and_populate dep_prefix)
set(single_args URI REF)
cmake_parse_arguments(fdcp_args "" "${single_args}" "" ${ARGN})
if("${fdcp_args_URI}" STREQUAL "")
message(FATAL_ERROR [=[
Cannot check requested dependency source's availability.
Please provide a valid URI(almost always a URL to a github repo).
Note that the above error message if for developers of Forge.
]=])
endif()
string(FIND "${fdcp_args_REF}" "=" fdcp_has_algo_id)
if(${BUILD_OFFLINE} AND NOT ${FG_INTERNAL_DOWNLOAD_FLAG})
if(NOT ${fdcp_has_algo_id} EQUAL -1)
FetchContent_Populate(${dep_prefix}
QUIET
URL ${fdcp_args_URI}
URL_HASH ${fdcp_args_REF}
DOWNLOAD_COMMAND \"\"
UPDATE_DISCONNECTED ON
SOURCE_DIR "${Forge_SOURCE_DIR}/extern/${dep_prefix}-src"
BINARY_DIR "${Forge_BINARY_DIR}/extern/${dep_prefix}-build"
SUBBUILD_DIR "${Forge_BINARY_DIR}/extern/${dep_prefix}-subbuild"
)
elseif("${fdcp_args_REF}" STREQUAL "")
FetchContent_Populate(${dep_prefix}
QUIET
URL ${fdcp_args_URI}
DOWNLOAD_COMMAND \"\"
UPDATE_DISCONNECTED ON
SOURCE_DIR "${Forge_SOURCE_DIR}/extern/${dep_prefix}-src"
BINARY_DIR "${Forge_BINARY_DIR}/extern/${dep_prefix}-build"
SUBBUILD_DIR "${Forge_BINARY_DIR}/extern/${dep_prefix}-subbuild"
)
else()
# The left over alternative is assumed to be a cloud hosted git repository
FetchContent_Populate(${dep_prefix}
QUIET
GIT_REPOSITORY ${fdcp_args_URI}
GIT_TAG ${fdcp_args_REF}
DOWNLOAD_COMMAND \"\"
UPDATE_DISCONNECTED ON
SOURCE_DIR "${Forge_SOURCE_DIR}/extern/${dep_prefix}-src"
BINARY_DIR "${Forge_BINARY_DIR}/extern/${dep_prefix}-build"
SUBBUILD_DIR "${Forge_BINARY_DIR}/extern/${dep_prefix}-subbuild"
)
endif()
else()
if(NOT ${fdcp_has_algo_id} EQUAL -1)
FetchContent_Declare(${dep_prefix}
URL ${fdcp_args_URI}
URL_HASH ${fdcp_args_REF}
)
elseif("${fdcp_args_REF}" STREQUAL "")
FetchContent_Declare(${dep_prefix}
URL ${fdcp_args_URI}
)
else()
# The left over alternative is assumed to be a cloud hosted git repository
FetchContent_Declare(${dep_prefix}
GIT_REPOSITORY ${fdcp_args_URI}
GIT_TAG ${fdcp_args_REF}
)
endif()
FetchContent_GetProperties(${dep_prefix})
if(NOT ${dep_prefix}_POPULATED)
FetchContent_Populate(${dep_prefix})
endif()
set(FG_INTERNAL_DOWNLOAD_FLAG ON CACHE BOOL "Dependencies Download Tracker Flag" FORCE)
endif()
endmacro()