Skip to content

Commit

Permalink
Add Find GPIOD CMake file for C++
Browse files Browse the repository at this point in the history
  • Loading branch information
knro authored and bzizou committed Jan 18, 2024
1 parent 5865747 commit 853b488
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ option(WITH_PLAYERONE "Install Player One Astronomy's Camera Driver" On)
option(WITH_WEEWX_JSON "Install Weewx JSON Driver" On)
option(WITH_ROLLOFFINO "Install RollOff ino Dome Driver" On)
option(WITH_ASTROASIS "Install Astroasis Driver" On)
option(WITH_TICFOCUSER "Install Pololu TicFocuser Driver" On)

# FFMPEG required for INDI Webcam driver
find_package(FFmpeg)
Expand Down Expand Up @@ -768,6 +769,11 @@ SET(LIBRARIES_FOUND FALSE)
endif(ASTROASIS_FOUND)
endif(WITH_ASTROASIS)

# Pololu Tic Focuser (depends on https://github.com/pololu/pololu-tic-software)
if (WITH_TICFOCUSER)
add_subdirectory(indi-ticfocuser)
endif(WITH_TICFOCUSER)

# Check if libraries are found. If not, we must build them, install them, THEN run CMake again to build and instal the drivers. If all the libraraies are installed, then we build and install the drivers only now.
if (LIBRARIES_FOUND)
message(STATUS "############################################################################")
Expand Down
55 changes: 55 additions & 0 deletions cmake_modules/FindGPIOD.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# - Try to find GPIOD
# Once done this will define
#
# GPIOD_FOUND - system has libgpiod
# GPIOD_INCLUDE_DIR - the libgpiod include directory
# GPIOD_LIBRARIES - Link these to use libgpiod
#
# N.B. This is for C++ only, you need to include
#
#include <gpiod.hpp>
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

if (GPIOD_INCLUDE_DIR AND GPIOD_LIBRARIES)

# in cache already
set(GPIOD_FOUND TRUE)
message(STATUS "Found libgpiod: ${GPIOD_LIBRARIES}")

else (GPIOD_INCLUDE_DIR AND GPIOD_LIBRARIES)

find_path(GPIOD_INCLUDE_DIR gpiod.hpp
${_obIncDir}
${GNUWIN32_DIR}/include
/usr/local/include
)

find_library(GPIOD_LIBRARIES NAMES gpiodcxx
PATHS
${_obLinkDir}
${GNUWIN32_DIR}/lib
/usr/local/lib
)

if(GPIOD_INCLUDE_DIR AND GPIOD_LIBRARIES)
set(GPIOD_FOUND TRUE)
else (GPIOD_INCLUDE_DIR AND GPIOD_LIBRARIES)
set(GPIOD_FOUND FALSE)
endif(GPIOD_INCLUDE_DIR AND GPIOD_LIBRARIES)


if (GPIOD_FOUND)
if (NOT GPIOD_FIND_QUIETLY)
message(STATUS "Found GPIOD: ${GPIOD_LIBRARIES}")
endif (NOT GPIOD_FIND_QUIETLY)
else (GPIOD_FOUND)
if (GPIOD_FIND_REQUIRED)
message(FATAL_ERROR "libgpiod not found. Please install libgpiod-dev")
endif (GPIOD_FIND_REQUIRED)
endif (GPIOD_FOUND)

mark_as_advanced(GPIOD_INCLUDE_DIR GPIOD_LIBRARIES)

endif (GPIOD_INCLUDE_DIR AND GPIOD_LIBRARIES)

0 comments on commit 853b488

Please sign in to comment.