From 03ca7ca54e50adc4d14f784b302f158149b8bfca Mon Sep 17 00:00:00 2001 From: graf2242 Date: Wed, 3 Jul 2024 10:17:00 +0300 Subject: [PATCH] indi-pentax: add setcap in CMakeLists to allow "raw IO" for non-root users --- indi-pentax/CMakeLists.txt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/indi-pentax/CMakeLists.txt b/indi-pentax/CMakeLists.txt index cfa00fb72..a6936ecd9 100644 --- a/indi-pentax/CMakeLists.txt +++ b/indi-pentax/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.16) +cmake_minimum_required(VERSION 3.19) PROJECT(indi_pentax CXX C) LIST(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake_modules/") @@ -48,6 +48,21 @@ add_executable(indi_pentax ${indipentax_SRCS}) target_link_libraries(indi_pentax pthread ${PENTAX_LIBRARIES} ${INDI_LIBRARIES} ${JPEG_LIBRARIES} ${LibRaw_LIBRARIES} ${CFITSIO_LIBRARIES} ${ZLIB_LIBRARY}) +find_program(SUDO sudo) +if(NOT SUDO) + message(WARNING "sudo must be available on the system in order to set permissions for the driver") +else() + message("-- sudo command: ${SUDO}") +endif() + +find_program(SETCAP setcap) +if(NOT SETCAP) + message(WARNING "setcap not found, driver may not work because of lack of permissions") +else() + message("-- setcap command: ${SETCAP}") + install(CODE "execute_process(COMMAND ${SUDO} -S ${SETCAP} cap_sys_rawio+ep indi_pentax)") +endif() + install(TARGETS indi_pentax RUNTIME DESTINATION bin) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/indi_pentax.xml DESTINATION ${INDI_DATA_DIR})