forked from joan2937/pigpio
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
147 lines (124 loc) · 3.68 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
cmake_minimum_required(VERSION 3.0)
project(pigpio)
set(PIGPIO_LIBS)
set(SOVERSION "1")
set(CMAKE_C_FLAGS "-O3 -Wall -pthread")
set(PIGPIO_FLAGS "-L. -lrt")
#set(DESTDIR ${CMAKE_CURRENT_SOURCE_DIR}/build/dest)
if(NOT DEFINED BUILD_SHARED_LIBS)
set(BUILD_SHARED_LIBS "ON")
endif(NOT DEFINED BUILD_SHARED_LIBS)
# libpigpio.(so|a)
add_library(pigpio pigpio.c command.c custom.cext)
list(APPEND PIGPIO_LIBS pigpio)
# libpigpiod_if.(so|a)
add_library(pigpiod_if pigpiod_if.c command.c)
list(APPEND PIGPIO_LIBS pigpiod_if)
# libpigpiod_if2.(so|a)
add_library(pigpiod_if2 pigpiod_if2.c command.c)
list(APPEND PIGPIO_LIBS pigpiod_if2)
# set common library target options
foreach(lib ${PIGPIO_LIBS})
set_target_properties(${lib} PROPERTIES
POSITION_INDEPENDENT_CODE ON
SOVERSION ${SOVERSION}
)
endforeach()
# x_pigpio
add_executable(x_pigpio x_pigpio.c)
add_dependencies(x_pigpio pigpio)
target_link_libraries(x_pigpio
${PIGPIO_FLAGS}
-lpigpio
)
# x_pigpiod_if
add_executable(x_pigpiod_if x_pigpiod_if.c)
add_dependencies(x_pigpiod_if pigpiod_if)
target_link_libraries(x_pigpiod_if
${PIGPIO_FLAGS}
-lpigpiod_if
)
# x_pigpiod_if2
add_executable(x_pigpiod_if2 x_pigpiod_if2.c)
add_dependencies(x_pigpiod_if2 pigpiod_if2)
target_link_libraries(x_pigpiod_if2
${PIGPIO_FLAGS}
-lpigpiod_if2
)
# pigpiod
add_executable(pigpiod pigpiod.c)
add_dependencies(pigpiod pigpio)
target_link_libraries(pigpiod
${PIGPIO_FLAGS}
-lpigpio
)
# pigs
add_executable(pigs pigs.c command.c)
# pig2vcd
add_executable(pig2vcd pig2vcd.c command.c)
# install
install(DIRECTORY
DESTINATION ${DESTDIR}/opt/pigpio/cgi
PATTERN ""
PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
GROUP_READ GROUP_EXECUTE
WORLD_READ WORLD_EXECUTE
)
install(TARGETS pigpio pigpiod_if pigpiod_if2 pig2vcd pigpiod pigs
LIBRARY DESTINATION ${DESTDIR}/usr/local/lib
RUNTIME DESTINATION ${DESTDIR}/usr/local/bin
ARCHIVE DESTINATION ${DESTDIR}/usr/local/lib
)
install(FILES pigpio.h pigpiod_if.h pigpiod_if2.h
DESTINATION ${DESTDIR}/usr/local/include
PERMISSIONS OWNER_READ OWNER_WRITE
GROUP_READ
WORLD_READ
)
file(GLOB man_1_SRC "*.1")
install(FILES ${man_1_SRC}
DESTINATION ${DESTDIR}/usr/local/man/man1
PERMISSIONS OWNER_READ OWNER_WRITE
GROUP_READ
WORLD_READ
)
file(GLOB man_3_SRC "*.3")
install(FILES ${man_3_SRC}
DESTINATION ${DESTDIR}/usr/local/man/man3
PERMISSIONS OWNER_READ OWNER_WRITE
GROUP_READ
WORLD_READ
)
file(GLOB setup_SRC "setup.py")
find_program(PYTHON2_FOUND python2)
if(PYTHON2_FOUND)
install(CODE "execute_process(COMMAND cd ${CMAKE_SOURCE_DIR} && python2 ${setup_SRC} install)")
endif()
find_program(PYTHON3_FOUND python3)
if(PYTHON3_FOUND)
install(CODE "execute_process(COMMAND cd ${CMAKE_SOURCE_DIR} && python3 ${setup_SRC} install)")
endif()
install(CODE "execute_process(COMMAND ldconfig)")
# uninstall
if(PYTHON2_FOUND)
set(PY2_CMD python2 ${setup_SRC} install --record /tmp/pigpio > /dev/null)
set(PY2_CMD ${PY2_CMD} && xargs rm -f < /tmp/pigpio > /dev/null)
endif()
if(PYTHON3_FOUND)
set(PY3_CMD python3 ${setup_SRC} install --record /tmp/pigpio > /dev/null)
set(PY3_CMD ${PY3_CMD} && xargs rm -f < /tmp/pigpio > /dev/null)
endif()
add_custom_target(uninstall
COMMAND rm -f ${DESTDIR}/usr/local/include/pigpio.h
COMMAND rm -f ${DESTDIR}/usr/local/include/pigpiod_if.h
COMMAND rm -f ${DESTDIR}/usr/local/include/pigpiod_if2.h
COMMAND rm -f ${DESTDIR}/usr/local/lib/libpigpio*
COMMAND rm -f ${DESTDIR}/usr/local/bin/pig2vcd
COMMAND rm -f ${DESTDIR}/usr/local/bin/pigpiod
COMMAND rm -f ${DESTDIR}/usr/local/bin/pigs
COMMAND cd ${CMAKE_SOURCE_DIR} && ${PY2_CMD}
COMMAND cd ${CMAKE_SOURCE_DIR} && ${PY3_CMD}
COMMAND rm -f ${DESTDIR}/usr/local/man/man1/pig*.1
COMMAND rm -f ${DESTDIR}/usr/local/man/man3/pig*.3
COMMAND ldconfig
)