Skip to content

Commit

Permalink
conditionally build examples with pigpio
Browse files Browse the repository at this point in the history
  • Loading branch information
2bndy5 committed Jan 23, 2022
1 parent f47339e commit 20c8621
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
10 changes: 8 additions & 2 deletions examples_RPi/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,16 @@ message(STATUS "using RF24 library: ${RF24}")
find_library(RF24Network rf24network REQUIRED)
message(STATUS "using RF24Network library: ${RF24Network}")

find_library(LibPIGPIO pigpio)

foreach(example ${EXAMPLES_LIST})
# make a target
add_executable(${example} ${example}.cpp)

# link the RF24 lib to the target. Notice we specify pthread as a linked lib here
target_link_libraries(${example} PUBLIC ${RF24} pthread ${RF24Network})
if ("${LibPIGPIO}" STREQUAL "LibPIGPIO-NOTFOUND")
target_link_libraries(${example} PUBLIC ${RF24} pthread ${RF24Network})
else()
message(STATUS "linking to ${LibPIGPIO} for interrupt support")
target_link_libraries(${example} PUBLIC ${RF24} pthread ${RF24Network} ${LibPIGPIO})
endif()
endforeach()
11 changes: 10 additions & 1 deletion examples_RPi/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,20 @@ ifneq "${RPI}" "1"
RPI=$(shell cat /proc/cpuinfo | grep Hardware | grep -c BCM2709)
endif

pigpio_detected=0
ifeq ($(wildcard "/usr/lib/libpigpio.so"))
pigpio_detected=1
endif

ifeq "$(RPI)" "1"
# The recommended compiler flags for the Raspberry Pi
CCFLAGS=-Ofast -mfpu=vfp -mfloat-abi=hard -march=$(ARCH) -mtune=arm1176jzf-s -std=c++0x
ifeq "$(pigpio_detected)" "1"
CCFLAGS=$(CCFLAGS) -lpigpio
endif
else
CCFLAGS=$(CCFLAGS) -DRF24_NO_INTERRUPT
endif


# define all programs
PROGRAMS = rx-test helloworld_rx helloworld_tx
Expand Down

0 comments on commit 20c8621

Please sign in to comment.