-
Notifications
You must be signed in to change notification settings - Fork 16
/
external.cmake
206 lines (169 loc) · 6.4 KB
/
external.cmake
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
set(AIRMAP_EXTERNAL_DEPENDENCIES_OUTPUT_PATH "${CMAKE_BINARY_DIR}/external")
set(ENV{AIRMAP_EXTERNAL_DEPENDENCIES_OUTPUT_PATH} "${CMAKE_BINARY_DIR}/external")
function (build_boost)
set(trigger_build_dir ${CMAKE_BINARY_DIR}/force_boost)
if (EXISTS ${trigger_build_dir})
return()
endif()
file(MAKE_DIRECTORY ${trigger_build_dir} ${trigger_build_dir}/build)
execute_process(
COMMAND ${CMAKE_COMMAND}
-G${CMAKE_GENERATOR}
-DANDROID_ABI=${ANDROID_ABI}
-DANDROID_PLATFORM=${ANDROID_PLATFORM}
-DANDROID_STL=${ANDROID_STL}
-DANDROID_CPP_FEATURES=${ANDROID_CPP_FEATURES}
-DCMAKE_TOOLCHAIN_FILE:PATH=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
${CMAKE_SOURCE_DIR}/vendor/boost
WORKING_DIRECTORY ${trigger_build_dir}/build
)
execute_process(COMMAND ${CMAKE_COMMAND} --build .
WORKING_DIRECTORY ${trigger_build_dir}/build
)
endfunction()
function (build_boringssl)
set(trigger_build_dir ${CMAKE_BINARY_DIR}/force_boringssl)
if (EXISTS ${trigger_build_dir})
return()
endif()
file(MAKE_DIRECTORY ${trigger_build_dir} ${trigger_build_dir}/build)
execute_process(
COMMAND ${CMAKE_COMMAND}
-G${CMAKE_GENERATOR}
-DANDROID_ABI=${ANDROID_ABI}
-DANDROID_PLATFORM=${ANDROID_PLATFORM}
-DANDROID_STL=${ANDROID_STL}
-DANDROID_CPP_FEATURES=${ANDROID_CPP_FEATURES}
-DCMAKE_TOOLCHAIN_FILE:PATH=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_FIND_ROOT_PATH:PATH="${CMAKE_FIND_ROOT_PATH}"
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
${CMAKE_SOURCE_DIR}/vendor/boringssl
WORKING_DIRECTORY ${trigger_build_dir}/build
)
execute_process(COMMAND ${CMAKE_COMMAND} --build .
WORKING_DIRECTORY ${trigger_build_dir}/build
)
endfunction()
function (build_protobuf)
set(trigger_build_dir ${CMAKE_BINARY_DIR}/force_protobuf)
if (EXISTS ${trigger_build_dir})
return()
endif()
file(MAKE_DIRECTORY ${trigger_build_dir} ${trigger_build_dir}/build)
execute_process(
COMMAND ${CMAKE_COMMAND}
-G${CMAKE_GENERATOR}
-DANDROID_ABI=${ANDROID_ABI}
-DANDROID_PLATFORM=${ANDROID_PLATFORM}
-DANDROID_STL=${ANDROID_STL}
-DANDROID_CPP_FEATURES=${ANDROID_CPP_FEATURES}
-DCMAKE_TOOLCHAIN_FILE:PATH=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_FIND_ROOT_PATH=${CMAKE_FIND_ROOT_PATH}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
${CMAKE_SOURCE_DIR}/vendor/protobuf
WORKING_DIRECTORY ${trigger_build_dir}/build
)
execute_process(COMMAND ${CMAKE_COMMAND} --build .
WORKING_DIRECTORY ${trigger_build_dir}/build
)
endfunction()
function (build_cares)
if (NOT AIRMAP_ENABLE_GRPC)
message(STATUS "Skipping c-ares build")
return()
endif()
set(trigger_build_dir ${CMAKE_BINARY_DIR}/force_cares)
if (EXISTS ${trigger_build_dir})
return()
endif()
file(MAKE_DIRECTORY ${trigger_build_dir} ${trigger_build_dir}/build)
execute_process(
COMMAND ${CMAKE_COMMAND}
-G${CMAKE_GENERATOR}
-DANDROID_ABI=${ANDROID_ABI}
-DANDROID_PLATFORM=${ANDROID_PLATFORM}
-DANDROID_STL=${ANDROID_STL}
-DANDROID_CPP_FEATURES=${ANDROID_CPP_FEATURES}
-DCMAKE_TOOLCHAIN_FILE:PATH=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_FIND_ROOT_PATH=${CMAKE_FIND_ROOT_PATH}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
${CMAKE_SOURCE_DIR}/vendor/cares
WORKING_DIRECTORY ${trigger_build_dir}/build
)
execute_process(COMMAND ${CMAKE_COMMAND} --build .
WORKING_DIRECTORY ${trigger_build_dir}/build
)
endfunction()
function (build_grpc)
if (${CMAKE_CROSSCOMPILING} AND AIRMAP_ENABLE_GRPC)
message(FATAL_ERROR Cross-compiling with gRPC is not supported)
endif ()
if (NOT AIRMAP_ENABLE_GRPC)
message(STATUS "Skipping gRPC build")
return()
endif()
set(trigger_build_dir ${CMAKE_BINARY_DIR}/force_grpc)
if (EXISTS ${trigger_build_dir})
return()
endif()
file(MAKE_DIRECTORY ${trigger_build_dir} ${trigger_build_dir}/build)
execute_process(
COMMAND ${CMAKE_COMMAND}
-G${CMAKE_GENERATOR}
-DANDROID_ABI=${ANDROID_ABI}
-DANDROID_PLATFORM=${ANDROID_PLATFORM}
-DANDROID_STL=${ANDROID_STL}
-DANDROID_CPP_FEATURES=${ANDROID_CPP_FEATURES}
-DCMAKE_TOOLCHAIN_FILE:PATH=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_FIND_ROOT_PATH=${CMAKE_FIND_ROOT_PATH}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DOPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR}
-DOPENSSL_USE_STATIC_LIBS=${OPENSSL_USE_STATIC_LIBS}
${CMAKE_SOURCE_DIR}/vendor/grpc
WORKING_DIRECTORY ${trigger_build_dir}/build
)
execute_process(COMMAND ${CMAKE_COMMAND} --build .
WORKING_DIRECTORY ${trigger_build_dir}/build
)
find_file(
AIRMAP_GRPC_CMAKE_CONFIG gRPCConfig.cmake
PATHS ${AIRMAP_GRPC_OUTPUT_PATH}/lib/cmake/grpc ${AIRMAP_GRPC_OUTPUT_PATH}/${CMAKE_INSTALL_LIBDIR}/cmake/grpc
NO_DEFAULT_PATH NO_CMAKE_SYSTEM_PATH NO_CMAKE_FIND_ROOT_PATH)
if (NOT AIRMAP_GRPC_CMAKE_CONFIG)
message(FATAL_ERROR "Failed to find grpc cmake config file")
endif()
include(${AIRMAP_GRPC_CMAKE_CONFIG})
endfunction()
set(AIRMAP_BOOST_OUTPUT_PATH "${AIRMAP_EXTERNAL_DEPENDENCIES_OUTPUT_PATH}")
set(AIRMAP_BORINGSSL_OUTPUT_PATH "${AIRMAP_EXTERNAL_DEPENDENCIES_OUTPUT_PATH}")
set(AIRMAP_CARES_OUTPUT_PATH "${AIRMAP_EXTERNAL_DEPENDENCIES_OUTPUT_PATH}")
set(AIRMAP_GRPC_OUTPUT_PATH "${AIRMAP_EXTERNAL_DEPENDENCIES_OUTPUT_PATH}")
set(AIRMAP_PROTOBUF_OUTPUT_PATH "${AIRMAP_EXTERNAL_DEPENDENCIES_OUTPUT_PATH}")
set(ENV{AIRMAP_BOOST_OUTPUT_PATH} ${AIRMAP_BOOST_OUTPUT_PATH})
set(ENV{AIRMAP_BORINGSSL_OUTPUT_PATH} ${AIRMAP_BORINGSSL_OUTPUT_PATH})
set(ENV{AIRMAP_CARES_OUTPUT_PATH} ${AIRMAP_CARES_OUTPUT_PATH})
set(ENV{AIRMAP_GRPC_OUTPUT_PATH} ${AIRMAP_GRPC_OUTPUT_PATH})
set(ENV{AIRMAP_PROTOBUF_OUTPUT_PATH} ${AIRMAP_PROTOBUF_OUTPUT_PATH})
list(
APPEND CMAKE_PREFIX_PATH
${AIRMAP_EXTERNAL_DEPENDENCIES_OUTPUT_PATH}
)
set(ENV{CMAKE_PREFIX_PATH} "${AIRMAP_BOOST_OUTPUT_PATH}:${AIRMAP_BORINGSSL_OUTPUT_PATH}:${AIRMAP_CARES_OUTPUT_PATH}:${AIRMAP_GRPC_OUTPUT_PATH}:${AIRMAP_PROTOBUF_OUTPUT_PATH}")
set(BOOST_ROOT ${AIRMAP_BOOST_OUTPUT_PATH})
set(Boost_USE_MULTITHREADED ON)
set(Boost_NO_SYSTEM_PATHS ON)
set(Boost_USE_STATIC_LIBS ON)
# Please note that the order of these invocations is important
build_boost()
build_boringssl()
build_protobuf()
build_cares()
build_grpc()
list(
APPEND CMAKE_FIND_ROOT_PATH
${AIRMAP_EXTERNAL_DEPENDENCIES_OUTPUT_PATH}
)
include(GNUInstallDirs)
set(OPENSSL_ROOT_DIR ${AIRMAP_EXTERNAL_DEPENDENCIES_OUTPUT_PATH})
set(OPENSSL_USE_STATIC_LIBS ON)