File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -324,6 +324,30 @@ endif()
324
324
find_package (gpiod )
325
325
if (GPIOD_FOUND )
326
326
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DUSE_GPIOD" )
327
+
328
+ # Version 2 uses a completely different API.
329
+ # Try to determine version and put it on compile command line.
330
+
331
+ # Require pkg-config support
332
+ find_package (PkgConfig REQUIRED )
333
+ # Probe for libgpiod
334
+ pkg_check_modules (LIBGPIOD REQUIRED libgpiod )
335
+ # Abort if not found
336
+ if (NOT LIBGPIOD_FOUND )
337
+ message (FATAL_ERROR "libgpiod not found via pkg-config" )
338
+ endif ()
339
+
340
+ # LIBGPIOD_VERSION holds the full x.y.z string
341
+
342
+ # Now split out major and minor versions into separate integers
343
+ string (REPLACE "." ";" VLIST ${LIBGPIOD_VERSION} )
344
+ list (GET VLIST 0 LIBGPIOD_VERSION_MAJOR )
345
+ list (GET VLIST 1 LIBGPIOD_VERSION_MINOR )
346
+ message (STATUS "libgpiod version ${LIBGPIOD_VERSION} major=${LIBGPIOD_VERSION_MAJOR} minor=${LIBGPIOD_VERSION_MINOR} " )
347
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLIBGPIOD_VERSION=${LIBGPIOD_VERSION} " )
348
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLIBGPIOD_VERSION_MAJOR=${LIBGPIOD_VERSION_MAJOR} " )
349
+ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DLIBGPIOD_VERSION_MINOR=${LIBGPIOD_VERSION_MINOR} " )
350
+
327
351
else ()
328
352
set (GPIOD_INCLUDE_DIRS "" )
329
353
set (GPIOD_LIBRARIES "" )
You can’t perform that action at this time.
0 commit comments