From 88c2a55fb0727dd41d326accae7a34599b382b10 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Sun, 16 Oct 2022 11:54:36 +0200 Subject: [PATCH 1/7] remove manual setup.py generation --- CMakeLists.txt | 6 +----- cmake/setup.py.in | 24 ------------------------ 2 files changed, 1 insertion(+), 29 deletions(-) delete mode 100644 cmake/setup.py.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 1410edb..b4a27e6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,11 +115,7 @@ install(FILES ${man_3_SRC} find_package(Python COMPONENTS Interpreter QUIET) if(Python_FOUND) - configure_file(${CMAKE_CURRENT_LIST_DIR}/cmake/setup.py.in - ${CMAKE_CURRENT_BINARY_DIR}/setup.py - ) - - install(CODE "execute_process(COMMAND ${Python_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/setup.py install)") + install(CODE "execute_process(COMMAND ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR}/setup.py install)") endif() # package project diff --git a/cmake/setup.py.in b/cmake/setup.py.in deleted file mode 100644 index a5913a2..0000000 --- a/cmake/setup.py.in +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python - -from distutils.core import setup - -setup(name='pigpio', - version='1.44', - author='joan', - author_email='joan@abyz.me.uk', - maintainer='joan', - maintainer_email='joan@abyz.me.uk', - url='http://abyz.me.uk/rpi/pigpio/python.html', - description='Raspberry Pi GPIO module', - long_description='Raspberry Pi Python module to access the pigpio daemon', - download_url='http://abyz.me.uk/rpi/pigpio/pigpio.zip', - license='unlicense.org', - py_modules=['pigpio'], - keywords=['raspberrypi', 'gpio',], - classifiers=[ - "Programming Language :: Python :: 2", - "Programming Language :: Python :: 3", - ], - package_dir={ '': '${CMAKE_CURRENT_SOURCE_DIR}'} - ) - From 524c4bc463938037c2217512e0c0eea5837719cb Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Sun, 16 Oct 2022 12:18:46 +0200 Subject: [PATCH 2/7] install python package to prefix --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b4a27e6..81552a3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,7 +115,7 @@ install(FILES ${man_3_SRC} find_package(Python COMPONENTS Interpreter QUIET) if(Python_FOUND) - install(CODE "execute_process(COMMAND ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR}/setup.py install)") + install(CODE "execute_process(COMMAND ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR}/setup.py install --prefix=${CMAKE_INSTALL_PREFIX})") endif() # package project From 9aefdb91c03d9a8562955b1b1732f639d6a74a77 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Sun, 16 Oct 2022 23:13:48 +0200 Subject: [PATCH 3/7] fix whitespace --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 81552a3..d9d872f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -52,7 +52,7 @@ include (CMakePackageConfigHelpers) generate_export_header(${PROJECT_NAME}) install(TARGETS pigpio pigpiod_if pigpiod_if2 pig2vcd pigpiod pigs - EXPORT ${PROJECT_NAME}Targets + EXPORT ${PROJECT_NAME}Targets LIBRARY DESTINATION lib${LIB_SUFFIX} ARCHIVE DESTINATION lib${LIB_SUFFIX} RUNTIME DESTINATION bin From 64c8bfbfc7c45db93e129ffdcf04aa94ad628e26 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Sun, 16 Oct 2022 23:25:25 +0200 Subject: [PATCH 4/7] make man pages configurable --- CMakeLists.txt | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d9d872f..e6c3f91 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ find_package(Threads REQUIRED) find_package(RT REQUIRED) option(BUILD_SHARED_LIBS "Create shared libraries" ON) +option(MAN_PAGES "Create manual pages" OFF) add_compile_options(-Wall) @@ -95,21 +96,23 @@ install(FILES pigpio.h pigpiod_if.h pigpiod_if2.h WORLD_READ ) -file(GLOB man_1_SRC "*.1") -install(FILES ${man_1_SRC} - DESTINATION man/man1 - PERMISSIONS OWNER_READ OWNER_WRITE - GROUP_READ - WORLD_READ -) +if (MAN_PAGES) + file(GLOB man_1_SRC "*.1") + install(FILES ${man_1_SRC} + DESTINATION man/man1 + PERMISSIONS OWNER_READ OWNER_WRITE + GROUP_READ + WORLD_READ + ) -file(GLOB man_3_SRC "*.3") -install(FILES ${man_3_SRC} - DESTINATION man/man3 - PERMISSIONS OWNER_READ OWNER_WRITE - GROUP_READ - WORLD_READ -) + file(GLOB man_3_SRC "*.3") + install(FILES ${man_3_SRC} + DESTINATION man/man3 + PERMISSIONS OWNER_READ OWNER_WRITE + GROUP_READ + WORLD_READ + ) +endif() # Install python modules. find_package(Python COMPONENTS Interpreter QUIET) From d490e04103c830a6e2ed73503f369f7bac5ea798 Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Sun, 16 Oct 2022 23:36:00 +0200 Subject: [PATCH 5/7] make socket interface and tests configurable --- CMakeLists.txt | 99 +++++++++++++++++++++++++++++++++----------------- 1 file changed, 65 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e6c3f91..b125923 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,42 +9,88 @@ find_package(RT REQUIRED) option(BUILD_SHARED_LIBS "Create shared libraries" ON) option(MAN_PAGES "Create manual pages" OFF) +option(SOCKET_INTERFACE "Build socket interface" ON) +option(TESTS "Build tests" OFF) add_compile_options(-Wall) # libpigpio.(so|a) add_library(pigpio pigpio.c command.c custom.cext) -# libpigpiod_if.(so|a) -add_library(pigpiod_if pigpiod_if.c command.c) +install(TARGETS pigpio + EXPORT ${PROJECT_NAME}Targets + LIBRARY DESTINATION lib${LIB_SUFFIX} + ARCHIVE DESTINATION lib${LIB_SUFFIX} + RUNTIME DESTINATION bin + INCLUDES DESTINATION include +) -# libpigpiod_if2.(so|a) -add_library(pigpiod_if2 pigpiod_if2.c command.c) +install(FILES pigpio.h + DESTINATION include + PERMISSIONS OWNER_READ OWNER_WRITE + GROUP_READ + WORLD_READ +) -# x_pigpio -add_executable(x_pigpio x_pigpio.c) -target_link_libraries(x_pigpio pigpio RT::RT Threads::Threads) +if(TESTS) + # x_pigpio + add_executable(x_pigpio x_pigpio.c) + target_link_libraries(x_pigpio pigpio RT::RT Threads::Threads) +endif() -# x_pigpiod_if -add_executable(x_pigpiod_if x_pigpiod_if.c) -target_link_libraries(x_pigpiod_if pigpiod_if RT::RT Threads::Threads) +if(SOCKET_INTERFACE) + # libpigpiod_if.(so|a) + add_library(pigpiod_if pigpiod_if.c command.c) -# x_pigpiod_if2 -add_executable(x_pigpiod_if2 x_pigpiod_if2.c) -target_link_libraries(x_pigpiod_if2 pigpiod_if2 RT::RT Threads::Threads) + # libpigpiod_if2.(so|a) + add_library(pigpiod_if2 pigpiod_if2.c command.c) -# pigpiod -add_executable(pigpiod pigpiod.c) -target_link_libraries(pigpiod pigpio RT::RT Threads::Threads) + # pigpiod + add_executable(pigpiod pigpiod.c) + target_link_libraries(pigpiod pigpio RT::RT Threads::Threads) -# pigs -add_executable(pigs pigs.c command.c) -target_link_libraries(pigs Threads::Threads) + # pigs + add_executable(pigs pigs.c command.c) + target_link_libraries(pigs Threads::Threads) + + install(TARGETS pigpiod_if pigpiod_if2 pigpiod pigs + EXPORT ${PROJECT_NAME}Targets + LIBRARY DESTINATION lib${LIB_SUFFIX} + ARCHIVE DESTINATION lib${LIB_SUFFIX} + RUNTIME DESTINATION bin + INCLUDES DESTINATION include + ) + + install(FILES pigpiod_if.h pigpiod_if2.h + DESTINATION include + PERMISSIONS OWNER_READ OWNER_WRITE + GROUP_READ + WORLD_READ + ) + + if(TESTS) + # x_pigpiod_if + add_executable(x_pigpiod_if x_pigpiod_if.c) + target_link_libraries(x_pigpiod_if pigpiod_if RT::RT Threads::Threads) + + # x_pigpiod_if2 + add_executable(x_pigpiod_if2 x_pigpiod_if2.c) + target_link_libraries(x_pigpiod_if2 pigpiod_if2 RT::RT Threads::Threads) + endif() +endif() # pig2vcd add_executable(pig2vcd pig2vcd.c command.c) target_link_libraries(pig2vcd Threads::Threads) +install(TARGETS pig2vcd + EXPORT ${PROJECT_NAME}Targets + LIBRARY DESTINATION lib${LIB_SUFFIX} + ARCHIVE DESTINATION lib${LIB_SUFFIX} + RUNTIME DESTINATION bin + INCLUDES DESTINATION include +) + # Configure and install project include (GenerateExportHeader) @@ -52,14 +98,6 @@ include (CMakePackageConfigHelpers) generate_export_header(${PROJECT_NAME}) -install(TARGETS pigpio pigpiod_if pigpiod_if2 pig2vcd pigpiod pigs - EXPORT ${PROJECT_NAME}Targets - LIBRARY DESTINATION lib${LIB_SUFFIX} - ARCHIVE DESTINATION lib${LIB_SUFFIX} - RUNTIME DESTINATION bin - INCLUDES DESTINATION include -) - write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake" VERSION ${${PROJECT_NAME}_VERSION} @@ -89,13 +127,6 @@ install( ${ConfigPackageLocation} ) -install(FILES pigpio.h pigpiod_if.h pigpiod_if2.h - DESTINATION include - PERMISSIONS OWNER_READ OWNER_WRITE - GROUP_READ - WORLD_READ -) - if (MAN_PAGES) file(GLOB man_1_SRC "*.1") install(FILES ${man_1_SRC} From 3ca60ca5a29efaf7736281e627dfde34fc265caf Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Sun, 16 Oct 2022 23:36:25 +0200 Subject: [PATCH 6/7] make VCD converter configurable --- CMakeLists.txt | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b125923..23d40c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,6 +11,7 @@ option(BUILD_SHARED_LIBS "Create shared libraries" ON) option(MAN_PAGES "Create manual pages" OFF) option(SOCKET_INTERFACE "Build socket interface" ON) option(TESTS "Build tests" OFF) +option(PIG2VCD "Build VCD format converter" OFF) add_compile_options(-Wall) @@ -79,17 +80,19 @@ if(SOCKET_INTERFACE) endif() endif() -# pig2vcd -add_executable(pig2vcd pig2vcd.c command.c) -target_link_libraries(pig2vcd Threads::Threads) +if(PIG2VCD) + # pig2vcd + add_executable(pig2vcd pig2vcd.c command.c) + target_link_libraries(pig2vcd Threads::Threads) -install(TARGETS pig2vcd - EXPORT ${PROJECT_NAME}Targets - LIBRARY DESTINATION lib${LIB_SUFFIX} - ARCHIVE DESTINATION lib${LIB_SUFFIX} - RUNTIME DESTINATION bin - INCLUDES DESTINATION include -) + install(TARGETS pig2vcd + EXPORT ${PROJECT_NAME}Targets + LIBRARY DESTINATION lib${LIB_SUFFIX} + ARCHIVE DESTINATION lib${LIB_SUFFIX} + RUNTIME DESTINATION bin + INCLUDES DESTINATION include + ) +endif() # Configure and install project From 0bd209f185900f7eb1a7e592048383f8fbc37b4e Mon Sep 17 00:00:00 2001 From: Christian Rauch Date: Sun, 16 Oct 2022 23:46:00 +0200 Subject: [PATCH 7/7] make Python module configurable --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 23d40c4..0e7477e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,6 +12,7 @@ option(MAN_PAGES "Create manual pages" OFF) option(SOCKET_INTERFACE "Build socket interface" ON) option(TESTS "Build tests" OFF) option(PIG2VCD "Build VCD format converter" OFF) +option(PYTHON_MODULE "Build Python module" OFF) add_compile_options(-Wall) @@ -151,7 +152,7 @@ endif() # Install python modules. find_package(Python COMPONENTS Interpreter QUIET) -if(Python_FOUND) +if(Python_FOUND AND PYTHON_MODULE AND SOCKET_INTERFACE) install(CODE "execute_process(COMMAND ${Python_EXECUTABLE} ${CMAKE_SOURCE_DIR}/setup.py install --prefix=${CMAKE_INSTALL_PREFIX})") endif()