-
Notifications
You must be signed in to change notification settings - Fork 3
/
CMakeLists.txt
74 lines (58 loc) · 2.03 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
cmake_minimum_required(VERSION 3.15)
# Set the project name to your project name
project(pyrf24)
if(SKBUILD)
message(STATUS "This project is being built using scikit-build & pybind11")
endif()
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION ON)
include(cmake/using_flags.cmake)
add_subdirectory(pybind11)
include(RF24/cmake/AutoConfig_RF24_DRIVER.cmake)
add_subdirectory(RF24/utility) # configure the RF24_DRIVER
if(NOT "${RF24_LINKED_DRIVER}" STREQUAL "")
message(STATUS "Linking to utility driver '${RF24_LINKED_DRIVER}'")
endif()
# suplement our copy of linux/gpio.h into SPIDEV driver sources
set(SUPPLEMENT_LINUX_GPIO_H FALSE)
if("${RF24_DRIVER}" STREQUAL "SPIDEV")
set(SUPPLEMENT_LINUX_GPIO_H TRUE)
message(STATUS "Supplementing ${RF24_DRIVER} driver with linux/gpio.h")
list(APPEND RF24_DRIVER_SOURCES src/linux/gpio.h)
endif()
# ## Build python bindings for RF24 stack into 1 binary
pybind11_add_module(pyrf24
RF24/RF24.cpp
${RF24_DRIVER_SOURCES}
RF24Network/RF24Network.cpp
RF24Mesh/RF24Mesh.cpp
src/pyRF24.cpp
src/pyRF24Network.cpp
src/pyRF24Mesh.cpp
src/glue.cpp
)
# don't let source look for an installed RF24 lib
target_compile_definitions(pyrf24 PUBLIC USE_RF24_LIB_SRC)
if(SUPPLEMENT_LINUX_GPIO_H)
target_include_directories(pyrf24 PUBLIC src)
endif()
target_include_directories(pyrf24 PUBLIC
RF24
RF24/utility
RF24/utility/${RF24_DRIVER}
RF24Network
RF24Mesh
)
if(NOT "${RF24_LINKED_DRIVER}" STREQUAL "")
if("${RF24_DRIVER}" STREQUAL "wiringPi")
target_link_libraries(pyrf24 PUBLIC rt crypt ${RF24_LINKED_DRIVER})
else()
target_link_libraries(pyrf24 PUBLIC ${RF24_LINKED_DRIVER})
endif()
endif()
apply_flags(pyrf24)
# ############################### INSTALL RULES ####################################
# these are needed since the resulting .so files are copied into
# the binary distribution wheels (.whl files) for python.
install(TARGETS pyrf24 DESTINATION .)
# ## uncomment to show compiler args used in build logs
# set(CMAKE_VERBOSE_MAKEFILE ON)