linuxgpio: add gpiod_line_set_direction_input helper for libgpiod v1.4 support (refs #1782)

This ancient libgpiod version is still shipped on Ubuntu 20.04 LTS.
Add support for it by adding another helper.

Signed-off-by: Michael Heimpold <mhei@heimpold.de>
This commit is contained in:
Michael Heimpold
2024-04-22 23:11:33 +02:00
parent db2580d17b
commit 6a75ac7057
4 changed files with 66 additions and 15 deletions

View File

@@ -240,6 +240,7 @@ if(HAVE_LINUXGPIO)
# defaults/fallbacks
set(HAVE_LIBGPIOD 0)
set(HAVE_LIBGPIOD_V2 0)
set(HAVE_LIBGPIOD_V1_6 0)
find_package(PkgConfig)
if(PKG_CONFIG_FOUND)
@@ -251,12 +252,21 @@ if(HAVE_LINUXGPIO)
set(CMAKE_REQUIRED_LIBRARIES ${LIBGPIODV2_LIBRARIES})
set(LIB_LIBGPIOD ${LIBGPIODV2_LINK_LIBRARIES})
else()
# check whether we have at least an older version
pkg_check_modules(LIBGPIOD libgpiod)
if(LIBGPIOD_FOUND)
# check whether we have version >= 1.6
pkg_check_modules(LIBGPIODV1_6 libgpiod>=1.6)
if(LIBGPIODV1_6_FOUND)
set(HAVE_LIBGPIOD 1)
set(CMAKE_REQUIRED_LIBRARIES ${LIBGPIOD_LIBRARIES})
set(LIB_LIBGPIOD ${LIBGPIOD_LINK_LIBRARIES})
set(HAVE_LIBGPIOD_V1_6 1)
set(CMAKE_REQUIRED_LIBRARIES ${LIBGPIODV1_6_LIBRARIES})
set(LIB_LIBGPIOD ${LIBGPIODV1_6_LINK_LIBRARIES})
else()
# check whether we have at least an older version
pkg_check_modules(LIBGPIOD libgpiod)
if(LIBGPIOD_FOUND)
set(HAVE_LIBGPIOD 1)
set(CMAKE_REQUIRED_LIBRARIES ${LIBGPIOD_LIBRARIES})
set(LIB_LIBGPIOD ${LIBGPIOD_LINK_LIBRARIES})
endif()
endif()
endif()
else()
@@ -358,6 +368,7 @@ if (DEBUG_CMAKE)
message(STATUS "HAVE_HIDAPI_HIDAPI_H: ${HAVE_HIDAPI_HIDAPI_H}")
message(STATUS "LIBUSB_COMPAT_DIR: ${LIBUSB_COMPAT_DIR}")
message(STATUS "LIBGPIODV2_FOUND: ${LIBGPIODV2_FOUND}")
message(STATUS "LIBGPIODV1_6_FOUND: ${LIBGPIODV1_6_FOUND}")
message(STATUS "LIBGPIOD_FOUND: ${LIBGPIOD_FOUND}")
message(STATUS "----------------------")
endif()
@@ -429,7 +440,9 @@ endif()
if(HAVE_LINUXGPIO)
message(STATUS "ENABLED linuxgpio")
if (LIBGPIODV2_FOUND)
message(STATUS "DO HAVE libgpiod (v2.x)")
message(STATUS "DO HAVE libgpiod (>=2.0)")
elseif(LIBGPIODV1_6_FOUND)
message(STATUS "DO HAVE libgpiod (>=1.6)")
elseif(LIBGPIOD_FOUND)
message(STATUS "DO HAVE libgpiod")
else()