Skip to content

Commit 163f9a5

Browse files
committed
scan: Fix default backends list containing disabled backends
Use CMake to give us a list of the backends available for scanning. This makes sure that the context scan won't fail by trying to scan from a backend that wasn't enabled. Fixes #794. Signed-off-by: Paul Cercueil <[email protected]>
1 parent cad8314 commit 163f9a5

File tree

3 files changed

+12
-1
lines changed

3 files changed

+12
-1
lines changed

CMakeLists.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ if (WITH_USB_BACKEND)
150150
message(SEND_ERROR "Unable to find libusb-1.0 dependency.\n"
151151
"If you want to disable the USB backend, set WITH_USB_BACKEND=OFF.")
152152
else()
153+
list(APPEND LIBIIO_SCAN_BACKENDS usb)
153154
set(IIOD_CLIENT 1)
154155
set(NEED_LIBXML2 1)
155156
set(NEED_THREADS 1)
@@ -250,6 +251,8 @@ if(WITH_LOCAL_BACKEND)
250251

251252
option(WITH_LOCAL_MMAP_API "Use the mmap API provided in Analog Devices' kernel (not upstream)" ON)
252253
option(WITH_HWMON "Add compatibility with the hardware monitoring (hwmon) subsystem" OFF)
254+
255+
list(APPEND LIBIIO_SCAN_BACKENDS local)
253256
endif()
254257

255258
option(WITH_SERIAL_BACKEND "Enable the serial backend" OFF)
@@ -358,6 +361,10 @@ if(WITH_NETWORK_BACKEND)
358361
list(APPEND LIBS_TO_LINK ${AVAHI_LIBRARIES})
359362
endif()
360363

364+
if (HAVE_DNS_SD)
365+
list(APPEND LIBIIO_SCAN_BACKENDS ip)
366+
endif()
367+
361368
set(NEED_THREADS 1)
362369
set(IIOD_CLIENT 1)
363370
set(NEED_LIBXML2 1)
@@ -612,6 +619,8 @@ if (WITH_USB_BACKEND AND CMAKE_SYSTEM_NAME MATCHES "^Linux")
612619
endif()
613620
endif()
614621

622+
string(REPLACE ";" "," LIBIIO_SCAN_BACKENDS "${LIBIIO_SCAN_BACKENDS}")
623+
615624
configure_file(iio-config.h.cmakein ${CMAKE_CURRENT_BINARY_DIR}/iio-config.h @ONLY)
616625

617626
list(APPEND IIO_FEATURES_${WITH_XML_BACKEND} xml)

iio-config.h.cmakein

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
#define LOG_LEVEL @LOG_LEVEL@_L
99

10+
#define LIBIIO_SCAN_BACKENDS "@LIBIIO_SCAN_BACKENDS@"
11+
1012
#cmakedefine01 WITH_LOCAL_BACKEND
1113
#cmakedefine01 WITH_XML_BACKEND
1214
#cmakedefine01 WITH_NETWORK_BACKEND

scan.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ struct iio_scan_context * iio_create_scan_context(
155155
return NULL;
156156
}
157157

158-
ctx->backendopts = iio_strndup(backend ? backend : "local,usb,ip", PATH_MAX);
158+
ctx->backendopts = iio_strndup(backend ? backend : LIBIIO_SCAN_BACKENDS, PATH_MAX);
159159
if (!ctx->backendopts) {
160160
free(ctx);
161161
errno = ENOMEM;

0 commit comments

Comments
 (0)