-
Notifications
You must be signed in to change notification settings - Fork 48
/
Copy pathBuildHwDrivers.cmake
284 lines (266 loc) · 11 KB
/
BuildHwDrivers.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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
############################################################
## Pothos SDR environment build sub-script
##
## This script builds SDR hardware drivers
##
## * osmo-sdr
## * rtl-sdr
## * bladerf
## * hackrf
## * uhd/usrp
## * airspy
## * airspy-hf+
## * mirisdr
## * libiio (plutosdr)
## * libad9361 (plutosdr)
############################################################
set(OSMO_BRANCH master)
set(MIRISDR_BRANCH master)
set(RTL_BRANCH development)
set(BLADERF_BRANCH master)
set(HACKRF_BRANCH master)
set(UHD_BRANCH v4.0.0.0)
set(UMTRX_BRANCH master)
set(AIRSPY_BRANCH master)
set(AIRSPYHF_BRANCH master)
set(LIBIIO_BRANCH v0.19)
set(LIBAD9361_BRANCH master)
############################################################
# python generation tools
# uhd uses mako
############################################################
execute_process(COMMAND ${PYTHON3_ROOT}/Scripts/pip.exe install mako OUTPUT_QUIET)
############################################################
## Build Osmo SDR
############################################################
MyExternalProject_Add(osmo-sdr
DEPENDS libusb
GIT_REPOSITORY git://git.osmocom.org/osmo-sdr.git
GIT_TAG ${OSMO_BRANCH}
CMAKE_DEFAULTS ON
CONFIGURE_COMMAND
"${CMAKE_COMMAND}" <SOURCE_DIR>/software/libosmosdr
-G ${CMAKE_GENERATOR}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DLIBUSB_INCLUDE_DIR=${LIBUSB_INCLUDE_DIR}
-DLIBUSB_LIBRARIES=${LIBUSB_LIBRARIES}
LICENSE_FILES software/libosmosdr/COPYING
)
############################################################
## Build Miri SDR
############################################################
MyExternalProject_Add(miri-sdr
DEPENDS libusb
GIT_REPOSITORY git://git.osmocom.org/libmirisdr.git
GIT_TAG ${MIRISDR_BRANCH}
CMAKE_DEFAULTS ON
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DLIBUSB_INCLUDE_DIR=${LIBUSB_INCLUDE_DIR}
-DLIBUSB_LIBRARIES=${LIBUSB_LIBRARIES}
LICENSE_FILES COPYING
)
############################################################
## Build RTL SDR
############################################################
MyExternalProject_Add(rtl-sdr
DEPENDS Pthreads libusb Pthreads
GIT_REPOSITORY https://github.com/librtlsdr/librtlsdr.git
GIT_TAG ${RTL_BRANCH}
CMAKE_DEFAULTS ON
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DLIBUSB_INCLUDE_DIR=${LIBUSB_INCLUDE_DIR}
-DLIBUSB_LIBRARIES=${LIBUSB_LIBRARIES}
-DTHREADS_PTHREADS_INCLUDE_DIR=${THREADS_PTHREADS_INCLUDE_DIR}
-DTHREADS_PTHREADS_WIN32_LIBRARY=${THREADS_PTHREADS_WIN32_LIBRARY}
LICENSE_FILES COPYING
)
############################################################
## Build BladeRF
############################################################
MyExternalProject_Add(bladeRF
DEPENDS Pthreads libusb
GIT_REPOSITORY https://github.com/Nuand/bladeRF.git
GIT_TAG ${BLADERF_BRANCH}
CONFIGURE_COMMAND
"${CMAKE_COMMAND}" <SOURCE_DIR>/host
-G ${CMAKE_GENERATOR}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DTREAT_WARNINGS_AS_ERRORS=OFF
-DENABLE_BACKEND_USB=ON
-DENABLE_BACKEND_LIBUSB=ON
-DENABLE_BACKEND_CYAPI=${FX3_SDK_FOUND}
-DFX3_SDK_PATH=${FX3_SDK_PATH}
-DLIBUSB_HEADER_FILE=${LIBUSB_INCLUDE_DIR}/libusb.h
-Dusb_LIBRARY=${LIBUSB_ROOT}/x64/Release/dll/libusb-1.0.lib
-DLIBUSB_PATH=${LIBUSB_ROOT}
-DLIBPTHREADSWIN32_HEADER_FILE=${THREADS_PTHREADS_INCLUDE_DIR}/pthread.h
-DPTHREAD_LIBRARY=${THREADS_PTHREADS_WIN32_LIBRARY}
-DLIBPTHREADSWIN32_PATH=${THREADS_PTHREADS_ROOT}
-DVERSION_INFO_OVERRIDE=${EXTRA_VERSION_INFO}
BUILD_COMMAND echo "build bladerf..."
#work around the bladerf copy external dll commands
#since we are not using the exact same file path
&& ${CMAKE_COMMAND} -E make_directory ${THREADS_PTHREADS_ROOT}/dll/x64
&& ${CMAKE_COMMAND} -E copy
${THREADS_PTHREADS_ROOT}/pthreadVC2.dll
${THREADS_PTHREADS_ROOT}/dll/x64/pthreadVC2.dll
&& ${CMAKE_COMMAND} -E make_directory ${LIBUSB_ROOT}/MS64/dll
&& ${CMAKE_COMMAND} -E copy
${LIBUSB_ROOT}/x64/Release/dll/libusb-1.0.dll
${LIBUSB_ROOT}/MS64/dll/libusb-1.0.dll
#the actual cmake build target
&& ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE}
#cleanup from work around copies
&& ${CMAKE_COMMAND} -E remove_directory ${THREADS_PTHREADS_ROOT}/dll
&& ${CMAKE_COMMAND} -E remove_directory ${LIBUSB_ROOT}/MS64
INSTALL_COMMAND echo "install bladerf..."
#the actual cmake install target
&& ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE} --target install
#post install: move dll from lib into the runtime path directory
&& ${CMAKE_COMMAND} -E rename ${CMAKE_INSTALL_PREFIX}/lib/bladeRF.dll ${CMAKE_INSTALL_PREFIX}/bin/bladeRF.dll
LICENSE_FILES legal/licenses/
)
#bladerf tries to install this file, but its not part of the SDK, so make it
ExternalProject_Get_Property(bladeRF BINARY_DIR)
execute_process(COMMAND ${CMAKE_COMMAND} -E make_directory
"${BINARY_DIR}/output/${CMAKE_BUILD_TYPE}/drivers/CyUSB3")
execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
"${FX3_SDK_PATH}/driver/bin/Win8.1/x64/WdfCoinstaller01011.dll"
"${BINARY_DIR}/output/${CMAKE_BUILD_TYPE}/drivers/CyUSB3")
############################################################
## Build HackRF
############################################################
MyExternalProject_Add(hackRF
DEPENDS Pthreads libusb fftw Pthreads
GIT_REPOSITORY https://github.com/mossmann/hackrf.git
GIT_TAG ${HACKRF_BRANCH}
CONFIGURE_COMMAND
"${CMAKE_COMMAND}" <SOURCE_DIR>/host
-G ${CMAKE_GENERATOR}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DLIBUSB_INCLUDE_DIR=${LIBUSB_INCLUDE_DIR}
-DLIBUSB_LIBRARIES=${LIBUSB_LIBRARIES}
-DTHREADS_PTHREADS_INCLUDE_DIR=${THREADS_PTHREADS_INCLUDE_DIR}
-DTHREADS_PTHREADS_WIN32_LIBRARY=${THREADS_PTHREADS_WIN32_LIBRARY}
-DFFTW_INCLUDES=${FFTW3F_INCLUDE_DIRS}
-DFFTW_LIBRARIES=${FFTW3F_LIBRARIES}
BUILD_COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE}
INSTALL_COMMAND ${CMAKE_COMMAND} --build . --config ${CMAKE_BUILD_TYPE} --target install
#post install: move lib from bin into the library path directory
&& ${CMAKE_COMMAND} -E rename ${CMAKE_INSTALL_PREFIX}/bin/hackrf.lib ${CMAKE_INSTALL_PREFIX}/lib/hackrf.lib
&& ${CMAKE_COMMAND} -E rename ${CMAKE_INSTALL_PREFIX}/bin/hackrf_static.lib ${CMAKE_INSTALL_PREFIX}/lib/hackrf_static.lib
LICENSE_FILES COPYING
)
############################################################
## Build UHD
############################################################
if (EXISTS ${BOOST_ROOT})
MyExternalProject_Add(uhd
DEPENDS libusb
GIT_REPOSITORY https://github.com/EttusResearch/uhd.git
GIT_TAG ${UHD_BRANCH}
CMAKE_DEFAULTS ON
CONFIGURE_COMMAND
"${CMAKE_COMMAND}" <SOURCE_DIR>/host
-G ${CMAKE_GENERATOR}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DLIBUSB_INCLUDE_DIR=${LIBUSB_INCLUDE_DIR}
-DLIBUSB_LIBRARIES=${LIBUSB_LIBRARIES}
-DBOOST_ROOT=${BOOST_ROOT}
-DBOOST_LIBRARYDIR=${BOOST_LIBRARYDIR}
-DBOOST_ALL_DYN_LINK=TRUE
-DPYTHON_EXECUTABLE=${PYTHON3_EXECUTABLE}
LICENSE_FILES host/LICENSE
)
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}
WriteRegStr HKEY_LOCAL_MACHINE \\\"${NSIS_ENV}\\\" \\\"UHD_PKG_PATH\\\" \\\"$INSTDIR\\\"
")
set(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS "${CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS}
DeleteRegValue HKEY_LOCAL_MACHINE \\\"${NSIS_ENV}\\\" \\\"UHD_PKG_PATH\\\"
")
set(UHD_INCLUDE_DIRS ${CMAKE_INSTALL_PREFIX}/include)
set(UHD_LIBRARIES ${CMAKE_INSTALL_PREFIX}/lib/uhd.lib)
else()
message(STATUS "Boost missing, skipping uhd...")
endif()
############################################################
## Build Airspy
############################################################
MyExternalProject_Add(airspy
DEPENDS Pthreads libusb Pthreads
GIT_REPOSITORY https://github.com/airspy/airspyone_host.git
GIT_TAG ${AIRSPY_BRANCH}
CMAKE_DEFAULTS ON
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DLIBUSB_INCLUDE_DIR=${LIBUSB_INCLUDE_DIR}
-DLIBUSB_LIBRARIES=${LIBUSB_LIBRARIES}
-DTHREADS_PTHREADS_INCLUDE_DIR=${THREADS_PTHREADS_INCLUDE_DIR}
-DTHREADS_PTHREADS_WIN32_LIBRARY=${THREADS_PTHREADS_WIN32_LIBRARY}
LICENSE_FILES README.md
)
############################################################
## Build AirspyHF
############################################################
MyExternalProject_Add(airspyhf
DEPENDS Pthreads libusb Pthreads
GIT_REPOSITORY https://github.com/airspy/airspyhf.git
GIT_TAG ${AIRSPYHF_BRANCH}
CMAKE_DEFAULTS ON
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DLIBUSB_INCLUDE_DIR=${LIBUSB_INCLUDE_DIR}
-DLIBUSB_LIBRARIES=${LIBUSB_LIBRARIES}
-DTHREADS_PTHREADS_INCLUDE_DIR=${THREADS_PTHREADS_INCLUDE_DIR}
-DTHREADS_PTHREADS_WIN32_LIBRARY=${THREADS_PTHREADS_WIN32_LIBRARY}
LICENSE_FILES LICENSE
)
############################################################
## Build libiio
############################################################
MyExternalProject_Add(libiio
DEPENDS libxml2 libusb Pthreads
GIT_REPOSITORY https://github.com/analogdevicesinc/libiio.git
GIT_TAG ${LIBIIO_BRANCH}
CMAKE_DEFAULTS ON
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DLIBUSB_INCLUDE_DIR=${LIBUSB_INCLUDE_DIR}
-DLIBUSB_LIBRARIES=${LIBUSB_LIBRARIES}
-DTHREADS_PTHREADS_INCLUDE_DIR=${THREADS_PTHREADS_INCLUDE_DIR}
-DTHREADS_PTHREADS_WIN32_LIBRARY=${THREADS_PTHREADS_WIN32_LIBRARY}
-DLIBXML2_INCLUDE_DIR=${LIBXML2_INCLUDE_DIR}
-DLIBXML2_LIBRARIES=${LIBXML2_LIBRARIES}
-DCSHARP_BINDINGS=OFF
-DPYTHON_BINDINGS=OFF
-DWITH_MATLAB_BINDINGS_API=OFF
LICENSE_FILES COPYING.txt
)
set(LIBIIO_INCLUDE_DIR ${CMAKE_INSTALL_PREFIX}/include)
set(LIBIIO_LIBRARY ${CMAKE_INSTALL_PREFIX}/lib/libiio.lib)
############################################################
## Build libad9361
############################################################
MyExternalProject_Add(libad9361
DEPENDS libiio
GIT_REPOSITORY https://github.com/analogdevicesinc/libad9361-iio.git
GIT_TAG ${LIBAD9361_BRANCH}
CMAKE_DEFAULTS ON
CMAKE_ARGS
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DLIBIIO_INCLUDEDIR=${LIBIIO_INCLUDE_DIR}
-DLIBIIO_LIBRARIES=${LIBIIO_LIBRARY}
LICENSE_FILES LICENSE
)