Browse Source

PlutoSDR: find libiio 1.x headers and flag the 1.x API

libiio 1.x installs its header as include/iio/iio.h instead of
include/iio.h. Look for the 1.x layout first and fall back to the 0.x
one, and set LIBIIO_V1 so plutosdrdevice can select the API at compile
time. The bundled external build (v0.26) keeps the 0.x path.

The input and output plugin headers only need the iio_buffer type, so
forward-declare it instead of including iio.h.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chirpmodem-v8.0.0
Marcel 1 month ago
parent
commit
73d45c3e24
  1. 28
      cmake/Modules/FindLibIIO.cmake
  2. 4
      devices/plutosdr/CMakeLists.txt
  3. 3
      plugins/samplesink/plutosdroutput/plutosdroutput.h
  4. 3
      plugins/samplesource/plutosdrinput/plutosdrinput.h

28
cmake/Modules/FindLibIIO.cmake

@ -3,14 +3,30 @@ if(NOT LIBIIO_FOUND) @@ -3,14 +3,30 @@ if(NOT LIBIIO_FOUND)
pkg_check_modules (LIBIIO_PKG libiio>=0.7)
if(LIBIIO_PKG_FOUND OR (DEFINED IIO_DIR))
find_path(LIBIIO_INCLUDE_DIR
NAMES iio.h
# libiio 1.x installs its header as <prefix>/include/iio/iio.h
find_path(LIBIIO_V1_INCLUDE_DIR
NAMES iio/iio.h
HINTS ${IIO_DIR}/include
${LIBIIO_PKG_INCLUDE_DIRS}
PATHS /usr/include
/usr/local/include
)
if(LIBIIO_V1_INCLUDE_DIR)
set(LIBIIO_INCLUDE_DIR ${LIBIIO_V1_INCLUDE_DIR} CACHE PATH "libiio include directory")
set(LIBIIO_V1 TRUE CACHE INTERNAL "libiio 1.x API")
else()
# libiio 0.x installs its header as <prefix>/include/iio.h
find_path(LIBIIO_INCLUDE_DIR
NAMES iio.h
HINTS ${IIO_DIR}/include
${LIBIIO_PKG_INCLUDE_DIRS}
PATHS /usr/include
/usr/local/include
)
set(LIBIIO_V1 FALSE CACHE INTERNAL "libiio 1.x API")
endif()
find_library(LIBIIO_LIBRARIES
NAMES iio
HINTS ${IIO_DIR}/lib
@ -21,13 +37,17 @@ if(NOT LIBIIO_FOUND) @@ -21,13 +37,17 @@ if(NOT LIBIIO_FOUND)
if(LIBIIO_INCLUDE_DIR AND LIBIIO_LIBRARIES)
set(LIBIIO_FOUND TRUE CACHE INTERNAL "libiio found")
message(STATUS "Found libiio: ${LIBIIO_INCLUDE_DIR}, ${LIBIIO_LIBRARIES}")
if(LIBIIO_V1)
message(STATUS "Found libiio (1.x API): ${LIBIIO_INCLUDE_DIR}, ${LIBIIO_LIBRARIES}")
else()
message(STATUS "Found libiio (0.x API): ${LIBIIO_INCLUDE_DIR}, ${LIBIIO_LIBRARIES}")
endif()
else(LIBIIO_INCLUDE_DIR AND LIBIIO_LIBRARIES)
set(LIBIIO_FOUND FALSE CACHE INTERNAL "libiio found")
message(STATUS "libiio not found.")
endif(LIBIIO_INCLUDE_DIR AND LIBIIO_LIBRARIES)
mark_as_advanced(LIBIIO_INCLUDE_DIR LIBIIO_LIBRARIES)
mark_as_advanced(LIBIIO_INCLUDE_DIR LIBIIO_V1_INCLUDE_DIR LIBIIO_LIBRARIES)
endif(LIBIIO_PKG_FOUND OR (DEFINED IIO_DIR))

4
devices/plutosdr/CMakeLists.txt

@ -35,6 +35,10 @@ target_link_libraries(plutosdrdevice @@ -35,6 +35,10 @@ target_link_libraries(plutosdrdevice
${ICONV_LIBRARY}
)
if(LIBIIO_V1)
target_compile_definitions(plutosdrdevice PRIVATE LIBIIO_V1)
endif()
if(LIBIIO_EXTERNAL)
add_dependencies(plutosdrdevice libiio)
endif()

3
plugins/samplesink/plutosdroutput/plutosdroutput.h

@ -25,13 +25,14 @@ @@ -25,13 +25,14 @@
#include <QString>
#include <QNetworkRequest>
#include "iio.h"
#include "dsp/devicesamplesink.h"
#include "util/message.h"
#include "plutosdr/deviceplutosdrshared.h"
#include "plutosdr/deviceplutosdrbox.h"
#include "plutosdroutputsettings.h"
struct iio_buffer;
class QNetworkAccessManager;
class QNetworkReply;
class DeviceAPI;

3
plugins/samplesource/plutosdrinput/plutosdrinput.h

@ -26,13 +26,14 @@ @@ -26,13 +26,14 @@
#include <QByteArray>
#include <QNetworkRequest>
#include "iio.h"
#include "dsp/devicesamplesource.h"
#include "util/message.h"
#include "plutosdr/deviceplutosdrshared.h"
#include "plutosdr/deviceplutosdrbox.h"
#include "plutosdrinputsettings.h"
struct iio_buffer;
class QNetworkAccessManager;
class QNetworkReply;
class DeviceAPI;

Loading…
Cancel
Save