From 853b4884bd0c38e95a4d9b03bd4dc131f90516ac Mon Sep 17 00:00:00 2001 From: Jasem Mutlaq Date: Sat, 13 Jan 2024 11:39:56 +0300 Subject: [PATCH] Add Find GPIOD CMake file for C++ --- CMakeLists.txt | 6 ++++ cmake_modules/FindGPIOD.cmake | 55 +++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 cmake_modules/FindGPIOD.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 92cb4146f..5e8aae493 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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 "############################################################################") diff --git a/cmake_modules/FindGPIOD.cmake b/cmake_modules/FindGPIOD.cmake new file mode 100644 index 000000000..31c57abd0 --- /dev/null +++ b/cmake_modules/FindGPIOD.cmake @@ -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 +# +# 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)